Message Board -  Archive

[ Login ] [ Create Account ]
[ Board List ] [ View Board ] [ Post Reply ]
  Author  Subject: Re: changing picture formats

Posted on 06-25-2002 02:14 a.m. ET  reply

Original Poster: Jym Williams Zavada

There is a way to change a whole directory of jpegs to another directory
with all the pictures changed to xpm, and it is easier. However, there are
two requirements. 1) That you have the ImageMagick toolset installed (might
come with Mandrake 8.2, I don't know). And 2) That you have a working
knowledge of bash commands.

If you have the ImageMagick toolset, you can use the convert command to
convert the jpegs to xpms. First, you create the second directory (for this
example, I'll assume it's /tmp/my_xpms). Then, assuming you are in the
directory containing the jpegs, and assuming they all end in .jpg, you'll use
bash's "for" command much the same way as the following example:

for x in *.jpg; do convert $x /tmp/my_xpms/`echo $x | sed 's/.jpg$//'`.xpm;

What the above means is this: for every file ending in .jpg, store the
filename in variable 'x', run the program convert with $x as the first
argument, and the second argument begins "/tmp/my_xpms/", then appends the
output of "echo $x | sed 's/.jpg$//', then appends a .xpm on the end. The
echo $x prints the contents of the variable 'x' to the input of the sed
program, which then removes the .jpg from the filename.

Granted, this could possibly be far more than you bargained for, but hopefully
you'll understand enough to be able to get the job done the easy way. Good

< Previous 1 Next >

Site Contents