Uploading image makes it black (not darker!)

I saw the bug in which the gravatars turn dark and this does not seem to be the same.
I want to upload an asset image to the asset thread. So as it says I click on reply then on upload
and I select the file I want to upload. When it’s uploaded it looks totally pitch black.

Imgur

In the above example, the first image with gray patterns is how it looks when I link it from the web and the black box under it is how it looks when I upload it from my machine.

if you want the file to try it, it’s here http://www.ledonneindustries.com/wp-content/uploads/2014/11/footer_lodyas.png

Thanks!

5 Likes

Looks like ImageMagick strikes again — except that I can’t reproduce this locally.

Uploading StefanD’s file on meta and try results in a solid black image; uploading it to my local Discourse does not. Since I’m not using the Docker setup, is the ImageMagick version in the docker base image outdated?

Mine is:

Version: ImageMagick 6.9.0-3 Q16 x86_64 2015-01-17 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2015 ImageMagick Studio LLC
Features: DPC Modules OpenMP
Delegates (built-in): bzlib freetype jng jpeg ltdl png tiff zlib
2 Likes

Yeah, I can’t reproduce it locally either…

Version: ImageMagick 6.8.9-8 Q16 x86_64 2014-10-23 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2014 ImageMagick Studio LLC
Features: DPC Modules
Delegates: bzlib freetype jng jpeg ltdl lzma png xml zlib

And inside the docker image…

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

Time to update :exclamation:

2 Likes

Seems like a dup of Uploading Grayscale images causes the image to be darkened. The reason that the image is going black when uploaded is that the source image is so dark to begin with. Testing to be sure:

And with a single de-grayed pixel (top-left pixel changed from RGB(53,53,53) to RGB(54,53,53)):

Edit: Make sure to check the full size images. The thumbnails are reduced in size enough that the color shift doesn’t have an effect on the darkening of the image.

4 Likes

I thought updating ImageMagick did not fix the darkening problem? @sam tested it and said, it did not:

https://meta.discourse.org/t/discourse-greyscale-jpg-avatar-processing-adds-darkness/17993/22?u=codinghorror

Maybe it’s depending on a bad version of libpng?

1 Like

This is a super annoying bug so if we can figure it out, that’d be good.

FWIW, my ImageMagick dynamically links against libpng16 and I have libpng 1.6.16 installed. That version was released in late December 2014. And… the best available version in Ubuntu Trusty is 1.2.50!? :confounded:

2 Likes

I can confirm that in Ubuntu 14.04 LTS

apt-get install imagemagick

produces

root@discourse:/var/discourse# 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

and on the same machine

apt-get install libpng-dev

… how do you tell the version, since this is just a library, not a command, right?

root@discourse:/usr/lib# find . -name *libpng*
./x86_64-linux-gnu/libpng12.so.0
./x86_64-linux-gnu/libpng.so
./x86_64-linux-gnu/libpng12.so
./x86_64-linux-gnu/libpng12.a
./x86_64-linux-gnu/pkgconfig/libpng12.pc
./x86_64-linux-gnu/pkgconfig/libpng.pc
./x86_64-linux-gnu/libpng.a

I guess that’s 1.2?

Looks like you need to pull compile support in @zogstrip and get the latest versions of both libpng and imagemagick in the image, first…

if you can come up with a script that compiles image magick and libpng so it just right I would be happy to add to our image.

2 Likes

Sigh, fine, guess I’ll have to set up a VM for the Docker environment… :challengeaccepted:

2 Likes

Actually, @sam is looking for something to put in the Dockerfile. So you want a series of commands that you can:

  • boot a clean ubuntu image
  • run the commands
  • save that image
  • THEN run the launcher script

So you can use just one level of VM :stuck_out_tongue:

And here we are:

https://gist.github.com/Elberet/f3947aa6e56395d47f17

Edit: yeah, no, I’m not touching the Dockerfile. You guys can integrate that in there. For testing, I’ve hacked the launcher and had it run this script just before pups. :smile:

5 Likes

I did a new image and dark handling seems way better eg:

Same avatar, same user … one is old algorithm and one new.

https://d11a6trkgmumsb.cloudfront.net/user_avatar/meta.discourse.org/caffeine/45/17828.png

https://d11a6trkgmumsb.cloudfront.net/user_avatar/meta.discourse.org/caffeine/46/17828.png

To get latest image and update:

cd /var/discourse
git pull
./launcher rebuild app
./launcher enter app
rake avatars:clean

@zogstrip this raises a big challenge for us we kind of want to update all optimised images everywhere we host and flush cdn.

Thanks heaps @elberet

3 Likes