You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by George Wei <gw...@163.com> on 2011/10/09 01:06:32 UTC

[sanselan]How to read resolution of a JPEG image without Exif?

Dear all,

I have a JPEG image which colorspace is CMYK and it has no Exif information.

When I use Photoshop open it, I can see its resolution is 600DPI. I also can read its resolution by right-click it in Windows Explorer, then select menuitem "Properties", then switch to tab "Summary", at last click button "Advanced".

I have to read its resolution in my Java application. I've tried several imaging tools/libraries like JAI Image/IO Tools, Apache FOP, Apache Sanselan, iText, but I always failed.

for Sanselan, the test code is as follows:

try {
	File file = new File("C:/hs8mm.jpg");
	ImageInfo imageInfo = Sanselan.getImageInfo(file);
	System.out.println(imageInfo.getPhysicalWidthDpi());
} catch (ImageReadException e) {
	e.printStackTrace();
} catch (IOException e) {
	e.printStackTrace();
} catch (BadElementException e) {
	e.printStackTrace();
} 

The output is -1.

Is there another way to read the resolution? Thanks for any help.

Regards,
George

[sanselan]Re: How to read resolution of a JPEG image without Exif?

Posted by George Wei <gw...@163.com>.
The JPEG image can be downloaded at http://dl.iteye.com/topics/download/cbd41105-0f24-35bd-9e6f-d33cf4a5503d

George



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org