Click here to Skip to main content
14,385,487 members
Rate this:
Please Sign up or sign in to vote.
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
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 1:02am
v2
Comments
   
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

Rate this:
Please Sign up or sign in to vote.

Solution 1

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.
   
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, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100