Subject: Re: looking for an xpmto<foo> converter than understands none

From: Anthony Thyssen <[email-masked]>
Date: Wed, 31 May 1995 10:55:57 +1000

"Paul Harrington" <[email-masked]> writes:-
| When I tried to convert some of the xpms into ppms (so that I can use
| them as Tk-4.0b3 canvas items) I was getting errors about missing or
| invalid formats. I upgraded to the netpbm-1mar1994 release but I am
| still getting errors as it does not recognise the 'none' colour.
| 
The netpbm xpm converter is very very stupid and hates any odd things in
Xpixmaps.  Here is a sed script I filter Xpixmaps through before converting.

file x2p.sed
=======8<--------CUT HERE----------axes/crowbars permitted---------------
#!/bin/sed -f
#
# x2p.sed
# 
# Sed script to fix older versions of xpm so pbmplus understands these also
# to remove any extra comments which may also confuse pbmplus.
# 
# Some sed program do not understand \< \> word boundary constructs so part
# of the file complexity in involved in working around this lack.
# 
# WARNING: the empty [  ] below contain a space and a tab.
#
#  Anthony Thyssen    20 Nov 1994
# -----
# create the appropiate header
  1i\
/* XPM */\
static char *icon[] = {
# extra spaces, comments, and blank lines
  /^static[^A-Za-z0-9]/ d
  s/^[ 	]*"/"/g
  /^[^"]/ s/\/\*.*\*\///g
  /^[ 	]*$/ d
# some funny business with old xpms
  /^!/ d
  /^[^\/"}]/ s/.*/"&",/
# rename the transparent color to white
  s/\([smgc]\)  *[Tt]ransparent\([^A-Za-z0-9]\)/\1 white \2/g
  s/\([smgc]\)  *[Nn]one\([^A-Za-z0-9]\)/\1 white \2/g
  s/#[Tt]ransparent/white/g
  s/#[Nn]one/white/g

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

Then in other script I use a sequence like the following to handle both
pixmaps and bitmaps.

from file "x2p"
=======8<--------CUT HERE----------axes/crowbars permitted---------------
for i in "$@" ; do
  name="`basename $i`"
  suffix="`expr "$name" : '.*\.\([^.]*\)'`"

  j=`basename $i .$suffix`           # destination name
  s=`echo $suffix | sed 's/^x/p/'`   # its new suffix  x -> p

  echo >&2 "file \"$i\""
  case "$suffix" in
    xbm) sed 's/unsigned //' "$i" | xbmtopbm > "$j.$s" ;;
    xpm) x2p.sed "$i" | xpmtoppm 2>/dev/null > "$j.$s" ;;
    *) echo -n "${b}"
       echo >&2 "Unknown suffix for \"$i\""
       continue
  esac
done
=======8<--------CUT HERE----------axes/crowbars permitted---------------

The above is from the scripts in the support section of

   Anthony's Icons
     http://www.cit.gu.edu.au/~anthony/icons/
   Support Files
     http://www.cit.gu.edu.au/~anthony/icons/support/
   Support Scripts
     /antbin/list_icons?dir=support/scripts

Also look at  "xpm-fix" (and "mk-color-db" associated with this)
which is a perl script I use to fix the xpm files created by
netpbm, particularly with regard to re-adding the X color names again.

| what is the easiest/best way for me to convert the xpm's into ppm's? I
| have tried the other approach of using the gifs  ...
| 	giftopnm | pnmdepth 255 |ppmquant 5
| 
| but I am still getting horrible 4x8x4 colourmap which does not look
| nice.
| 
You are asking ppmquant to reduce the number of colors to only 5,
of course it is going to look horrible.

Look at the "recolor" script in the above support directory. I use
this to convert incoming images into the library's standard color
table (about 30 standard X window colors)

Also look at "xbm2gif" to convert bitmaps/pixmaps to GIF format with
or without transparency.

  Anthony Thyssen ( System Programmer )   http://www.cit.gu.edu.au/~anthony/
-------------------------------------------------------------------------------
  "Now I've got the bead on you with MY disintegrating gun.
   And when it disintegrates, it disintegrates. (pulls trigger)
   Well, what you do know, it (the gun) disintegrated."
                 -- Daffy Duck -- Duck Dodgers in the 24th and a half century
-------------------------------------------------------------------------------

---

From: Anthony Thyssen <[email-masked]>
Date: Thu, 1 Jun 1995 11:46:09 +1000

"Paul Harrington" <[email-masked]> writes..
| I have been unable so far to FTP the scripts that Anthony mentions in
| his message ... I guess that an examination of them should answer a
| few of my questions.
| 
| pjjH
| 
FTP is a problem as I do not have an offical ftp site at the moment.
preferally in the US.    ftp.x.org refused :-(

Hang on -- I'll just do an update on the ftp site here..

OK intermediate version  1.7b  is now created (dated 1 July 1996)
This will not be an offical release, just an update for ftp users.

This FTP site is not offical and is not to be released to NEWS or FAQs
This is purely a service to anyone who recieves this mail.
So don't tell anyone  ;-)

    AIcons private FTP (for site archivers)    
       ftp.cit.gu.edu.au   /pub/AIcons

The site is not fast and limited to a small number of ftp users.

  Anthony Thyssen ( System Programmer )   http://www.cit.gu.edu.au/~anthony/
-------------------------------------------------------------------------------
  Wirth's Rule:     Never store data in more than one place,
              sooner or later you will update one and not the other.
-------------------------------------------------------------------------------