Fixed  Avatar Transparency

Regardless of the provided settings, GD doesn't produce the most optimized png images.

No I guess the user of ImageMagik would be needed for the most optimized but ImageMagik is more server heavy and is needed to be installed extra, GD comes as standard with PHP these days...
 
GIF to me is like IE6, dead.

This may be true, but only because they don't resize well - so rather than displaying as they were intended to be displayed, they're squashed into jaggy lines or expanded into fuzzy ones. Personally I have always loved the crispness of GIFs vs. the mushiness of JPGs. And it's an art format after all - personal preference ought to count for something, since art is subjective. :/
 
It's more than just transparency... Forcing all images to JPEG means you lose not only the ability to have transparency, but you also don't have the ability to have lossless images (that would be the biggest thing for me) and you can't have animated images (not that I would EVER want them, but I'm sure some might).
 
It's more than just transparency... Forcing all images to JPEG means you lose not only the ability to have transparency, but you also don't have the ability to have lossless images (that would be the biggest thing for me) and you can't have animated images (not that I would EVER want them, but I'm sure some might).
I agree completely... Why .png isn't supported is beyond me. I would say that for most intent and purposes, .png is better than .jpg. I know it's not better for every situation, but on the Web, I find that .png tends to work out better.
 
I agree completely... Why .png isn't supported is beyond me. I would say that for most intent and purposes, .png is better than .jpg. I know it's not better for every situation, but on the Web, I find that .png tends to work out better.
I agree this should be fixed, but I just wanted to point out the jpgs are almost always superior for photographic data; smaller filesize for the same—as detectable by the human eye—image quality.
 
I agree completely... Why .png isn't supported is beyond me. I would say that for most intent and purposes, .png is better than .jpg. I know it's not better for every situation, but on the Web, I find that .png tends to work out better.
I guess it wasn't this thread I posted it in, but the difference in file size between JPG and PNG (for images produced by GD) was astronomical. 5k vs 45k sort of thing. I'll play with it again to see if I can get better results.
 
I guess it wasn't this thread I posted it in, but the difference in file size between JPG and PNG (for images produced by GD) was astronomical. 5k vs 45k sort of thing. I'll play with it again to see if I can get better results.
quality (compression) / filters within imagepng doesn't help at all?

Edit:

bool imagepng ( resource $image [, string $filename [, int $quality [, int $filters ]]] )

quality = 0-9

filter can be:

Code:
PNG_NO_FILTER        - Disable all filters
PNG_FILTER_NONE        - the scanline is transmitted unmodified; it is only necessary to insert a filter type byte before the data.
PNG_FILTER_SUB        - transmits the difference between each byte and the value of the corresponding byte of the prior pixel.
PNG_FILTER_UP        - just like the Sub filter except that the pixel immediately above the current pixel, rather than just to its left, is used as the predictor.
PNG_FILTER_AVG        - uses the average of the two neighbouring pixels (left and above) to predict the value of a pixel.
PNG_FILTER_PAETH    - computes a simple linear function of the three neighbouring pixels (left, above, upper left), then chooses as predictor the neighboring pixel closest to the computed value.
PNG_ALL_FILTERS        - Enables all filters.
 
I guess it wasn't this thread I posted it in, but the difference in file size between JPG and PNG (for images produced by GD) was astronomical. 5k vs 45k sort of thing. I'll play with it again to see if I can get better results.
It depends on the context of the image for sure, but a 5k vs. 45k size makes me think something is wrong regardless of the image.

I just did a couple tests on file sizes...

The image I'm using as my avatar here:

JPEG (quality = 100): 4.8k
JPEG (quality = 60): 2.2k
PNG (24-bit): 11.1k
PNG (8-bit): 5.4k
GIF: 6k

Line art/drawings tend to be better suited for PNG (and what you would probably use some transparency for anyway).

If I used a 75x75 version of my company logo (with transparency where supported) the size is as follows:

JPEG (quality = 100): 3.6k
JPEG (quality = 60): 1.9k
PNG (24-bit): 1.3k
PNG (8-bit): 0.8k
GIF: 0.8k

So depending on the context of the image, some formats are more efficient than others, but some image that comes out being 9x larger as PNG vs. JPEG seems odd to me.
 
It depends on the context of the image for sure, but a 5k vs. 45k size makes me think something is wrong regardless of the image.

I just did a couple tests on file sizes...

The image I'm using as my avatar here:

JPEG (quality = 100): 4.8k
JPEG (quality = 60): 2.2k
PNG (24-bit): 11.1k
PNG (8-bit): 5.4k
GIF: 6k

Line art/drawings tend to be better suited for PNG (and what you would probably use some transparency for anyway).

If I used a 75x75 version of my company logo (with transparency where supported) the size is as follows:

JPEG (quality = 100): 3.6k
JPEG (quality = 60): 1.9k
PNG (24-bit): 1.3k
PNG (8-bit): 0.8k
GIF: 0.8k

So depending on the context of the image, some formats are more efficient than others, but some image that comes out being 9x larger as PNG vs. JPEG seems odd to me.
Did you handle these through GD? In general my experience matches yours: (using good software) PNG tends to be slightly larger, if not a similar size, as JPEG. But I think Mike was saying that GD handles PNG's poorly and outputs extremely large filesizes relative to JPEG's. In other words, it's GD's fault. :)

This is why I suggested trying the various compression levels and filters GD offers through imagepng(). :)
 
To me this would be a giant plus to add...
but as a temporary workaround can someone upload a 200x200 image within a certain filesize and not have it converted or is it a requirement of XF's system that the avatar images be JPEG.

Maybe an option in the avatar upload box that lets you pick between ... upload and resize or upload a PNG @ 200x200 of less than a specified filesize and not have it touched by GD? Is this even possible?
 
AAAAhhhh that would explain why my avy has a black line underneath it!!! It is a transparent png.

I would love to see transparency supported across the board :)
 
It will now use a white background instead of black, which would also mimic how the image would appear when viewed as an attachment on its own. Thus, I'm tagging this issue as fixed (since I don't see another viable option).

Using a GD bundled with PHP (2.0.34 compatible), with the attached image, resized to the large avatar size (192px wide):

JPEG, quality 75: ~11k
PNG, "quality" 0 (this is actually compression, 0 is none): ~220k!
PNG, "quality" 9, PNG_FILTER_NONE: ~154k
PNG, "quality" 9, PNG_ALL_FILTERS: ~105k
GIF (not really going to look great): ~31k

I'm sure these numbers wouldn't be as drastic with non-photo content, but on balance it likely isn't worth it. For the medium sized avatar (the one used on posts), the difference can be between 4k and 21k.

I really like PNG and would much prefer to use it. ImageMagick probably handles it better and I would re-investigate when that's an option.
 

Attachments

  • IMG_1541.webp
    IMG_1541.webp
    61.9 KB · Views: 26
Seems like a reasonable compromise to me.

Looks like you could do with a shave though Mike ;)

Edit: Just got a server error message pop up even though the post was successful.

error.webp
 
Top Bottom