Made EXIFReader more lenient while parsing.

- Now supports empty strings encoded with value count 0.
 - Added Rational.NaN constant to handle bad EXIF data.
Fixed a bug in the JPEGImageReader's raw EXIF thumbnail decoding.
Added test cases.
This commit is contained in:
Harald Kuhr
2012-02-02 16:55:01 +01:00
parent f2e3f7ed03
commit c3524adbbc
9 changed files with 138 additions and 49 deletions

View File

@@ -303,7 +303,7 @@ public class JPEGImageReaderTest extends ImageReaderAbstractTestCase<JPEGImageRe
}
@Test
public void testEXIFRAWThumbnail() throws IOException {
public void testEXIFRawThumbnail() throws IOException {
JPEGImageReader reader = createReader();
reader.setInput(ImageIO.createImageInputStream(getClassLoaderResource("/jpeg/exif-rgb-thumbnail-sony-d700.jpg")));
@@ -317,4 +317,20 @@ public class JPEGImageReaderTest extends ImageReaderAbstractTestCase<JPEGImageRe
assertEquals(80, thumbnail.getWidth());
assertEquals(60, thumbnail.getHeight());
}
@Test
public void testBadEXIFRawThumbnail() throws IOException {
JPEGImageReader reader = createReader();
reader.setInput(ImageIO.createImageInputStream(getClassLoaderResource("/jpeg/exif-rgb-thumbnail-bad-exif-kodak-dc210.jpg")));
assertTrue(reader.hasThumbnails(0));
assertEquals(1, reader.getNumThumbnails(0));
assertEquals(96, reader.getThumbnailWidth(0, 0));
assertEquals(72, reader.getThumbnailHeight(0, 0));
BufferedImage thumbnail = reader.readThumbnail(0, 0);
assertNotNull(thumbnail);
assertEquals(96, thumbnail.getWidth());
assertEquals(72, thumbnail.getHeight());
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 KiB