如何获取图像的dpi(Java) [英] How to get the dpi of an image(Java)
本文介绍了如何获取图像的dpi(Java)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在c#中,我们可以使用Image.HorizontalResolution和Image.VerticalResolution。
In c#, we can use Image.HorizontalResolution and Image.VerticalResolution.
但在java中,如何获取它?
But in java, how to get it?
我找到 ImageInfo.java
,但它只支持几种图像类型。
I found ImageInfo.java
, but it only support a few image types.
http://kickjava.com/src/imageinfo/ImageInfo .java.htm
推荐答案
您可以使用Apache Commons Sanselan库获取图像信息:http://commons.apache.org/imaging/index.html 。
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();
这篇关于如何获取图像的dpi(Java)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文