Create image with #444444 background color problem.

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
novito
Posts: 30
Joined: 2013-11-26T17:37:36-07:00
Authentication code: 6789

Create image with #444444 background color problem.

Post by novito »

Hi,

Why the following code:

Code: Select all

convert -size 100x100 xc:#444444 whatever.png
Would return a white backgrounded image?

I mean, #444444 is not white, it's mostly gray. I fail to see why would that happen.

By the way, I am using:

Version: ImageMagick 6.7.7-10 2013-09-10 Q16 http://www.imagemagick.org
Under Ubuntu 12.04

Thanks
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Create image with #444444 background color problem.

Post by fmw42 »

put double quotes around the hex value

convert -size 100x100 xc:"#444444" whatever.png
novito
Posts: 30
Joined: 2013-11-26T17:37:36-07:00
Authentication code: 6789

Re: Create image with #444444 background color problem.

Post by novito »

Hi,

Thanks for the quick reply (as always :))

That didn't do the trick. I still see a white backgrounded image.
novito
Posts: 30
Joined: 2013-11-26T17:37:36-07:00
Authentication code: 6789

Re: Create image with #444444 background color problem.

Post by novito »

I have been told a guy got it working without the quotes on ImageMagick 6.6.0-4 2011-12-10 Q16

Also, notice that when using jpg format, it works fine.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Create image with #444444 background color problem.

Post by fmw42 »

Quotes are required on Linux/Mac systems to avoid conflict with #. See Example Usage at http://www.imagemagick.org/script/color.php

I suspect that perhaps your libpng may be corrupt or too old. What version are you using? See PNG listing from

convert -list format

Also what delegates do you have installed from

convert -list configure

at the line starting with DELEGATES
novito
Posts: 30
Joined: 2013-11-26T17:37:36-07:00
Authentication code: 6789

Re: Create image with #444444 background color problem.

Post by novito »

Conver --list format (PNG related info) gives me this:

PNG* PNG rw- Portable Network Graphics (libpng 1.2.49)
See http://www.libpng.org/ for details about the PNG format.
PNG24* PNG rw- opaque 24-bit RGB (zlib 1.2.7)
PNG32* PNG rw- opaque or transparent 32-bit RGBA
PNG8* PNG rw- 8-bit indexed with optional binary transparency

convert --list configure (DELEGATES) gives me this:

DELEGATES bzlib djvu fftw fontconfig freetype jbig jpeg jng jp2 lcms2 lqr lzma openexr pango png rsvg tiff x11 xml wmf zlib

Thanks.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Create image with #444444 background color problem.

Post by fmw42 »

What tool are you using to determine that the color is white? Are you displaying the image somewhere or using identify -verbose yourimage?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Create image with #444444 background color problem.

Post by fmw42 »

I can verify that I get the same result as you on that old version of IM. It fails for png (with a more current version of libpng) and works for jpg. Looks like you need to upgrade IM to a more current version.

I am using:

PNG* PNG rw- Portable Network Graphics (libpng 1.5.17)


im67710update convert -size 100x100 xc:"#444444" whatever.png

Code: Select all

identify -verbose whatever.png
Image: whatever.png
  Format: PNG (Portable Network Graphics)
  Mime type: image/png
  Class: PseudoClass
  Geometry: 100x100+0+0
  Resolution: 72x72
  Print size: 1.38889x1.38889
  Units: Undefined
  Type: Bilevel
  Base type: Bilevel
  Endianess: Undefined
  Colorspace: Gray
  Depth: 8/4-bit
  Channel depth:
    gray: 1-bit
  Channel statistics:
    Gray:
      min: 255 (1)
      max: 255 (1)
      mean: 255 (1)
      standard deviation: 0 (0)
      kurtosis: 0
      skewness: 0
  Colors: 1
  Histogram:
     10000: (255,255,255) #FFFFFF gray(255)


im67710update convert -size 100x100 xc:"#444444" whatever.jpg

Code: Select all

identify -verbose whatever.jpg
Image: whatever.jpg
  Format: JPEG (Joint Photographic Experts Group JFIF format)
  Mime type: image/jpeg
  Class: DirectClass
  Geometry: 100x100+0+0
  Resolution: 72x72
  Print size: 1.38889x1.38889
  Units: PixelsPerInch
  Type: Grayscale
  Base type: Grayscale
  Endianess: Undefined
  Colorspace: Gray
  Depth: 8/4-bit
  Channel depth:
    gray: 4-bit
  Channel statistics:
    Gray:
      min: 68 (0.266667)
      max: 68 (0.266667)
      mean: 68 (0.266667)
      standard deviation: 0 (0)
      kurtosis: 0
      skewness: 0
  Colors: 1
  Histogram:
     10000: ( 68, 68, 68) #444444 gray(68)
novito
Posts: 30
Joined: 2013-11-26T17:37:36-07:00
Authentication code: 6789

Re: Create image with #444444 background color problem.

Post by novito »

Interesting...

So you say I would need to update IM? Don't you mean libpng? I am confused as, I am using all this through the Ruby RMagick gem, and I haven't had to install any libpng at all, so am not sure when that got installed (maybe through IM itself?)

Thanks a lot...
Last edited by novito on 2014-01-08T23:02:37-07:00, edited 1 time in total.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Create image with #444444 background color problem.

Post by fmw42 »

No it is not libpng because I was using a much more current version of libpng and it failed.

Here is a workaround -- create as miff and pipe to convert to png

convert -size 100x100 xc:"#444444" miff:- | convert - whatever2.png


or use tiff output if you do not want the jpg compression

convert -size 100x100 xc:"#444444" whatever.tiff
novito
Posts: 30
Joined: 2013-11-26T17:37:36-07:00
Authentication code: 6789

Re: Create image with #444444 background color problem.

Post by novito »

This is weird though. Which version of IM you have that is working? I might want to update to that version.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Create image with #444444 background color problem.

Post by fmw42 »

It works fine for me on IM 6.8.8.1 Q16 Mac OSX. It fails when I use IM 6.7.7.10 Q16 Mac OSX. Both are using the same version of libpng

PNG* PNG rw- Portable Network Graphics (libpng 1.5.17)

It may have been just a bug in that one version. But I cannot say for sure without testing further version.

If you have to upgrade, upgrade to the highest (more current) version of IM just to get all the bug fixes and new features. IM 6.7.7.10 is over 100 versions old.
novito
Posts: 30
Joined: 2013-11-26T17:37:36-07:00
Authentication code: 6789

Re: Create image with #444444 background color problem.

Post by novito »

Hi!

Upgrading to ImageMagick 6.8.8-1 Q16 i686 2014-01-10 http://www.imagemagick.org

did the trick.

Now my problem is that the Ruby library (RMagick), somehow I guess is still using the old version, because I still have the same problem when creating images from it.

Thanks
Post Reply