Write dpi metadata to a jpeg image in Java

心已入冬 提交于 2019-11-28 10:54:06

Some issues that were not considered here:

  1. 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);
    
  2. 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.

  3. 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);
    

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!