2
votes

I want to modify the metadata of some types of images (png, jpeg or gif) and I found a a code that works very well for PNG images on this topic, provided by haraldK. When I try to run it on a jpg image though, it throws this error : javax.imageio.IIOException: JFIF APP0 must be first marker after SOI. The error is thrown when arriving on the line IIOImage image = reader.readAll(0, null);

What can I do to get this working ?

Thanks in advance for your answer.

1
You can try my JPEG plugin for ImageIO, it will most likely handle your image fine, with no code changes (only new dependencies on class path).Harald K
So I downloaded the jars for jpeg and TIFF that are showed under 'Manual dependency example', is it enough to work ? And when you mean no code changes it means that I can use the exact same code you proposed on the subject I mentionned ?Peter suib
You need to place the jars on class path. If your application is a web app, you need to read the part about web apps. Otherwise it should be enough. You can check the class of the reader. It should be com.twelvemonkeys...JPEGImageReader. If it is, and it does not work, I need to see the JPEG file to say why.Harald K

1 Answers

0
votes

The problem you face is the JPEG standard did not define a file format. Several file formats appeared. E.g. JFIF. EXIF. SPIFF. These formats represent metadata in different ways. Apparently the library you are trying to use only supports the JFIF file format. Apparently your library only supports the JFIF format while you have a file in a different format (likely EXIF).

So you need a library that supports your file format or you need to modify the library you have to work with whatever file format you have. That could be a fairly substantial change.