Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Observed multiple instances of PNG chunk 'eXIf', for which multiples are not allowed #683

Open
Nathipha opened this issue Oct 17, 2024 · 2 comments

Comments

@Nathipha
Copy link

Java 8, metadata-extractor 2.19.0, xmpcore 6.1.11
I'm trying to read the metadata of this png image (also attached it) with the following code:

String input = "C:\\misc\\EXIF\\testimgs\\Minions-png-1.png";

try {
    File img = new File(input);
    Metadata meta = ImageMetadataReader.readMetadata(img);
} catch(Exception e) {
    e.printStackTrace();
}

...but it's throwing an Exception:

com.drew.imaging.png.PngProcessingException: Observed multiple instances of PNG chunk 'eXIf', for which multiples are not allowed
	at com.drew.imaging.png.PngChunkReader.extract(PngChunkReader.java:115)
	at com.drew.imaging.png.PngMetadataReader.readMetadata(PngMetadataReader.java:103)
	at com.drew.imaging.ImageMetadataReader.readMetadata(ImageMetadataReader.java:157)
	at com.drew.imaging.ImageMetadataReader.readMetadata(ImageMetadataReader.java:124)
	at com.drew.imaging.ImageMetadataReader.readMetadata(ImageMetadataReader.java:204)
	at Main.main(Main.java:41)

This seems to be the same as in the second to last post in this issue thread (but the other poster hasn't created his own issue yet).

How do I go about fixing this?

Minions-png-1

@drewnoakes
Copy link
Owner

On a phone so don't have full context, but my sense is that maybe we can loosen the restriction here and tolerate invalid data.

Certain chunks are not allowed to exist more than once, and the library is enforcing that. Some software must have produced invalid PNG data.

There are lots of ways data can be invalid. It happens. We generally try to tolerate and continue in the face of such errors.

If you want to dig into the details and see about making a PR I'll be happy to help review and merge.

@Nathipha
Copy link
Author

Oh, so that means that that is a broken .png? Image viewers (even the Windows one) and PaintShopPro are able to open it just fine. How do I fix the image or make sure that I don't get the same problem with other images too, is there a parameter I can set in the library to just ignore this specific one?

How would I go about fixing this in code, I've got no idea where to even start tbh.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants