#!/usr/bin/perl -w # rotate EPS-File anti-clockwise about 90 degrees # (c) 2008 Axel Junge a.junge@tu-bs.de # (c) 2008 Gurvan Le Guernic gleguern@gmail.com # # 2008-10-17: initial version v0.1 $infilename = $ARGV[0]; $outfilename = $ARGV[1]; if ( $#ARGV == 1) { open ( INFILE, "$infilename") or die "Can't open $infilename !"; open ( OUTFILE, ">$outfilename") or die "Can't open $outfilename !"; } else { print "rotateEps.pl: Perl script to rotate EPS files 90 degrees anti-clockwise\n"; print "v0.1 by G. Le Guernic\n"; print "Syntax: rotateEps.pl \n"; print "Requirement: The input file must have a correct values of bounding box. The perl\n"; print " script \"fixbb\" is a good choice to ensure correct bounding box values.\n"; exit; } $rotated = "false"; while ($line = ) { # search BBox if ( $line =~ /^%%BoundingBox: (\d+) (\d+) (\d+) (\d+)/ ) { # save xmin and xmax to set center of rotation later $newLx = 0 - $4; $newLy = $1; $newUx = 0 - $2; $newUy = $3; # write bouding box after rotation print OUTFILE "%%BoundingBox: $newLx $newLy $newUx $newUy\n"; } else { print OUTFILE $line; } # search start of PostScript code if ( $rotated eq "false" && $line =~ /^[^%]/ ) { # rotate 90 degrees anti-clockwise print OUTFILE "90 rotate\n"; $rotated = "true"; } } close INFILE; close OUTFILE;