简体   繁体   English

获取图像分辨率(theBufferedImage)

[英]Get image resolution ( theBufferedImage )

how do I get the resolution of an image. 我如何获得图像的分辨率。

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

Regards, saromba 此致saromba

You can't get DPI or any other such information out of BufferedImage , you'll have to examine the original JPEG file for it. 您无法从BufferedImage获取DPI或任何其他此类信息,您必须为其检查原始JPEG文件。 It's just a raster image without any metadata. 它只是一个没有任何元数据的光栅图像。 If you're writing a BufferedImage to a file, you can set the DPI. 如果要将BufferedImage写入文件,则可以设置DPI。 But BufferedImage itself has no concept of DPI, it's just pixels. 但是BufferedImage本身没有DPI的概念,只是像素。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM