Very small PNGs are inappropriately converted to JPGs

It appears that transparent logos are no longer possible…this has broken our logo on our site.

This is a transparent background with white text – uploaded one to imgur so I could show what it is supposed to be. It seems to be getting converted to JPEG

actual logo vs Uploaded below – note it’s a white-background so just right-click and save to see the bug:

Is there any way to preserve transparent backgrounds and not make them white – which makes the text…and everything go away…

1 Like

The Imgur file is a PNG, the upload is a jpg, jpegs don’t support transparency.

Are you saying Discourse converted your PNG logo into JPG?

Was this a logo uploaded to the ‘Assets for the Site Design’ thread, or using the new site logo interface?

4 Likes

The new site logo interface-- How would I force it to use the Assets for the Site Design thread one?

Have we reproduced this @tgxworld?

If I upload a PNG, I’d like it to remain a PNG personally…and @codinghorror – I did actually reproduce it – see my original post :slight_smile: – it is convertng to JPEG all images apparently

1 Like

This usually implies the file is not optimized, and therefore far larger than it should be. Have you tried running the PNG through a lossless optimizer first?

Isn’t it the option png to jpg quality that automatically compress png files?

You should try by putting 100 in this setting

I just grabbed it from the Assets for Site Design thread and uploaded it. I could do that and try again… could we just optimize the PNGs and not convert to JPEG so that we could preserve transparency?

I’m on vacation so it’s hard for me to test things at this time, but I strongly suspect that if you ran the PNG through a lossless optimizer (google for it, if you need to), you’ll get a much smaller image that won’t be converted due to size. I could be wrong, but this is my best technical guess based on what I know at this moment.

Thiis is not time-sensitive and can wait until after the holidays :slight_smile:

Could a solution be to optimize the PNG server-side rather than convert to JPEG be an option?

Anyone reading this has all the information necessary to test the hypothesis.

1 Like

We will get this sorted, very likely due to image optimization. I am very surprised that our optimisation is stripping transparent pixels.

It’s filesize based, for the most part. If the image is wildly smaller as a jpg then that’s what we choose. Only a perversely egregious PNG would cause this to happen.

Edit: that does NOT appear to be the case (13kb PNG), so if this is happening, it is a different bug @sam

1 Like
$ du -sh transparent_logo.png 
28K	transparent_logo.png

Weird, it is 13kb from imgur so I suspect it’s not optimized.

Either way both 13kb and 26kb are plenty small, so my hypothesis was not correct.

@robbyoconnor yeah something is not right … this PNG is tiny … 12.2k

JPEG converting this should not happen… yet… it happens.

1 Like

I think it’s because the jpg is only 5kb, so that’s viewed as a significant filesize savings (by percentage perhaps). We should disable this optimization step when the total size is under, say, 100kb?

3 Likes

On it… yeah I would say it has to have a threshold of absolute savings in bytes as well… minimum saving of say 100k.

3 Likes
$ optipng transparent_logo.png -o7
** Processing: transparent_logo.png
2400x600 pixels, 8 bits/pixel, 17 colors (16 transparent) in palette
Input IDAT size = 12340 bytes
Input file size = 12715 bytes

Trying:
  zc = 9  zm = 8  zs = 3  f = 5		IDAT size = 12340

transparent_logo.png is already optimized.

3 Likes

I completely missed the fact that it was converted to JPEG somehow