TIFF 高度错误
好吧,我同意这是一个奇怪的问题,但请耐心等待。
我有一个 TIFF
图像,并且使用的是 Windows
。当我右键单击并转到属性
时,我看到宽度 = 1728 像素
和 高度
= 1146 像素
。当我使用 Java
作为 BufferedImage
读取它并调用 getWidth()
和 getHeight()
时,我看到了同样的事情。当我用 MS Paint
打开它时,我看到相同的大小。
但问题是这个尺寸不正确,因为高度太小,图像看起来白痴。现在有趣的部分是:当我使用 IrfanView
打开它时,我看到它正常,高度 = 2292 像素
。当我使用 Windows 照片查看器
打开它时,它看起来不错,高度 = 2292 像素
。
所以我的问题是:尽管在图像的元数据中指定了错误的高度,但 IrfanView 和 Windows 照片查看器如何设法识别正确的高度?那么如何在 Java 中做同样的事情呢?我不想向用户展示一个愚蠢的图像。
PS 图像来自外部,我对错误的元数据无能为力......
OK, I agree this is a strange question, but bear with me.
I have a TIFF
image and I am using Windows
. When I right-click and go to Properties
, I see Width = 1728 pixels
and Height
= 1146 pixels
. When I read it with Java
as a BufferedImage
and call getWidth()
and getHeight()
, I see the same things. When I open it with MS Paint
, I see the same size.
But the problem is that this size is not correct because the height is too small and the image looks idiotic. Now the interesting part: when I open it with IrfanView
, I see it OK, with Height = 2292 pixels
. When I open it with Windows Photo Viewer
, it looks OK with Height = 2292 pixels
.
So my question is: How did IrfanView
and Windows Photo Viewer
manage to recognize the correct height, although it was specified wrong in the metadata of the image? And how to do the same in Java? I don't want to show an idiotic image to the user.
P.S The image comes from outside and I can't do anything about the wrong metadata...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我解决了这个问题。事实上,这个形象从一开始就不合适。
IrfanView
显示 OK 的原因是它比较了Horizontal
和Vertical
DPI
,如果不正确equal,它会调整图像大小以使它们相等。例如:
当 IrfanView 打开图像时,它会产生以下结果:
Height = Height * (HorizontalDPI / VerticalDPI) = 600 * 2 = 1200
。我最终在我的软件中做了同样的事情。一切正常:)
我希望这篇文章对其他人有用:)
I resolved the problem. In fact the image was inappropriate from the beginning. The reason why
IrfanView
shows it OK, is that it compares theHorizontal
andVertical
DPI
and if they are not equal, it resizes the image to make them equal.For example:
When IrfanView opens the image it makes the following:
Height = Height * (HorizontalDPI / VerticalDPI) = 600 * 2 = 1200
.I ended up doing the same in my software. Everything is working fine:)
I hope this post will be useful to other people:)