Re: xpm colormap... (long)

Anthony Thyssen (
Tue, 22 Oct 1996 11:43:47 +1000 (EST)

| I have a bunch of color xpm files, which are the faces of people who
| I'm in contact with. (The xpm files contain a big number of colours).
| When xfaces is showing the xpm files, the program steals all the
| colors in the color-map, causing other applications to fail in
| allocating colours.
| Now,
| - Is there a way to tell xfaces to install/not-install it's own colormap?
| (in the same way netscape does with the -install/-no-install flag?)
| - How can I reduce the number of colours in xpm files?. (Any X-Windows
| program that does this?, I was using 'xv', but it seems to produce a
| corrupted xpm file if I save it with a reduced color set.)

I am not sure of the first but the second I can definately help with.

I am the coordinator for Anthony's X Windows Icon library (started 1991)
and had a simular problem with colors for icons. If you just use them
as contributed, each used a a set of colors and every icon used a
different set.

Anthony's X Windows Icon Library (AIcons)

My solution was to pick a set of 30 colors and recolor all the icons to
this set.

For the color picking process what was wanted etc. see..
For the final color selections
or in a X pixmap file

Now for your solution.

The core program I used to recolor icons (X pixmaps) was the PbmPlus
filter ``ppmquant'' This can take a `ppm' file of colors and
either dither images into this map (your need) or replace the colors
(my need). It can also just reduce the colors used, but the colors
picked may not be the same across all images in that case (unless all
images are concatanated in to image to give to the program). As such
I recommend creating a ppm colormap.

`ppmquant' is part of the pbmplus (netpbm) filter package

The Colormap I use is available at
or in X pixmap format (not directly usable by `ppmquant'

ASIDE: A colormap is just a ppm image with the colors wanted in it.
Often just one pixel for each color wanted to make it minimal.

The `ppmquant' can only be run on one image, also I wanted to recolor
whole directories of X Pixmap images, so I wrote quite a number of
scripts to convert the X Pixmaps to ppmplus, recolor them, convert them
back AND fix the color names which ppmplus filters delete.

All these scripts can be found in the AIcons support script area
or download this support files from

The specific script to recolor icons is called (suprise) `recolor'

EG: recolor *.xpm
or recolor -fs *.xpm # dithered recolor
or recolor -fs -f colormap.ppm *.xpm # with this colormap

This will recolor all X Pixmaps in the corrent directory renaming them
or is the number of colors was reduced

WARNING: recolor depends on other scripts in the support scripts
directory a couple of which also depend of perl being installed
(to create and use a pixel->colorname database for the ppm image
to X pixmap conversion)


I will make only one more suggestion...

When I start my X windows session I want to ensure that programs like
netscape do not grab the 30 `standard' colors I use. As such I
want to assign those colors before netscape and others are run.

To do this I have a line like the following in my .xsession or .xinitrc
X windows startup file.

=======8<--------CUT HERE----------axes/crowbars permitted---------------

# ----- Get Server information ---------
eval `xrdb -symbols | sed -n '/=/{s/-D\([^= ]*\)=*/\1=/gp;}'`
HOST=`hostname` # correct this xrdb setting


if [ $PLANES != 1 ]; then # color display
# Load standard colortable to insure these color are present.
sxpm -geometry 6x5-40-40 $HOME/icons/local/colormap.xpm &
sleep 1 # pause a moment

=======8<--------CUT HERE----------axes/crowbars permitted---------------

The -geometry places the image underneth my xclock which is started later
in the sequence.

I also recomend ctwm for seting the icons various programs use.

I think that is enough for now. Use the above as you see fit and I hope
all this helps.

I will be placing a copy of this in my ``Tower of Computation Sorcery''
X windows floor, which is part of my ``Web Castle''.

X Windows Hints and Tip Floor
Tower of Computation Sorcery
Anthony's Home is his Castle

Anthony Thyssen ( System Programmer )
We are designated, Pentium 90 of the Borg....
Division is futile! You will be approximated!
PGP Public Key available -- finger -l