# Uploading image makes it black (not darker!)

**URL:** https://meta.discourse.org/t/uploading-image-makes-it-black-not-darker/27115
**Category:** Bug
**Created:** [April 2, 2015, 1:49pm UTC](https://meta.discourse.org/t/uploading-image-makes-it-black-not-darker/27115 "2015-04-02T13:49:30Z")
**Posts on this page:** 15
**Page:** 1

<div class="post-metadata">

### Author: ![StefanD](https://avatars.discourse-cdn.com/v4/letter/s/f4b2a3/32.png) [@StefanD](https://meta.discourse.org/u/StefanD)
#### Post date: [April 2, 2015, 1:49pm UTC](https://meta.discourse.org/t/uploading-image-makes-it-black-not-darker/27115/1 "2015-04-02T13:49:30Z")

</div>

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](https://global.discourse-cdn.com/meta/original/4X/e/f/f/effe51493d85c6c4fbf9488a1a679b8ed7bf17ab.png "imgur.com") ](https://imgur.com/4wX4qIS)

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](http://www.ledonneindustries.com/wp-content/uploads/2014/11/footer_lodyas.png)

Thanks!

---

<div class="post-metadata">

### Author: ![elberet](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/elberet/32/122404_2.png) [@elberet](https://meta.discourse.org/u/elberet)
#### Post date: [April 2, 2015, 2:38pm UTC](https://meta.discourse.org/t/uploading-image-makes-it-black-not-darker/27115/2 "2015-04-02T14:38:13Z")

</div>

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

```

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [April 2, 2015, 2:39pm UTC](https://meta.discourse.org/t/uploading-image-makes-it-black-not-darker/27115/3 "2015-04-02T14:39:28Z")

</div>

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 ❗

---

<div class="post-metadata">

### Author: ![anon25879736](https://avatars.discourse-cdn.com/v4/letter/a/e95f7d/32.png) [@anon25879736](https://meta.discourse.org/u/anon25879736)
#### Post date: [April 2, 2015, 3:49pm UTC](https://meta.discourse.org/t/uploading-image-makes-it-black-not-darker/27115/4 "2015-04-02T15:49:18Z")

</div>

Seems like a dup of [Uploading Grayscale images causes the image to be darkened](https://meta.discourse.org/t/uploading-grayscale-images-causes-the-image-to-be-darkened/24616). 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:

 ![](https://global.discourse-cdn.com/meta/original/3X/6/2/621df6061bb265361c3873522ea305c6b5ccaeaf.png) 

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

 ![](https://global.discourse-cdn.com/meta/original/3X/a/a/aa254cd9be6171d0e7f4650bbcd1c04e2dec5860.png)

**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.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [April 2, 2015, 10:39pm UTC](https://meta.discourse.org/t/uploading-image-makes-it-black-not-darker/27115/5 "2015-04-02T22:39:47Z")

</div>

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](https://meta.discourse.org/t/discourse-greyscale-jpg-avatar-processing-adds-darkness/17993/22)

---

<div class="post-metadata">

### Author: ![elberet](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/elberet/32/122404_2.png) [@elberet](https://meta.discourse.org/u/elberet)
#### Post date: [April 2, 2015, 10:55pm UTC](https://meta.discourse.org/t/uploading-image-makes-it-black-not-darker/27115/6 "2015-04-02T22:55:37Z")

</div>

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

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [April 2, 2015, 10:56pm UTC](https://meta.discourse.org/t/uploading-image-makes-it-black-not-darker/27115/7 "2015-04-02T22:56:53Z")

</div>

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

---

<div class="post-metadata">

### Author: ![elberet](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/elberet/32/122404_2.png) [@elberet](https://meta.discourse.org/u/elberet)
#### Post date: [April 2, 2015, 11:08pm UTC](https://meta.discourse.org/t/uploading-image-makes-it-black-not-darker/27115/8 "2015-04-02T23:08:12Z")

</div>

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!? 😖

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [April 2, 2015, 11:37pm UTC](https://meta.discourse.org/t/uploading-image-makes-it-black-not-darker/27115/9 "2015-04-02T23:37:21Z")

</div>

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..

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [April 3, 2015, 12:04am UTC](https://meta.discourse.org/t/uploading-image-makes-it-black-not-darker/27115/10 "2015-04-03T00:04:16Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![elberet](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/elberet/32/122404_2.png) [@elberet](https://meta.discourse.org/u/elberet)
#### Post date: [April 3, 2015, 1:54pm UTC](https://meta.discourse.org/t/uploading-image-makes-it-black-not-darker/27115/11 "2015-04-03T13:54:41Z")

</div>

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

---

<div class="post-metadata">

### Author: ![riking](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riking/32/170938_2.png) [@riking](https://meta.discourse.org/u/riking)
#### Post date: [April 3, 2015, 4:56pm UTC](https://meta.discourse.org/t/uploading-image-makes-it-black-not-darker/27115/12 "2015-04-03T16:56:14Z")

</div>

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 😛

---

<div class="post-metadata">

### Author: ![elberet](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/elberet/32/122404_2.png) [@elberet](https://meta.discourse.org/u/elberet)
#### Post date: [April 3, 2015, 4:57pm UTC](https://meta.discourse.org/t/uploading-image-makes-it-black-not-darker/27115/13 "2015-04-03T16:57:51Z")

</div>

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. 😄

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [April 3, 2015, 11:51pm UTC](https://meta.discourse.org/t/uploading-image-makes-it-black-not-darker/27115/14 "2015-04-03T23:51:54Z")

</div>

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

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

[https://global.discourse-cdn.com/meta/user\_avatar/meta.discourse.org/caffeine/45/17828.png](https://global.discourse-cdn.com/meta/user_avatar/meta.discourse.org/caffeine/45/17828.png)

[https://global.discourse-cdn.com/meta/user\_avatar/meta.discourse.org/caffeine/46/17828.png](https://global.discourse-cdn.com/meta/user_avatar/meta.discourse.org/caffeine/46/17828.png)

To get latest image and update:

```plaintext
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

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [April 4, 2015, 2:00am UTC](https://meta.discourse.org/t/uploading-image-makes-it-black-not-darker/27115/15 "2015-04-04T02:00:17Z")

</div>


