XPM and read of color "purple"
Posted: 2013-04-08T17:04:06-07:00
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...
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"
So write is good. Just the XPM read of colorname is wrong.
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 */
" "
};
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 */
" "
};