How can I compress jpeg images in Java without losing any metadata in that image?
- by guitarpoet
I want compress jpeg files using Java. I do it like this:
Read the image as BufferedImage
Write the image to another file with compression rate.
OK, that seems easy, but I find the ICC color profile and the EXIF information are gone in the new file and the DPI of the image is dropped from 240 to 72. It looks different from the origin image. I use a tool like preview in OS X. It can perfectly change the quality of the image without affecting other information.
Can I done this in Java? At least keep the ICC color profile and let the image color look the same as the origin photo?