#!/usr/local/bin/perl # ~/bin/lisa2html.p # # convertor.p runs convert on a load of images. # # usage : # convertor.p to=jpg options="blah blah" file1.gif file2.gif # eg convertor.p newpath=images/ L*tif # FI is the main file # IF is the current image file. $to = "jpg" ; $newpath = "" ; $behead = 0 ; # whether to strip leading path off the original filename $really = 1 ; # How to override with command line eval "\$$1=\$2" while @ARGV && $ARGV[0]=~ /^(\w+)=(.*)/ && shift; $_ = $newpath ; # check to see if newpath ends with "/" #if ( (!($newpath eq "")) && ( !(m#\/$#) ) ) { if ( m#[^/]$#) { print STDERR "WARNING: you specified a path without a trailing / \n This is legal but maybe you meant newpath=$newpath/ \n" ; } foreach $_ (@ARGV) { if (/(.+)\.(\w{3,4})/) { $file = $1 ; $suffix = $2 ; if ($behead) { $file =~ s#.*/## ; # remove everything up to a slash } $command = "convert $options $_ $newpath$file.$to" ; print STDERR $command,"\n" ; system($command) if ($really) ; } else { print STDERR "don't understand $_\n" ; } }