Discourse greyscale jpg avatar processing adds darkness?


(Jakob Borg) #1

I just noticed my Gravatar looks quite crappy here, but looks fine when the same image is uploaded directly. Compare the three young Alan’s in this screenshot:

To the left we have how it looks at Gravatar, in the middle how it looks on my Discourse install where I’ve manually uploaded the same image file, and to the right how it looks at meta after fetching from gravatar (a lot darker).

At a guess, the JPEG has embedded gamma info that gets stripped?


Uploading Grayscale images causes the image to be darkened
Avatars not always showing up after refresh
Uploading transparent overlay .png comes out incorrect
Profile image appears darker on mobile
(Jakob Borg) #5

So, the thing turned out to be not gamma (which was standard) but that my avatar was a grayscale JPEG.

jb@jborg-mbp:~/.Trash $ identify -verbose turing.jpg | grep Colorspace
  Colorspace: Gray

Adding a small amount of sepia and re-saving to get Colorspace: sRGB makes the avatar look as expected. Still though, not sure why the difference between fetch-from-gravatar and direct upload?

Anyway, grayscale JPEG avatars are probably rare enough that this is not an issue in practice.


(Sam Saffron) #6

We use image magick if you have a better set of settings you think we should use we would consider them.


(Jakob Borg) #7

I looked at the scaling in OptimizedImage but that’s all good, I can’t reproduce a “bad” thumbnail with that convert command on my computer. Maybe blame Gravatar? :confused:


(Eric Vantillard) #8

An other point is that my gravatar image is much more darker on discourse than the original one.
Any idea why ?

maybe related to optimized_image ?

my gravatar url http://www.gravatar.com/avatar/2cd1993c3c7de7adcdcdbbe0d223e643.png?size=32


(Eric Vantillard) #9

Same here I tried the imagemagick command by hand and it does not reproduce the problem.

 convert http://www.gravatar.com/avatar/2cd1993c3c7de7adcdcdbbe0d223e643.png?size=32 \
  -background transparent \
  -gravity center \
  -thumbnail 32x32^ \
  -extent 32x32 \
  -interpolate bicubic \
  -unsharp 2x0.5+0.7+0 \
  -quality 98 \
  gravatar_transformed.jpeg

image result is


(Eric Vantillard) #11

The imagemagick convert command options are fine (result of the command on ubuntu:14.04 )


(Eric Vantillard) #12

not seems to be an imagemagick problem. Any other manipulations of the image ?


(Sam Saffron) #13

Try running it inside the container, it may be a version specific issue.

./launcher ssh app

(Eric Vantillard) #14

result from my docker discourse instance

seems good to me.


(Eric Vantillard) #15

how to force recomputing the cached avatars inside discourse ?


(Vanjacosic) #16

I too would like to know if there’s a way to do this. I noticed that my avatars (from gravatar) are much darker.
At first I just thought I was imagining it - but I can confirm that I’m seeing the same results as @evantill is.


(Jakob Borg) #17

Note that you all have greyscale avatars, and only those are affected. While the problem is annoying and mysterious, adding just a little of any kind of color to the avatar should be a workaround.


(Eric Vantillard) #18

ok but we have the problem only on discourse. It’s the mysterious part that is worrying me.


(Sam Saffron) #19

I think I fixed this at last:

https://github.com/discourse/discourse/commit/f680374820f8775d939e2a3b2ba033b6dee75cba

Was caused due to the auto orientation code.

Note: the fix is not retroactive will only apply to new images


(Jeff Atwood) #20

http://www.imagemagick.org/script/color-management.php

Color management has changed significantly between ImageMagick version 6.7.5-5 and 6.8.0-3 in order to better conform to color and grayscale standards.

Hmm.

root@forum:/# convert --version
Version: ImageMagick 6.7.7-10 2014-03-06 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2012 ImageMagick Studio LLC
Features: OpenMP

@sam we really need to update ImageMagick here…


(Sam Saffron) #21

I am looking for a package ubuntu is at fault here, they have an old version.

In particular see:

https://launchpad.net/ubuntu/+source/imagemagick

utopic is on 6.7.7 even vivid vervet is only on 6.8

there is monster of dependencies so even installing from source can be tedious amd64 build of imagemagick 8:6.7.7.10+dfsg-4ubuntu1 : Devirtualised PPA : Colin Watson


(Sam Saffron) #22

I just tested on 6.9 and the same fix is still needed there. So it appears image magick upgradaytion does not resolve the issue.


Uploading image makes it black (not darker!)
(Jeff Atwood) #23

I do not think it is fixed, I think this jacks gamma on all avatars. Check out system on a brand new Discourse install:

Verified on try.discourse – I reverted for now. We need a fix that affects only greyscale images.


#24

As noted in this (now closed) topic, this affects all uploaded grayscale images, not just avatars.