You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Bruno P. Kinoshita (JIRA)" <ji...@apache.org> on 2017/08/06 10:23:01 UTC

[jira] [Commented] (IMAGING-202) java.io.IOException: Could not read block

    [ https://issues.apache.org/jira/browse/IMAGING-202?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16115746#comment-16115746 ] 

Bruno P. Kinoshita commented on IMAGING-202:
--------------------------------------------

Hi! I am evaluating imaging libraries to process images for a IIIF experiment, and going through some of the tickets for Commons Imaging.

Can you test with the latest code from the master branch? And maybe share a code snippet? I cannot reproduce the error with the following code:

{code:java}
public class TTT {

    public static void main(String[] args) {
        TiffReader reader = new TiffReader(/* strict */ true);
        ByteSource byteSource = new ByteSourceFile(
                new File("/home/kinow/Downloads/17_H1_MiUSA_ElPaso_ROICOM_1178.tif"));
        Listener listener = new Listener() {

            @Override
            public boolean setTiffHeader(TiffHeader tiffHeader) {
                System.out.println("Adding header " + tiffHeader);
                return true;
            }

            @Override
            public boolean addDirectory(TiffDirectory directory) {
                System.out.println("Adding directory " + directory.getElementDescription());
                return true;
            }

            @Override
            public boolean addField(TiffField field) {
                System.out.println("Adding field " + field);
                return true;
            }

            @Override
            public boolean readImageData() {
                System.out.println("READ IMAGE DATA...");
                return true;
            }

            @Override
            public boolean readOffsetDirectories() {
                System.out.println("### READ OFFSET DIRECTORIES");
                return true;
            }

        };
        try {
            reader.read(byteSource, Collections.<String, Object> emptyMap(), FormatCompliance.getDefault(), listener);
        } catch (ImageReadException | IOException e) {
            e.printStackTrace();
        }
        System.out.println("OK!");
    }
}
{code}

It gives me the following output:

{noformat}
Adding header org.apache.commons.imaging.formats.tiff.TiffHeader@5e3b8219
Adding field 254 (0xfe: NewSubfileType): 0 (1 Long)
Adding field 256 (0x100: ImageWidth): 6300 (1 Long)
Adding field 257 (0x101: ImageLength): 4200 (1 Long)
Adding field 258 (0x102: BitsPerSample): 8, 8, 8, 8 (4 Short)
Adding field 259 (0x103: Compression): 1 (1 Short)
Adding field 262 (0x106: PhotometricInterpretation): 5 (1 Short)
Adding field 271 (0x10f: Make): 'Canon' (6 ASCII)
Adding field 272 (0x110: Model): 'Canon EOS 5D Mark IV' (21 ASCII)
Adding field 273 (0x111: PreviewImageStart): 1024 (1 Long)
Adding field 277 (0x115: SamplesPerPixel): 4 (1 Short)
Adding field 278 (0x116: RowsPerStrip): 4200 (1 Long)
Adding field 279 (0x117: PreviewImageLength): 211680000 (1 Long)
Adding field 282 (0x11a: XResolution): 300 (1 Rational)
Adding field 283 (0x11b: YResolution): 300 (1 Rational)
Adding field 284 (0x11c: PlanarConfiguration): 1 (1 Short)
Adding field 296 (0x128: ResolutionUnit): 2 (1 Short)
Adding field 305 (0x131: Software): 'GMG Software' (13 ASCII)
Adding field 332 (0x14c: InkSet): 1 (1 Short)
Adding field 34377 (0x8649: PhotoshopSettings): 56, 66, 73, 77, 4, 37, 0, 0, 0, 0, 0, 16, -47, -56, -60, 86, 39, 34, 92, 113, -52, 87, 24, 99, 7, -37, -76, 109, 56, 66, 73, 77, 4, 58, 0, 0, 0, 0, 0, -27, 0, 0, 0, 16, 0, 0, 0, 1, 0, 0, 0... (8898) (8898 Byte)
Adding field 34665 (0x8769: ExifOffset): 108597878 (1 Long)
Adding field 34675 (0x8773: InterColorProfile): 0, 41, -18, 52, 0, 0, 0, 0, 2, 0, 0, 0, 112, 114, 116, 114, 67, 77, 89, 75, 76, 97, 98, 32, 7, -41, 0, 5, 0, 24, 0, 13, 0, 55, 0, 39, 97, 99, 115, 112, 65, 80, 80, 76, 0, 2, 0, 0, 0, 0, 0... (2747956) (2747956 Undefined)
READ IMAGE DATA...
Adding directory TIFF Directory (Root)
### READ OFFSET DIRECTORIES
Adding field 33434 (0x829a: ExposureTime): 1/125 (0.008) (1 Rational)
Adding field 33437 (0x829d: FNumber): 63/10 (6.3) (1 Rational)
Adding field 34850 (0x8822: ExposureProgram): 1 (1 Short)
Adding field 34855 (0x8827: PhotographicSensitivity): 1600 (1 Short)
Adding field 34864 (0x8830: Unknown Tag): 2 (1 Short)
Adding field 34866 (0x8832: Unknown Tag): 1600 (1 Long)
Adding field 36864 (0x9000: ExifVersion): 48, 50, 51, 48 (4 Undefined)
Adding field 36867 (0x9003: DateTimeOriginal): '2017:01:05 13:13:06' (20 ASCII)
Adding field 36868 (0x9004: DateTimeDigitized): '2017:01:05 13:13:06' (20 ASCII)
Adding field 37377 (0x9201: ShutterSpeedValue): 6965784/1000000 (6.966) (1 SRational)
Adding field 37378 (0x9202: ApertureValue): 5310704/1000000 (5.311) (1 Rational)
Adding field 37380 (0x9204: ExposureCompensation): 0 (1 SRational)
Adding field 37382 (0x9206: Subject Distance): 0 (1 Rational)
Adding field 37383 (0x9207: MeteringMode): 5 (1 Short)
Adding field 37385 (0x9209: Flash): 16 (1 Short)
Adding field 37386 (0x920a: FocalLength): 61 (1 Rational)
Adding field 37521 (0x9291: SubSecTimeOriginal): '00' (3 ASCII)
Adding field 37522 (0x9292: SubSecTimeDigitized): '00' (3 ASCII)
Adding field 40961 (0xa001: ColorSpace): -1 (1 Short)
Adding field 40962 (0xa002: ExifImageWidth): 6300 (1 Long)
Adding field 40963 (0xa003: ExifImageLength): 4200 (1 Long)
Adding field 41486 (0xa20e: FocalPlaneXResolution): 187405072/32768 (5,719.149) (1 Rational)
Adding field 41487 (0xa20f: FocalPlaneYResolution): 187724608/32768 (5,728.9) (1 Rational)
Adding field 41488 (0xa210: FocalPlaneResolutionUnit): 2 (1 Short)
Adding field 41728 (0xa300: FileSource): 3 (1 Undefined)
Adding field 41729 (0xa301: SceneType): 1 (1 Undefined)
Adding field 41985 (0xa401: CustomRendered): 0 (1 Short)
Adding field 41986 (0xa402: ExposureMode): 1 (1 Short)
Adding field 41987 (0xa403: WhiteBalance): 1 (1 Short)
Adding field 41990 (0xa406: SceneCaptureType): 0 (1 Short)
Adding field 42033 (0xa431: BodySerialNumber): '032022003578' (13 ASCII)
Adding field 42034 (0xa432: LensSpecification): 24, 70, Invalid rational (0/0), Invalid rational (0/0) (4 Rational)
Adding field 42036 (0xa434: LensModel): 'Canon EF 24-70mm f/2.8L II USM' (31 ASCII)
Adding field 42037 (0xa435: LensSerialNumber): '0310008085' (11 ASCII)
READ IMAGE DATA...
Adding directory TIFF Directory (Exif)
### READ OFFSET DIRECTORIES
OK!
{noformat}

However, there could be something wrong with the image... at least that's what Linux's `exiv2` tells me:

{noformat}
$ exiv2 17_H1_MiUSA_ElPaso_ROICOM_1178.tif 
Warning: Directory Image, entry 0x0111: Strip 0 is outside of the data area; ignored.
Error: Directory (Last IFD item) with 10825 entries considered invalid; not read.
File name       : 17_H1_MiUSA_ElPaso_ROICOM_1178.tif
File size       : 108598491 Bytes
MIME type       : image/tiff
Image size      : 6300 x 4200
Camera make     : Canon
Camera model    : Canon EOS 5D Mark IV
Image timestamp : 2017:01:05 13:13:06
Image number    : 
Exposure time   : 1/125 s
Aperture        : F6.3
Exposure bias   : 0 EV
Flash           : No, compulsory
Flash bias      : 
Focal length    : 61.0 mm
Subject distance: Unknown
ISO speed       : 1600
Exposure mode   : Manual
Metering mode   : Multi-segment
Macro mode      : 
Image quality   : 
Exif Resolution : 6300 x 4200
White balance   : Manual
Thumbnail       : None
Copyright       : 
Exif comment    : 
{noformat}

Had a class about the TIFF format in university, but never really learned how to interpret, so not sure if there's something wrong with the image. JHOVE reports the image as valid for that matter.

Cheers
Bruno

> java.io.IOException: Could not read block
> -----------------------------------------
>
>                 Key: IMAGING-202
>                 URL: https://issues.apache.org/jira/browse/IMAGING-202
>             Project: Commons Imaging
>          Issue Type: Bug
>          Components: Format: JPEG, Format: TIFF
>    Affects Versions: 1.0
>            Reporter: Srijan Bhatnagar
>            Priority: Critical
>
> Some images could not be read with imaging. The following exception appears - 
> {code}
> java.io.IOException: Could not read block (block start: 1024, block length: 211680000, data length: 108598491).
> 	at org.apache.commons.imaging.common.bytesource.ByteSourceInputStream.getBlock(ByteSourceInputStream.java:216)
> 	at org.apache.commons.imaging.formats.tiff.TiffReader.getTiffRawImageData(TiffReader.java:447)
> 	at org.apache.commons.imaging.formats.tiff.TiffReader.readDirectory(TiffReader.java:224)
> 	at org.apache.commons.imaging.formats.tiff.TiffReader.readDirectory(TiffReader.java:122)
> 	at org.apache.commons.imaging.formats.tiff.TiffReader.readDirectories(TiffReader.java:115)
> 	at org.apache.commons.imaging.formats.tiff.TiffReader.read(TiffReader.java:427)
> 	at org.apache.commons.imaging.formats.tiff.TiffReader.readContents(TiffReader.java:419)
> 	at org.apache.commons.imaging.formats.tiff.TiffImageParser.getMetadata(TiffImageParser.java:123)
> 	at org.apache.commons.imaging.ImageParser.getMetadata(ImageParser.java:144)
> 	at com.day.cq.dam.commons.handler.StandardImageHandler.extractMetadata(StandardImageHandler.java:385)
> 	at com.day.cq.dam.commons.handler.StandardImageHandler.extractMetadata(StandardImageHandler.java:201)
> 	at com.day.cq.dam.core.process.MetadataExtractor.extractMetadata(MetadataExtractor.java:82)
> 	at com.day.cq.dam.core.process.MetadataProcessorProcess.execute(MetadataProcessorProcess.java:121)
> 	at com.day.cq.workflow.compatibility.CQWorkflowProcessRunner.execute(CQWorkflowProcessRunner.java:93)
> 	at com.adobe.granite.workflow.core.job.HandlerBase.executeProcess(HandlerBase.java:189)
> 	at com.adobe.granite.workflow.core.job.JobHandler.process(JobHandler.java:244)
> 	at org.apache.sling.event.impl.jobs.JobConsumerManager$JobConsumerWrapper.process(JobConsumerManager.java:500)
> 	at org.apache.sling.event.impl.jobs.queues.JobQueueImpl.startJob(JobQueueImpl.java:291)
> 	at org.apache.sling.event.impl.jobs.queues.JobQueueImpl.access$100(JobQueueImpl.java:58)
> 	at org.apache.sling.event.impl.jobs.queues.JobQueueImpl$1.run(JobQueueImpl.java:227)
> 	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
> 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
> 	at java.lang.Thread.run(Unknown Source)
> {code}
> The zipped TIF file can be downloaded from - https://files.acrobat.com/a/preview/9ac91668-221f-479a-a45b-c5f685b9c021 



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)