mirror of
https://github.com/haraldk/TwelveMonkeys.git
synced 2025-08-04 03:55:28 -04:00
TMI-112: Now ignoring (removing) empty DHT node in metadata.
This commit is contained in:
parent
aef7b8bfba
commit
493edada59
@ -241,7 +241,12 @@ final class JPEGImage10MetadataCleaner {
|
|||||||
Node dht = dhts.item(j);
|
Node dht = dhts.item(j);
|
||||||
NodeList dhtables = dht.getChildNodes();
|
NodeList dhtables = dht.getChildNodes();
|
||||||
|
|
||||||
if (dhtables.getLength() > 4) {
|
if (dhtables.getLength() < 1) {
|
||||||
|
// Why is there an empty DHT node?
|
||||||
|
dht.getParentNode().removeChild(dht);
|
||||||
|
reader.processWarningOccurred("Metadata contains empty dht node. Ignoring.");
|
||||||
|
}
|
||||||
|
else if (dhtables.getLength() > 4) {
|
||||||
IIOMetadataNode acTables = new IIOMetadataNode("dht");
|
IIOMetadataNode acTables = new IIOMetadataNode("dht");
|
||||||
dht.getParentNode().insertBefore(acTables, dht.getNextSibling());
|
dht.getParentNode().insertBefore(acTables, dht.getNextSibling());
|
||||||
|
|
||||||
@ -262,6 +267,8 @@ final class JPEGImage10MetadataCleaner {
|
|||||||
}
|
}
|
||||||
catch (IIOInvalidTreeException e) {
|
catch (IIOInvalidTreeException e) {
|
||||||
if (JPEGImageReader.DEBUG) {
|
if (JPEGImageReader.DEBUG) {
|
||||||
|
new XMLSerializer(System.out, System.getProperty("file.encoding")).serialize(imageMetadata.getAsTree(JAVAX_IMAGEIO_JPEG_IMAGE_1_0), false);
|
||||||
|
System.out.println("-- 8< --");
|
||||||
new XMLSerializer(System.out, System.getProperty("file.encoding")).serialize(tree, false);
|
new XMLSerializer(System.out, System.getProperty("file.encoding")).serialize(tree, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -416,10 +416,11 @@ public class JPEGImageReaderTest extends ImageReaderAbstractTestCase<JPEGImageRe
|
|||||||
|
|
||||||
@Ignore("Known issue in com.sun...JPEGMetadata")
|
@Ignore("Known issue in com.sun...JPEGMetadata")
|
||||||
@Test
|
@Test
|
||||||
public void testExifStandardMetadataColorSpaceTypeYCbCr() {
|
public void testStandardMetadataColorSpaceTypeRGBForYCbCr() {
|
||||||
// These reports RGB in standard metadata, while the data is really YCbCr
|
// These reports RGB in standard metadata, while the data is really YCbCr.
|
||||||
fail("/jpeg/exif-jpeg-thumbnail-sony-dsc-p150-inverted-colors.jpg");
|
fail("/jpeg/exif-jpeg-thumbnail-sony-dsc-p150-inverted-colors.jpg");
|
||||||
fail("/jpeg/exif-pspro-13-inverted-colors.jpg");
|
fail("/jpeg/exif-pspro-13-inverted-colors.jpg");
|
||||||
|
// Not Exif, but same issue: SOF comp ids are JFIF standard 1-3 and *should* be interpreted as YCbCr but isn't.
|
||||||
fail("/jpeg/no-jfif-ycbcr.jpg");
|
fail("/jpeg/no-jfif-ycbcr.jpg");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1345,4 +1346,24 @@ public class JPEGImageReaderTest extends ImageReaderAbstractTestCase<JPEGImageRe
|
|||||||
|
|
||||||
return sortedNodes;
|
return sortedNodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testInvalidDHTIssue() throws IOException {
|
||||||
|
// Image has JFIF with DHT that is okay on read, but not when you set back from tree...
|
||||||
|
JPEGImageReader reader = createReader();
|
||||||
|
try {
|
||||||
|
reader.setInput(ImageIO.createImageInputStream(getClassLoaderResource("/jpeg/jfif-progressive-invalid-dht.jpg")));
|
||||||
|
|
||||||
|
IIOMetadata metadata = reader.getImageMetadata(0);
|
||||||
|
assertNotNull(metadata);
|
||||||
|
|
||||||
|
Node tree = metadata.getAsTree(metadata.getNativeMetadataFormatName());
|
||||||
|
assertNotNull(tree);
|
||||||
|
assertThat(tree, new IsInstanceOf(IIOMetadataNode.class));
|
||||||
|
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
reader.dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Binary file not shown.
After Width: | Height: | Size: 122 KiB |
Loading…
x
Reference in New Issue
Block a user