#!/usr/bin/perl -w # # Generates large web-sized and thumbnail images from larger source # images for web distribution. It uses ImageMagick (mogrify) to do the # actual conversion. # # Nadim Nakhleh 2/1/01 # # Customize sizes $lSize = 700; $tSize = 160; unless (@ARGV) { die "Usage: webify [ ... ]\n"; } foreach $file (@ARGV) { print "Processing file $file...\n"; if (-f $file) { $file =~ /(.*)\.(.*)/; $fname = $1; $fext = $2; $wfile = "${fname}_l.$fext"; $tfile = "${fname}_t.$fext"; $cmd = "cp \"$file\" \"$wfile\""; (system($cmd) == 0) or die "$0: Can't execute command: $cmd: $!"; print " Mogrifying web image\n"; $cmd = "mogrify -sample \"${lSize}x${lSize}>\" \"$wfile\""; (system($cmd) == 0) or die "$0: Can't execute command: $cmd: $!"; $cmd = "cp \"$wfile\" \"$tfile\""; (system($cmd) == 0) or die "$0: Can't execute command: $cmd: $!"; print " Mogrifying thumbnail image\n"; $cmd = "mogrify -sample \"${tSize}x${tSize}>\" \"$tfile\""; (system($cmd) == 0) or die "$0: Can't execute command: $cmd: $!"; print " done!\n"; } else { print "Can't find file $file...skipping\n"; } }