Page 1 of 1

XPM and read of color "purple"

Posted: 2013-04-08T17:04:06-07:00
by anthony
This is an old problem but one that bit me again recently in some image file format conversions...

IM normally uses SVG colorname before X11 colornames.
Unfortunately there are a few colornames that are conflicting between the two color systems
See IM Examples, Color Basices, Color Name Conflicts
http://www.imagemagick.org/Usage/color_ ... _conflicts

The problem...

The XPM image file format must use X11 color names for both read and write, and not SVG colornames.

When reading in a XPM image using of the the conflict colors (such as "purple") for example...

Code: Select all

/* XPM */
static char *purple_xpm[] = {
/* width height ncolors chars_per_pixel */
"1 1 1 1",
/* colors */
"a c purple",
/* pixels */
"a"
};

Code: Select all

convert purple.xpm xpm:-

Code: Select all

/* XPM */
static char *xpm__[] = {
/* columns rows colors chars-per-pixel */
"1 1 1 1 ",
"  c #808000008080",
/* pixels */
" "
};
when reading the "purple" color was read as color #800080" whcih is SVG purple. This is not X11 purple, whcih is "#a020f0", As such it read the color WRONG, and the image did not convert properly.


It is however smart enough to know that when writing not to use SVG "purple" so it output #808000008080"
so the write is good.

Quick test for writing a correct X11 "purple"

Code: Select all

convert xc:'#a020f0' xpm:-
/* XPM */
static char *xpm__[] = {
/* columns rows colors chars-per-pixel */
"1 1 1 1 ",
"  c purple",
/* pixels */
" "
};
So write is good. Just the XPM read of colorname is wrong.

Re: XPM and read of color "purple"

Posted: 2013-04-23T23:50:09-07:00
by anthony
Bump.... No feedback...

Reading "purple" in a XPM image returns a SVG purple, not a X11 Purple.
The write of a X11 purple in XPM image is good. Only read goes bad.

Re: XPM and read of color "purple"

Posted: 2013-04-24T00:33:47-07:00
by magick
Check 6.8.5-0 Beta. It reads X11 purple as expected.

Re: XPM and read of color "purple"

Posted: 2013-04-24T23:35:48-07:00
by anthony
Updated IMv6 (working on IMv7 at the moment)

Generate and read/write....

Code: Select all

convert xc:'#a020f0' xpm:- | tee /dev/tty | convert xpm:- xpm:- 

/* XPM */
static char *xpm__[] = {
/* columns rows colors chars-per-pixel */
"1 1 1 1 ",
"  c purple",
/* pixels */
" "
};

/* XPM */
static char *xpm__[] = {
/* columns rows colors chars-per-pixel */
"1 1 1 1 ",
"  c purple",
/* pixels */
" "
};
The first is what was written, (correct)
the second is a read and write, also now correct.

Check on actual pixel value as being a X11 color for XPM...

Code: Select all

convert xc:'#a020f0' xpm:- | convert xpm:- txt:

# ImageMagick pixel enumeration: 1,1,65535,srgb
0,0: (41120, 8224,61680)  #A0A02020F0F0  srgb(160,32,240)
Yeap good..

Fix verified.