In c#, we can use Image.HorizontalResolution and Image.VerticalResolution.
But in java, how to get it?
I found ImageInfo.java
, but it only support a few image types.
In c#, we can use Image.HorizontalResolution and Image.VerticalResolution.
But in java, how to get it?
I found ImageInfo.java
, but it only support a few image types.
ImageMagick is a powerful tool for all image related work. IM needs to be installed and requires some configuration for the environment but it's worth the trouble.
http://www.imagemagick.org
I recommend you use JMagick wit IM:
http://www.jmagick.org
I won't explain the details on how to since it is documented in urls given.
With the help of an ImageReader instance, you can get the image meta data in a neutral format, and then parse it for what you need. A DTD is here.
(Source/Inspiration: David Thielen)
Note that you will get a dpi only if it is there.
If you wonder what's in the Metadata XML, use this code:
You can use Apache Commons Sanselan library to get image info: http://commons.apache.org/imaging/index.html.
Find dpi of .bmp image use :
Maven Dependency :
I found this example interesting:
Get your ImageReader instance. Then use the first ImageReader, set the Input and read IIOImage or only getImageMetadata(pageIndex). You get the image format neutral metadata xml and parse it for the desired data.
// ... calc dot per centimeter to dpi : dpi = dpc / 2.54
The whole image neutral metadata format at