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