commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "George Wei" <gw...@163.com>
Subject [sanselan]How to read resolution of a JPEG image without Exif?
Date Sat, 08 Oct 2011 23:06:32 GMT
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

Mime
View raw message