与原始图像文件相比,ImageIO 写入会产生不同的文件大小
当使用 ImageIO 读取图像文件,然后将 BufferedImage 写入另一个文件(没有对 BufferedImage 对象进行任何操作)时,写入文件的文件大小不同与原始文件相比。
ImageIO 是否读取图像文件的完整内容(包括任何元数据,如 Exif 元数据)?
如果它确实读取了完整内容,那么 ImageIO 是否会写出包括任何元数据的图像内容?
When ImageIO is used to read an image file, then writes the BufferedImage
(without any manipulation of the BufferedImage
objet) to another file, the file size of the written file is different as compared to the original file.
Does ImageIO reads the full contents (including any metadata, like Exif metadata) of the image file?
And if it does read the full contents, then does ImageIO writes out the image contents including any metadata?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
许多文件格式(包括例如 jpeg)可以通过几种不同的方式正确压缩(即使对于相同的质量设置)。解压缩是确定性的,而压缩可能是不确定性的。
事实上,没有唯一正确的图像压缩方法意味着您不能期望 ImageIO 在加载/保存文件后生成字节等效的结果。
Many file formats (including for instance jpeg) can be correctly compressed in several different ways (even for the same quality settings). The decompression is deterministic while the compression may non-deterministic.
The fact that there is no unique right way of compressing an image implies that you can't expect ImageIO to produce a byte-equivalent result after loading / saving a file.