简体   繁体   English

与原始图像文件相比,ImageIO write会生成不同的文件大小

[英]ImageIO write produces a different file size as compared to the original image file

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. 当使用ImageIO读取图像文件,然后将BufferedImage (不对BufferedImage对象进行任何操作)写入另一个文件时,与原始文件相比,写入文件的文件大小不同。

Does ImageIO reads the full contents (including any metadata, like Exif metadata) of the image file? ImageIO是否读取图像文件的完整内容(包括任何元数据,如Exif元数据)?

And if it does read the full contents, then does ImageIO writes out the image contents including any metadata? 如果它确实读取了全部内容,那么ImageIO会写出包含任何元数据的图像内容吗?

Many file formats (including for instance jpeg) can be correctly compressed in several different ways (even for the same quality settings). 许多文件格式(包括例如jpeg)可以通过几种不同的方式正确压缩(即使是相同的质量设置)。 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. 事实上,没有独特的正确方法来压缩图像,这意味着在加载/保存文件后,您不能指望ImageIO产生与字节等效的结果。

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

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