Link to home
Start Free TrialLog in
Avatar of Ronald112197
Ronald112197Flag for Germany

asked on

retrieve image information (height, width, dpi, color depth) from JPG, GIF, PNG

I need to retrieve the "size" (in pixels and in inches/centimeters) and color depth from BMP, JPG, GIF and PNG files. The pixel size seems to be relatively easy, the dpi - value poses problems at least for PNG.

I would very much prefer a "pure JDK" solution (source level 1.6 is ok!) or a Sun library.
Some third party library must be small (< 100 KB), free and open source...

I'm quite good at Java, but the last time I used "Image"-objects was in Java 1.1 (!) :-) I hope some things have improved since then ;-)

Of course a "generic solution" for "almost any type of image" would be great. However, some special code for the above formats is also ok, I probably won't need more formats in the near future...

Thanks in advance for any help!
Avatar of ebertk
ebertk

Here's a good little class file that you can use to find just about anything you need about an image:
http://schmidt.devlib.org/image-info/

Hope this helps!
Avatar of Ronald112197

ASKER

Thanks for the link, but I already have this one and it does NOT support the (dpi) resolution for PNG images :-(
(see here: http://schmidt.devlib.org/image-info/#knownissues)

Actually, that's why I wrote "the dpi value poses problems for PNG" :-)
This is really a pity because I used png for 80% of the files I need to index now...

Any other ideas?
An image has no size in cm / inches but in pixels.
The size depends on the medium that you display in on.

;JOOP!
ohhh please... no offense, but I specifically asked about the dpi value and this is (or at least can be) stored in all of the file formats I mentioned. I checked many files and all of them have the dpi property set (it is displayed in the property sheet of Windows Explorer). I just cannot retrieve them from my Java program - yet...
(background: this is for scanned documents and I need to check the paper format of the originals)

I'm currently using the class mentioned by ebertk and it works for BMP and JPG, but not PNG.
I've also "stumbled across" (?) "Imagero", but it's much too large (> 2 MB) and source code is not provided...

This here seems interesting / promising:
http://www.dmoz.org/Computers/Programming/Languages/Java/Class_Libraries/Graphics/Data_Formats/

I'm trying to figure out how to use http://www.sixlegs.com/software/png/
Can anybody tell me how to use it? I don't know which properties I have to retrieve...

Completely different suggestions are still welcome!
ASKER CERTIFIED SOLUTION
Avatar of Ronald112197
Ronald112197
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial