Why are user images served as PNGs?

Why are user images served as PNGs?

David Scotson發表於
Number of replies: 10
I'm fairly sure Moodle user images used to be JPEGs, but now they seem to be PNGs. Does anyone know when and why this change happened?

Here on Moodle.org you can use the 3rd party service Gravatar which provides the user images as JPEGs. As a result some user's images from that service are 10x smaller than others provided by Moodle itself. (It also resizes the image as required, so when displayed at 60x60 it will provide a 60x60 image, not a larger one and then resize it in the browser).

Modern web design trends often emphasis the use of large user images to inspire users to interact with each other. Moodle seems to be anticipating this by introducing a new user icon size of f3 at 512x512px, but since these are PNGs, they are about 500K in size, which I think makes them basically unusable.

I think some users that have been around for a while and not changed their avatar still have JPEGs, in case that confuses anyone looking into this.

But has anyone else investigated this before? I'm thinking a shift back to JPEG would make a lot of sense, and allow us to use visually larger yet faster to download images but wanted to do some more research first to find out why the opposite switch was made in the past.
評比平均分數: -
In reply to David Scotson

Re: Why are user images served as PNGs?

Gareth J Barnard發表於
Core developers的相片 Particularly helpful Moodlers的相片 Plugin developers的相片

Anything in the Git log?

In reply to Gareth J Barnard

Re: Why are user images served as PNGs?

David Scotson發表於
After a bit of spelunking I found this commit message:

MDL-11000 finally switching to png images with jpg fallback, based on code by Luigi Pinca 微笑

Checking out that bug it seems that defaulting to PNG images was done as a side affect of fixing other issues. As Mary mentioned it was due to alpha being handled poorly compared with Mahara.

Since we already have the facility to do both I quite like the idea suggested in the bug of using JPEG if the user uploads a JPEG and PNG if the user uploads a PNG, seems like we'd get the best of all worlds then.

Might look at dropping the default quality from 90 too, though it depends on how good the GD implementation is.

In reply to David Scotson

Re: Why are user images served as PNGs?

David Scotson發表於
Filed a bug: MDL-46763


In reply to David Scotson

Re: Why are user images served as PNGs?

Mary Evans發表於

Your's is the only Avatar that is a PNG file. Everyone elses in the current page are using Gravatars even the grey default ones too are all via Gravetar secure server.

Did you upload yours to Moodle?

In reply to Mary Evans

Re: Why are user images served as PNGs?

David Scotson發表於
Yeah, mine isn't a gravatar, it's uploaded directly into Moodle.

As is Gareth's:

https://moodle.org/user/view.php?id=442195&course=5

Both of our user icon suit being PNG though as they are blocks of flat color.

Stuart's is a "photographic" image and therefore would be best as a JPEG. It too is a PNG though:

https://moodle.org/user/view.php?id=1058627&course=5

The default Gravatar mm image is very similar to the Moodle default one. It seems if you have Gravatar support turned on then Moodle has no way to know if your have an image uploaded or not, so it gets a Gravatar default image instead.

But on Moodle installs without Gravatars turned on, the default f1 image is a png. (Though should probably be switched to an SVG for both crisper lines and smaller file size).
In reply to David Scotson

Re: Why are user images served as PNGs?

Mary Evans發表於

Gareth must have changed his then as it was A graviatar yesterday.

In reply to David Scotson

Re: Why are user images served as PNGs?

Mary Evans發表於

The reason for .png over .jpg is, I suspect, because of the transparency property that .png files possess.

In reply to David Scotson

Re: Why are user images served as PNGs?

Mary Evans發表於

Further to my last comment. All the user pictures in this forum appear to be all .jpg even the ones that are using the Moodle default one.

In reply to Mary Evans

Re: Why are user images served as PNGs?

David Scotson發表於
The default one is definitely a PNG (though it can be replaced in a theme with anything you like e.g. an SVG icon).

How are you checking what file type they are? They don't have file endings which complicates things but FIrefox at least can tell you by right clicking and "view image info".
評比平均分數:Useful (1)