Why file size of difference between two tensor images is bigger than original ones?

I have two tensor activation greyscale images. I converted those image into PIL images. Then I computed difference between those two PIL images using ImageChops. The file size of this difference is supposed to be smaller than two original ones. But in my case, it is showing the reverse. What do you think to be the possible cause for this? Please have an answer.

Depending on the image encoding the diff image might contain more information (entropy) and would thus need more data for the encoding.
A simple example would be a totally blank image which wouldn’t require a lot of information as you would be able to store the color and just repeat it for all pixels, while an image containing random noise would contain much more information and would thus also be larger in file size.
The difference should not be visible, if you don’t use any image encoding/compression but store the raw pixel values.

Hi, thanks for your reply.

You are thus saying that it can happen, right?
Is there any solution to get the difference as relatively small file size?

Yes, it can happen and is quite a good description of the entropy or information of data.
If your diff image “looks” like random noise you won’t be able to reduce the file size significantly without losing data. PIL.Image.save should have some “quality” options, which would downgrade the image while saving but should yield a smaller file size.

Ok, thanks for your explanation.