如何读取文件格式(png、jpg、gif、bmp、tiff 等)和宽度、高度,对于具有值的那些,位图的 DPI?
Android 没有,javax.imageio.*
因此读取此内容的标准 Java 调用不可用。metadata-extractor是一款不错的产品,但不支持png
or gif
。
如何读取文件格式(png、jpg、gif、bmp、tiff 等)和宽度、高度,对于具有值的那些,位图的 DPI?
Android 没有,javax.imageio.*
因此读取此内容的标准 Java 调用不可用。metadata-extractor是一款不错的产品,但不支持png
or gif
。
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).