我想获得图像 dpi 以将像素转换为厘米,所以我使用 ImageInfo.java 来获得这个:
ImageInfo myMapInfo = new ImageInfo();
try {
File testFile = new File(fileNameString);
InputStream myMapStream = new FileInputStream(testFile);
myMapInfo.setInput(myMapStream);
myMapInfo.setDetermineImageNumber(true);
myMapInfo.setCollectComments(true);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
x = myMapInfo.getPhysicalWidthInch();
y = myMapInfo.getPhysicalHeightInch();
但不幸的是我在(x,y)中得到-1和-1!我使用这个类: ImageInfo.java