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

2017-12-30 Thread Bruno P. Kinoshita (JIRA)

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

Bruno P. Kinoshita commented on IMAGING-202:


Added a breakpoint after the line which I believe should trigger the error 
(attached screen shot), but could not reproduce it. Not sure if the code 
changed before or after the issue was reported, but at least from trying to 
find the code affected from reading the exception stack trace, I could not find 
a way to trigger the issue.

There's also the question on whether the image is valid or not. It could be 
something that we could change in the default behaviour of the parser, to give 
a warning instead of throwing an exception, but first we would need to properly 
reproduce the issue.

It was really helpful to have the stack trace and the test image, but now we 
would need some sample code. Feel free to re-open it in case the issue 
persists, and if it's possible to share some code for a 
[SSCCE|http://sscce.org/].

Thanks
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
> Attachments: 
> breakpoint-after-line-supposed-to-trigger-issue-i-think.png
>
>
> 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: 
> 21168, 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)


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

2017-12-30 Thread Bruno P. Kinoshita (JIRA)

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

Bruno P. Kinoshita commented on IMAGING-202:


Spent some time reading and learning more about Commons Imaging code, and 
working on issues regarding the TIFF format. Have just re-ran jhove, with 
different command line options, and found an issue in the validation of the 
image.

{noformat}
jhove -m tiff-hul  17_H1_MiUSA_ElPaso_ROICOM_1178.tif 
Jhove (Rel. 1.6, 2011-01-04)
 Date: 2017-12-30 22:35:53 NZDT
 RepresentationInformation: 17_H1_MiUSA_ElPaso_ROICOM_1178.tif
  ReportingModule: TIFF-hul, Rel. 1.5 (2007-10-02)
  LastModified: 2017-02-23 17:37:46 NZDT
  Size: 108598491
  Format: TIFF
  Status: Not well-formed
  SignatureMatches:
   TIFF-hul
  ErrorMessage: Value offset not word-aligned: 563
   Offset: 210
  MIMEtype: image/tiff
{noformat}

If you grab a TIFF image from NASA, for instance, from this URL 
https://photojournal.jpl.nasa.gov/new, you should be able to run the same 
command with one of the .tif images as input and get a clean output, with no 
ErrorMessage.

> 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: 
> 21168, 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)


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

2017-08-06 Thread Bruno P. Kinoshita (JIRA)

[ 
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. 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): 21168 (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/100 (6.966) (1 
SRational)
Adding field 37378 (0x9202: ApertureValue): 5310704/100 (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)