8 my $USAGE = "typical usage:\timage-size.pl *.png <input.xml >output.xml\n";
9 die $USAGE if $#ARGV < 0;
11 my %image_widths = ( );
12 my %image_heights = ( );
14 while( my $file = shift @ARGV ) {
15 my( $volume, $directory, $filename ) = File::Spec->splitpath( $file );
16 ( $image_widths{ $filename }, $image_heights{ $filename } ) =
20 while( my $line = <> ) {
21 if( $line =~ m{<instance.*src="([^"]+)"} ) {
23 if( exists $image_widths{$image} && defined $image_widths{$image} ) {
25 if( $line =~ m{width="[^"]*"} ) {
26 $line =~ s/width="[^"]*"/width="$image_widths{$image}"/;
29 $line =~ s/(src="[^"]*")/$1 width="$image_widths{$image}"/;
32 if( $line =~ m{height="[^"]*"} ) {
33 $line =~ s/height="[^"]*"/height="$image_heights{$image}"/;
36 $line =~ s/(src="[^"]*")/$1 height="$image_heights{$image}"/;