Click here to Skip to main content
15,867,568 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Python
create_png(x, y, cipher_pixel).save('D:\Dropbox\Code\image\cipher.png', 'PNG')

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.
Posted
Updated 1-Dec-14 0:02am
v2
Comments
Sergey Alexandrovich Kryukov 1-Dec-14 13:56pm    
It's not clear. Is the content of the image identical to the original one after decompression. I mean, on the pixel-by-pixel basis. Your approach should be this: encryption has nothing to do with image compression and image content. You encrypt and decrypt arrays of bytes, description should give you original data.
—SA

1 solution

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.
 
Share this answer
 
Comments
newbiejo 1-Dec-14 11:20am    
thanks for the reply. i'm sorry for the unclear question and yes, my question is about the file size. Are there any possible ways to save that "additional information" for later use, which i can use it when i try to built a .png image file again so the file size will be equal?
Anthony Mushrow 1-Dec-14 14:35pm    
I can't say for sure that this is what you're experiencing. But really, why does the file size matter that much to you? if you can view your saved image and it looks fine, then where is your issue?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900