[Wolves] easy peasy question imagemagick

Aquarius wolves at mailman.lug.org.uk
Tue Dec 10 15:49:01 2002


steve crozier spoo'd forth: 
> I've got a question thats bugging me because i know its really not hard , but 
> i can't find the right command. All i want to do is to batch convert a load 
> of .pnm files (and maybe resize them) into .jpg 
> 
> I've been using 'convert *.pnm *.jpg ' but all i get from that is a load of 
> files called *.jpg.1' and so  on. So , what should the correct command be? 

convert won't convert multiple images into multiple images,  afaik  (you 
can  convert  multiple  images  into  *one*  image,  say  an  animation, 
though). So do:

for f in *.pnm; do convert $f `basename $f pnm`.jpg; done

(the basename bit makes the command that goes to imagemagick  look  like 
"convert foo.pnm foo.jpg", rather than  "convert  foo.pnm  foo.pnm.jpg". 
This is completely untested, so caveat codor ;)

Aq.

-- 
If God didn't want us to eat meat, then he wouldn't have invented the
hamburger, would he? Logic.
           -- Bevier, afe