我如何获得图像的分辨率。

BufferedImage theBufferedImage = ImageIO.read(new File("/tmp/foo.jpg"));
int width = theBufferedImage.getWidth();
int height = theBufferedImage.getHeight();
int resolution = ???


问候,
萨隆巴

最佳答案

您无法从BufferedImage中获取DPI或任何其他此类信息,因此必须检查原始JPEG文件。它只是一个没有任何元数据的光栅图像。如果要将BufferedImage写入文件,则可以设置DPI。但是BufferedImage本身没有DPI的概念,只是像素。

关于java - 获取图像分辨率(theBufferedImage),我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/48578345/

10-11 16:10