How to get the dpi of an image(Java)

后端 未结 7 1886
无人及你
无人及你 2021-01-06 01:51

In c#, we can use Image.HorizontalResolution and Image.VerticalResolution.

But in java, how to get it?

I found ImageInfo.java, but it only supp

7条回答
  •  悲&欢浪女
    2021-01-06 02:01

    You can use Apache Commons Sanselan library to get image info: http://commons.apache.org/imaging/index.html.

    final ImageInfo imageInfo = Sanselan.getImageInfo(file_);
    
    final int physicalWidthDpi = imageInfo.getPhysicalWidthDpi();
    final int physicalHeightDpi = imageInfo.getPhysicalHeightDpi();
    

提交回复
热议问题