#!/usr/bin/perl -w # RUN THIS ON A MACHINE WITH ImageMagick 6.x.x OR HIGHER # The -distort option is not available in older revs. # # Greg Ercolano 2008 # my $frm = 1; my $filename = defined($ARGV[0]) ? $ARGV[0] : "out"; $ENV{SHELL} = "/bin/sh"; # force use of the bourne shell while ( 1 ) { my $in = sprintf("$filename-%04d.tga", $frm); my $tmp = "tmp.bmp"; my $tmp2 = "tmp2.bmp"; my $out = sprintf("$filename-persp-%04d.bmp", $frm); $frm++; if ( ! -r $in ) { print "--- NO MORE FRAMES\n"; exit(0); } print STDERR "Working on $out\n"; print STDERR " 1) Crop out a strip\n"; my $crop = "convert $in -crop 50x400+440+0 $tmp"; print STDERR " Executing: $crop\n"; if ( system($crop) != 0 ) { print STDERR "--- CROP FAILED\n"; exit(1); } print STDERR " 2) Perspective conversion..\n"; my $persp = "convert $tmp ". "-distort Perspective ". " '0,95 0,312 50,400 50,0 ". # input trapezoid " 0,0 0,400 50,400 50,0' ". # output image # " '0,115 0,285 50,400 50,0 ". # input trapezoid # " 0,0 0,400 50,400 50,0' ". # output image "$tmp2"; print STDERR " Executing: $persp\n"; if ( system($persp) != 0 ) { print STDERR "--- PERSPECTIVE FAILED\n"; exit(1); } print STDERR " 3) scale compress\n"; my $scale = "convert $tmp2 -scale 50%x100%\! $out"; print STDERR " Executing: $scale\n"; if ( system($scale) != 0 ) { print STDERR "--- SCALE FAILED\n"; exit(1); } # if ( $count++ > 10 ) { exit(0); } }