9 my $PROG_NAME = 'fix-image-sizes.pl';
10 my $USAGE = "typical usage:\t${PROG_NAME} *.png <input.xml >output.xml\n";
11 die $USAGE if $#ARGV < 0;
13 my %image_widths = ( );
14 my %image_heights = ( );
16 while( my $file = shift @ARGV ) {
17 my( $volume, $directory, $filename ) = File::Spec->splitpath( $file );
18 ( $image_widths{ $filename }, $image_heights{ $filename } ) =
22 while( my $line = <> ) {
23 if( $line =~ m{<instance.*src="([^"]+)"} ) {
25 if( exists $image_widths{$image} && defined $image_widths{$image} ) {
27 if( $line =~ m{width="[^"]*"} ) {
28 $line =~ s/width="[^"]*"/width="$image_widths{$image}"/;
31 $line =~ s/(src="[^"]*")/$1 width="$image_widths{$image}"/;
34 if( $line =~ m{height="[^"]*"} ) {
35 $line =~ s/height="[^"]*"/height="$image_heights{$image}"/;
38 $line =~ s/(src="[^"]*")/$1 height="$image_heights{$image}"/;