How to preserve xmp metadata when resizing jpg images
posted 8 years ago
I have a project where I'm required to read jpg images to extract their xmp metadata and downsize them if required. The images will be stored as byte arrays. I can extract the xmp data fine and I can resize the image fine, but the metadata is lost on the way.
I use ImageIO.read(file) to get a BufferedImage which I might resize if it is too large for our storage. I then convert this BufferedImage into a byte array and pass this to the storage object (which requires a byte array). But the xmp data I extracted before resizing the image are not preserved when using BufferedImage, the BufferedImage class seems to be concerned with the actual image data only. Are there alternatives that will let me resize and preserve the metadata, or do I have to somehow write the metadata into the byte array I have after resizing?