Author: damjan
Date: Mon Oct 21 17:53:56 2013
New Revision: 1534292

URL: http://svn.apache.org/r1534292
Log:
Make the EOI check in TiffReader.getJpegRawImageData()
only get performed when the strict flag is set,
as some images out in the wild seem to have thumbnails
without a valid EOI.

IMAGING-99 was the reason that EOI check was needed.
However testing the IMAGING-99 image with the section
commented out still works, so the EOI check wasn't 
what fixed IMAGING-99 

Jira issue key: IMAGING-108.


Modified:
    commons/proper/imaging/trunk/src/changes/changes.xml
    
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffReader.java

Modified: commons/proper/imaging/trunk/src/changes/changes.xml
URL: 
http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/changes/changes.xml?rev=1534292&r1=1534291&r2=1534292&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/changes/changes.xml (original)
+++ commons/proper/imaging/trunk/src/changes/changes.xml Mon Oct 21 17:53:56 
2013
@@ -46,6 +46,9 @@ The <action> type attribute can be add,u
   <body>
 
     <release version="1.0" date="TBA" description="TBA">
+      <action issue="IMAGING-108" dev="damjan" type="fix">
+        JPEG EOI marker could not be found at expected location.
+      </action>
       <action issue="IMAGING-101" dev="ggregory" type="fix" due-to="Colm O 
hEigeartaigh">
         GIF dimensions transposed.
       </action>

Modified: 
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffReader.java
URL: 
http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffReader.java?rev=1534292&r1=1534291&r2=1534292&view=diff
==============================================================================
--- 
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffReader.java
 (original)
+++ 
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffReader.java
 Mon Oct 21 17:53:56 2013
@@ -506,8 +506,9 @@ public class TiffReader extends BinaryFi
         }
         final byte data[] = byteSource.getBlock(offset, length);
         // check if the last read byte is actually the end of the image data
-        if (length < 2 ||
-                (((data[data.length - 2] & 0xff) << 8) | (data[data.length - 
1] & 0xff)) != JpegConstants.EOIMarker) {
+        if (strict &&
+                (length < 2 ||
+                (((data[data.length - 2] & 0xff) << 8) | (data[data.length - 
1] & 0xff)) != JpegConstants.EOIMarker)) {
             throw new ImageReadException("JPEG EOI marker could not be found 
at expected location");
         }
         return new JpegImageData(offset, length, data);


Reply via email to