Using imageIO, I usually have the problem of transforming an image file, and after overwriting it, it loses all of its EXIF data. Is there any way to preserve it without first extracting it, caching it, and then resetting it?
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- Difference between Types.INTEGER and Types.NULL in
Here is my solution using a combination of ImageIO, Imgscalr and Apache commons-imaging. It's a pity there's no single library which combines reading the image with its metadata, making this probably rather excessive on memory usage; Improvements welcome.
ImageIO do have this functionality itself, but instead of ImageIO.read you will need to use ImageReader:
(you may want to also check if such reader exists). Then you need to set the input:
Now you may save your metadata:
And then read the image:
When you want to save new image, you should use ImageWriter:
As it's old topic, I guess this answer is a bit too late, but may help others as this topic is still googlable.