Why does copying an image to the clipboard modify the image

0

I noticed when I copy images from a web browser using right click copy they don't turn out the same as when I save them normally.

I did a test. I got an image and opened it in firefox. I then right click copied it and saved it to a file using xclip -selection clipboard -t image/png -o > test.png

But when I ran md5 sums on the images they do not match. Looking at the binary data I can see the first 19 bytes are the same between files. The copied image is over double the size of the original.

What is the reasoning for the image changing after being copied and pasted?

Qwertie

Posted 2016-09-06T12:36:41.117

Reputation: 713

My guess (and it's only a guess, which is why this is a comment and not an answer) is that the clipboard is storing the actual image pixmap, and so xclip is recreating the PNG file. Since PNG has lots of options about how an image is stored, this could easily result in the same image having multiple file representations. – J Earls – 2016-09-06T13:39:38.883

Could it be that the xclip version is actually a bitmap with a .png extension? Try getting an image that has an alpha channel and doing the same test, then opening the newly created file and checking if the Alpha still exists or not. – Kieron Davies – 2016-09-06T12:50:19.987

The alpha is still there – Qwertie – 2016-09-06T12:53:16.350

Perhaps it is the compression ratio that xclip uses.

Maybe it uses the fastest method possible thus resulting in larger files? – Kieron Davies – 2016-09-06T13:38:54.633

Thats a good point. I will see if there is any way to inspect the differences in the pixels and not the binary – Qwertie – 2016-09-07T02:19:30.500

No answers