Reputation: 32874
How can I read the file format (png, jpg, gif, bmp, tiff, etc) and the width, height, and for those that have the value, the DPI for a bitmap?
Android does not have javax.imageio.*
so the standard Java calls to read this are not available. metadata-extractor is a good product but does not support png
or gif
.
Upvotes: 0
Views: 2973
Reputation: 75896
Width and height, along with bitdepth and color model, are not usually considered "metadata", rather they are basic image properties. By "image metadata" we usually refer to less essential data like physical resolution (DPI), EXIF-like data (timestamp, camera model, etc), etc; these are relatively format specific.
If you have decoded a image file (PNG, JPEG, GIF...) into a Bitmap, then you can ask the Bitmap object for the basic properties (eg, getHeight()). But if you need to ask for some "metadata", which is format specific, a Bitmap object won't store that information, you need something like the metadata-extractor you linked.
For PNG, you can also use this library (my own).
Upvotes: 2