I am trying to programatically set the dpi metadata of an jpeg image in Java. The source of the image is a scanner, so I get the horizontal/vertical resolution from TWAIN, a
I would seem this could be a bug.
I found this post from a few google searches
Apparently there are alot more that point to a bug as well.
The post above talks about using JMagick as a third party work around.
Some issues that were not considered here:
The tree is not directly mapped to the IOMetaData. To apply data from tree, add following call after setting the densities and raster parameters:
data.setFromTree("javax_imageio_jpeg_image_1.0", tree);
don't use the meta data as first parameter in the write call. See JPEGImageWriter#write(IIOMetaData, IIOImage, ImageWriteParam)
. If streamMetaData is not NULL, a warning (WARNING_STREAM_METADATA_IGNORED) will be generated.
set the meta data as IOMetadata
of the IOImage
. These meta data are used by JPEGImageWriter. The correct write call then is
imageWriter.write(null, new IIOImage(F_scaledImg, null, data), jpegParams);