XPM image files with color names fails

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

XPM image files with color names fails

Post by anthony »

The XPM coder is miss-handling the realing of XPM images contains actual color names rather than hex values.


For example using a "colortable" image..
http://www.imagemagick.org/Usage/images/colortable.gif
Image
This was converted a long time ago (correctly using NetPBMPlus)

While here is the source XPM image (and a IM converted GIF version)
http://www.cit.griffith.edu.au/~anthony ... rtable.xpm
Image

As you can see in the IM converted XPM the colors "Green" and "Purple" come out wrong.

XPM images are ONLY supposed to use X11 color definitions, but IM is using its complete color database for color name conversion which uses SVG definition for "Green" and "Purple", and as such getting the resulting final image wrong. here is its internal color database definition for these two colors.

Code: Select all

  convert -list color | grep -i '^green '
green rgb(0,128,0) SVG
green rgb(0,255,0) X11 XPM

Code: Select all

  convert -list color | grep -i '^purple '
purple rgb(128,0,128) SVG
purple rgb(160,32,240) X11 XPM


XPM coder MUST only use X11 colors for colornames when parsing the XPM image file format.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: XPM image files with color names fails

Post by anthony »

Bump... Still not fixed.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: XPM image files with color names fails

Post by magick »

We can reproduce the problem you posted and have a patch in ImageMagick 6.6.3-2 Beta available by sometime tomorrow. Thanks.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: XPM image files with color names fails

Post by anthony »

I now get a Corrupt image Error for the XPM image!!!

display: unrecognized color `DarkSlateGrey' @ warning/color.c/GetColorCompliance/946.
display: corrupt image `icons/local/colortable.xpm' @ error/xpm.c/ReadXPMImage/393.


I have no idea why it does not know what DarkSlateGrey is.

The X11 rgb.txt color table lists it as
47 79 79 DarkSlateGrey

And IM lists is as being a X11 color (as well as a SVG color)
DarkSlateGrey rgb(47,79,79) SVG X11
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: XPM image files with color names fails

Post by magick »

XPM supports a subset of the X11 colors. For example, your colortable.xpm includes the Khaki4 color which is not an XPM compliant color. However, we can't find the original format specification that lists the color names supported by XPM so we now permit any colorname when reading an XPM.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: XPM image files with color names fails

Post by fmw42 »

However, we can't find the original format specification that lists the color names
I don't know if this will help or is the original list of color names. But see

ftp://ftp.x.org/contrib/libraries/xpm-README.html
http://www.fileformat.info/format/xpm/egff.htm
http://en.wikipedia.org/wiki/X_PixMap
http://www.bolthole.com/java/Xpm.java
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: XPM image files with color names fails

Post by anthony »

The X11 color list has no changed in more than 10 years. It is normally extracted from Xlib functions, whcih in turn reads them from a file installed with the X server.

They are listed in the file named "rgb.txt" somewhere on any X window system.
originally it was located at /usr/lib/X11/rgb.txt
however the newer Xorg Xwindow servers moved it to /usr/share/X11/rgb.txt

NetPBM also installs a copy in /usr/share/netpbm/rgb.txt

IM never had problems with either DarkSlateGrey or Khaki4

And I am not adding the complication of having spaces in color names in the XPM color table.

Example XPM color table entry....
" s None c None",
". c dark slate grey",
"X c lemon chiffon",
"o c black",
teh first characters are the 'index' for the pixel data. after that single letters are 'keys' followed by the key value
'c' is for color and the color can be multiple words as you can see by the example above.
's' is a symbol name used for program modification of that color.

Also like GIF you can have multiple indexes with the same color, though typically different program 'symbols', however use of symbols is extremely rare, and can be ignored by IM. Multiple indexes in a palette should not be ignored!
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: XPM image files with color names fails

Post by fmw42 »

Post Reply