Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does gravatar adjust the colour in your images automatically?

I decided I wanted to change my gravatar to be circular. I have it circular on my blog with css and prefer the effect so decided to use a bit of imagemagick to give my image a circular alpha channel (so I could have it on SO, e.t.c. as well). a couple of quick commands later I was sorted:

# crop to square 422x422 with 0x0 offset
convert mike_gravatar.jpeg -crop 422x422+0+0 mike_gravatar_square.jpeg
# give circular alpha channel around it NOTE this is for a 422x422 image (note the 211x211)
convert mike_gravatar_square.jpeg \( +clone -threshold -1 -negate -fill white -draw "circle 211,211,211,0" \) -alpha off -compose copy_opacity -composite mike_gravatar_circle.png

brilliant, now we just upload this to gravatar, I will have a nice circular cropped image and all will be well with the world.


as you have probably guessed from the question all is not well:

darkened gravatar image

ok, I must have clearly messed up my imagemagick and not checked that the before and after image are the same, reopen the images next to one another, and see that they are indeed the same. I try uploading again to gravatar and notice that they seem to process the images after the "cropping" stage, here is what it looks like in the browser after the file upload (before the cropping messes it up):

working gravatar picture

Alright, lets do some digging, someone else must have stumbled upon this before, so I have a look around and one lone soul in a desolate forum wasteland cries out. Now there is no response to this, but the relevant text is here:

It seems that if a photo or picture uploaded to Gravatar's cropper doesn't have jet black, it will auto-level the nearest grey to black and darken the whole image, including darkening whites into greys. Can confirm that this occurs with any PNG image that has a grey background or has a large enough proportion of it, whether or not it has 255 whites and regardless if it has alpha-blending or not

So it seems like I can fix this by putting in a single black pixel, that sounds alright so I try adding a black pixel, then a single black and a single white pixel, result:

goddammit gravatar

So basically now I'm out of ideas:

  • does anyone have any idea what post-processing gravatar does, so I can undo it or counteract it's effects with pre-processing?
  • is this "feature" documented anywhere, or can it be turned off, or gotten around?

I think it would be quite cool to preprocess the image to counteract the darkening they would do to it but that would require knowing exactly what they do in order to change things and obviously might not be possible (depends on the relative movement of each colour, I suppose)

EDIT:

I tried making an inverse image to see if it was basing the processing on the average or the extreme values and that was also darkened, it seems that it's more likely to be the average:

darkened inverse circle

like image 499
Mike H-R Avatar asked Jun 09 '14 23:06

Mike H-R


People also ask

How long does it take for Gravatar to update?

Recent changes to your Gravatar will take on average up to 24 hours to update on all sites that use the Gravatar system.

What is a Gravatar image?

“Your Gravatar is an image that follows you from site to site appearing beside your name when you do things like comment or post on a blog. Avatars help identify your posts on blogs and web forums, so why not on any site?”

How do I change my Gravatar image in WordPress?

If you wish to change the default avatar, in the WordPress admin dashboard, head to Settings > Discussion. Scroll down to the Default Avatar section and you'll see a few additional options are provided for selection.

What size is Gravatar image?

Size. You may request images anywhere from 1px up to 2048px, however note that many users have lower resolution images, so requesting larger sizes may result in pixelation/low-quality images.


1 Answers

Alright, I've got a solution that "worked for me" unfortunately it is just empirical and "good enough" (I'd quite like to check what's actually happening but unfortunately don't have any more time to devote to being nerd sniped) I'm gonna post what I did, what I think might have happened and how I think this should be solved if someone has enough time.

First off what I did, I simply tried whitening the image by random amounts, what ended up working was a gamma around 2

convert mike_gravatar_circle.png -gamma 2 mike_gravatar_circle_light_2.png

here is what the picture looks like both before and after processing by gravatar:

gravatar pic before processinggravatar pic after processing

I feel it's pretty ridiculous that I need to clobber my picture like I do on the left to make it look normal so I'm going to leave this question open to see if anyone can show me a better/cleaner way of doing this.

EDIT: forgot to mention my (completely unfounded) guesses as to how this should be solved. So my guess is that gravatar might try and make the average color of the image some type of midrange value (as that might seem sensible... I guess, I don't know) and picks up the alpha as being all white. trying some experiments to determine could be interesting, but only if they had an api to automate uploading and downloading the images or it would be painful effort, I'm looking forward to any suggestions as to what people think is happening.

like image 53
Mike H-R Avatar answered Jan 03 '23 12:01

Mike H-R