Why do pasted png get converted to jpg

https://github.com/discourse/discourse/commit/a9c0df0b58c5495c574286084278b00a5d283cd3
Hi,
I wanted to ask about this commit. Why do pasted PNGs get converted to JPG in any case? what breaks without this commit? why is it called FIX?
Thank you very much :smiley:
spirobel

See Screenshots: JPEG vs. GIF (and PNG)

1 Like

I am sorry, but I can not find the answer to my question in your link. My question is not why pngs get converted to jpg, my question is: why do pasted PNGs get converted to JPGs? I dont understand why there is a difference between pasted and non pasted.
Thanks :smiley:

Pasted images typically come across as raw bitmaps, so saving them all as PNG (lossless) would be hugely wasteful in file size. Instead we test saving in both formats and see which results in a “reasonable” size, so (most) images end up efficiently stored as JPGs (lossy).

3 Likes

Thank you for your answer! I think I start to understand this now.

-----------------------------149589358933568048074206291858

Content-Disposition: form-data; name="type"

composer

-----------------------------149589358933568048074206291858

Content-Disposition: form-data; name="files[]"; filename="Screenshot_2020-05-05.png"

Content-Type: image/png

How can I reproduce this? I used the inspector and looked at the request and saw this when pasting a png, when I tried with a jpg it will say image/jpg. What does raw bitmap mean? With which browser does this happen (I use firefox)?

EDIT okay never mind, I think maybe I misunderstood what pasted means. I actually did drag and drop. I tried to copy and paste an image, but it seems like it does not work in general on my system. It just adds this text to the the composer:

x-special/nautilus-clipboard
copy
file:///home/username/Downloads/Screenshot_2020-05-05%20.png
2 Likes