PNG图像文件大小正在减少 [英] PNG image file size is reducing

查看:107
本文介绍了PNG图像文件大小正在减少的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的所有人,

我构建了一个应用程序来加密和解密.png格式的图像文件。我使用Python图像库(PIL)加载图像并获取所有像素值。从加密到解密过程的过程很顺利,原始图像与解密图像相同。

分辨率或尺寸没有任何问题。但是解密图像的尺寸小于原始图像。我错过了保存图像处理的东西吗?

我将图像保存到.png图像的python函数是

Dear All,
I built an apps to encrypt and to decrypt image file with .png format. I use Python Image Library (PIL) to load an image and get all the pixels value. The process is going well from encryption to decryption process which the original image will be identical with the decryption image.
There's nothing wrong with the resolution or the dimensions. But the decryption image has less size than the original image. am i miss something with the saving image process?
My python function for saving image to .png image is

create_png(x, y, cipher_pixel).save('D:\Dropbox\Code\image\cipher.png', 'PNG')



x ,y是尺寸,cipher_pixel是加密的结果。对于解密,我只是将cipher_pixel更改为plain_pixel。

我希望每个人都可以提供帮助。


x, y is the dimensions, cipher_pixel is the result from encryption. For the decryption, i just change the cipher_pixel to plain_pixel.
I hope everybody can help.

推荐答案

PNG文件的内容是压缩,因此生成的文件大小取决于压缩对您拥有的数据的效率。

您还可以使用不同的过滤类型(以帮助压缩),以便您可以根据具体情况设置不同的文件大小哪个应用程序保存了图像。

PNG格式还支持使用图像存储附加信息,例如颜色配置文件或默认背景颜色(用于透明区域)。如果某个应用程序不支持这些块,那么它们可以被忽略并在保存时可能从文件中删除,这也会影响文件大小。



如果你我不是在谈论文件大小,那我恐怕不知道你在谈论什么。
The contents of a PNG file are compressed, so the resulting file size depends on how efficient the compression is for the data you have.
You can also have different filtering types (to help with compression) so you could have different file sizes depending on which application saved the image.
The PNG format also supports storing additional information with an image, such as the colour profile, or a default background colour (for transparent areas). If an application does not support these chunks then they can be ignored and potentially dropped from the file when it is saved, which would also affect the file size.

If you're not talking about the file size, then I'm afraid I've no idea what your talking about.


这篇关于PNG图像文件大小正在减少的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆