Discussion:
How to don't use symbolic color within xpm
Boris Mayer-St-Onge
2010-07-19 14:37:48 UTC
Permalink
Hi,

I want to convert png image to xpm (using convert image.png convert.xpm)
but the file has some symbolic color, e.g:

"1 c gray82",

I have some problem to show the image on Windows computer (ok with
Linux). If I change the symbolic color with the hex value, e.g.:

"1 c #D1D1D1",

then everything is ok. I was wondering if it's possible to use an
argument with convert to use hex value everytime.

Thanks for any help.

Boris
Anthony Thyssen
2010-07-20 02:25:20 UTC
Permalink
On Mon, 19 Jul 2010 10:37:48 -0400
magick-users-***@imagemagick.org wrote:
| Hi,
|
| I want to convert png image to xpm (using convert image.png convert.xpm)
| but the file has some symbolic color, e.g:
|
| "1 c gray82",
|
| I have some problem to show the image on Windows computer (ok with
| Linux). If I change the symbolic color with the hex value, e.g.:
|
| "1 c #D1D1D1",
|
| then everything is ok. I was wondering if it's possible to use an
| argument with convert to use hex value everytime.
|
I had this problem a long time ago.

My solution was a shell script that looks up the colors, and replaces
the hex stringa with X window color names.

The scripts for this is part on my old "Anthony's Icon Library"
http://www.cit.griffith.edu.au/~anthony/icons/

Specifically the script directory in
http://www.cit.griffith.edu.au/~anthony/icons/support/scripts/Icons.html

And the scripts
xpm-fix Fix the X pixmap output from pbmplus (restore color names)
color_db_mk Create a reverse color name database (for xpm-fix)

These are also related.
colorname find the rgb.txt colorname of a pixel #rrggbb value
color_lookup Print the #rrggbb pixel value for a named X window color

The "color_db_mk" creates a small table of hex to color names dealing
with the fact that some hex values has multiple color names in the X11
RGB color table.

The "xpm-fix" uses the table to substitute the hex values with color names.

NOTE this is OLD stuff. I make no guarantees.


Anthony Thyssen ( System Programmer ) <***@griffith.edu.au>
--------------------------------------------------------------------------
And so, may Evil beware and may Good dress warmly
and eat lots of fresh vegetables. -- Tick, "The Tick"
--------------------------------------------------------------------------
Anthony's Castle http://www.cit.griffith.edu.au/~anthony/
Boris Mayer-St-Onge
2010-07-20 19:19:54 UTC
Permalink
Thanks,

I haven't think of using script, that's a good idea, I will take a look
on that (although I would prefer an option with convert in the future).

Boris
Post by Anthony Thyssen
On Mon, 19 Jul 2010 10:37:48 -0400
| Hi,
|
| I want to convert png image to xpm (using convert image.png convert.xpm)
|
| "1 c gray82",
|
| I have some problem to show the image on Windows computer (ok with
|
| "1 c #D1D1D1",
|
| then everything is ok. I was wondering if it's possible to use an
| argument with convert to use hex value everytime.
|
I had this problem a long time ago.
My solution was a shell script that looks up the colors, and replaces
the hex stringa with X window color names.
The scripts for this is part on my old "Anthony's Icon Library"
http://www.cit.griffith.edu.au/~anthony/icons/
Specifically the script directory in
http://www.cit.griffith.edu.au/~anthony/icons/support/scripts/Icons.html
And the scripts
xpm-fix Fix the X pixmap output from pbmplus (restore color names)
color_db_mk Create a reverse color name database (for xpm-fix)
These are also related.
colorname find the rgb.txt colorname of a pixel #rrggbb value
color_lookup Print the #rrggbb pixel value for a named X window color
The "color_db_mk" creates a small table of hex to color names dealing
with the fact that some hex values has multiple color names in the X11
RGB color table.
The "xpm-fix" uses the table to substitute the hex values with color names.
NOTE this is OLD stuff. I make no guarantees.
--------------------------------------------------------------------------
And so, may Evil beware and may Good dress warmly
and eat lots of fresh vegetables. -- Tick, "The Tick"
--------------------------------------------------------------------------
Anthony's Castle http://www.cit.griffith.edu.au/~anthony/
_______________________________________________
Magick-users mailing list
http://studio.imagemagick.org/mailman/listinfo/magick-users
Anthony Thyssen
2010-07-21 02:07:57 UTC
Permalink
IM is open source. and the XPM coder is in a separate module that
can be modified to allow it to use color names rather than hex codes.
It is just a matter of getting someone interested enough to make the
changes. It can even be made an 'option' :-)

However some XPM file readers (not using the xpm library), do not use
colorname or are broken so that it does not understand colornames in
the form of two words. For example, it understands SeaGreen, but
not Sea Green even though the specification allows this.


Hmmm... I may have found a bug. Green in ImageMagick is defined as
being the SVG 'green' specification which is a half bright green
#008000 . BUT XPM is only meant to use X11 color specification, where
Green is defined as a pure RGB green or #00FF00 ('Lime' in SVG
specification).

IM gets this wrong!

For example compare this GIF image of a color table
Loading Image...

With this one IM downloads and converts.
http://www.cit.griffith.edu.au/~anthony/icons/local/colortable.xpm

Compare with...
animate -delay 50 -loop 0 colortable.xpm colortable.gif

Hmmm look like it also gets the color 'Purple' wrong too!

here is the IM's internal definitions of these two colors.

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


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

I'll put in a bug report.


Anthony Thyssen ( System Programmer ) <***@griffith.edu.au>
--------------------------------------------------------------------------
My God! I HAVE POCKETS! -- Tick, "The Tick"
--------------------------------------------------------------------------
Anthony's Castle http://www.cit.griffith.edu.au/~anthony/



On Tue, 20 Jul 2010 15:19:54 -0400
magick-users-***@imagemagick.org wrote:
| Thanks,
|
| I haven't think of using script, that's a good idea, I will take a look
| on that (although I would prefer an option with convert in the future).
|
| Boris
|
| Anthony Thyssen wrote:
| > On Mon, 19 Jul 2010 10:37:48 -0400
| > magick-users-***@imagemagick.org wrote:
| > | Hi,
| > |
| > | I want to convert png image to xpm (using convert image.png convert.xpm)
| > | but the file has some symbolic color, e.g:
| > |
| > | "1 c gray82",
| > |
| > | I have some problem to show the image on Windows computer (ok with
| > | Linux). If I change the symbolic color with the hex value, e.g.:
| > |
| > | "1 c #D1D1D1",
| > |
| > | then everything is ok. I was wondering if it's possible to use an
| > | argument with convert to use hex value everytime.
| > |
| > I had this problem a long time ago.
| >
| > My solution was a shell script that looks up the colors, and replaces
| > the hex stringa with X window color names.
| >
| > The scripts for this is part on my old "Anthony's Icon Library"
| > http://www.cit.griffith.edu.au/~anthony/icons/
| >
| > Specifically the script directory in
| > http://www.cit.griffith.edu.au/~anthony/icons/support/scripts/Icons.html
| >
| > And the scripts
| > xpm-fix Fix the X pixmap output from pbmplus (restore color names)
| > color_db_mk Create a reverse color name database (for xpm-fix)
| >
| > These are also related.
| > colorname find the rgb.txt colorname of a pixel #rrggbb value
| > color_lookup Print the #rrggbb pixel value for a named X window color
| >
| > The "color_db_mk" creates a small table of hex to color names dealing
| > with the fact that some hex values has multiple color names in the X11
| > RGB color table.
| >
| > The "xpm-fix" uses the table to substitute the hex values with color names.
| >
| > NOTE this is OLD stuff. I make no guarantees.
| >
| >
| > Anthony Thyssen ( System Programmer ) <***@griffith.edu.au>
| > --------------------------------------------------------------------------
| > And so, may Evil beware and may Good dress warmly
| > and eat lots of fresh vegetables. -- Tick, "The Tick"
| > --------------------------------------------------------------------------
| > Anthony's Castle http://www.cit.griffith.edu.au/~anthony/
| > _______________________________________________
| > Magick-users mailing list
| > Magick-***@imagemagick.org
| > http://studio.imagemagick.org/mailman/listinfo/magick-users
|
|
| _______________________________________________
| Magick-users mailing list
| Magick-***@imagemagick.org
| http://studio.imagemagick.org/mailman/listinfo/magick-users

Loading...