A bug has been reported where uploading purely grayscale images to Discourse causes them to appear darkened. anon25879736 demonstrated this issue with an example image and found that shifting the R, G, or B value of a single pixel can make the image display correctly. However, this fix is unreliable for avatars, as the shifted pixel can get lost when the image is scaled down.
anon25879736 provided an example of a successful avatar where the entire background was shifted slightly. zogstrip mentioned that Discourse uses ImageMagick and ImageOptim for thumbnail optimization, but is unsure what causes the darkening.
Uploading a purely grayscale image causes the image to be darkened when displayed by discourse. This applies to images in posts, as well as images uploaded as avatars. for example, take this image:
This is much darker that the image is supposed to be. However, if I shift the R,G, or B value of a single pixel, it will display correctly. In this case, I have shifted the top left pixel from (172,172,172) to (173,172,172). This is the only change I have made between the source images.
Now, because of the R value being shifted in one pixel, the image is being displayed accurately.
Unfortunately, this fix is not reliable for avatars. Once the image is scaled down, the shifted pixel gets lost and the smaller image gets darkened again. As a result, you can end up with a grab bag of light and dark avatars. To make it work for avatars, you pretty much need to shift a region of pixels, instead of just a single pixel.
Here’s an example of a user who tried uploading a grayscale avatar with a single altered pixel. Note the version in the usercard is lighter than the resized version next to the post:
Here is an example of an avatar that works successfully. The entire background on this image was shifted slightly using the technique described in the OP.