#!/usr/pkg/bin/perl &imgsize(@ARGV); sub imgsize { my($file, $type, $pointer, $chunk, $size); foreach $file (@_) { open(IFF, $file) or die "cannot open: $!\n"; binmode(IFF); # necessary on Windows! $pointer = 0; # location of first size word while ($pointer < -s $file) { seek(IFF, $pointer, 0) or die "cannot seek: $!\n"; read(IFF, $chunk, 36) or die "cannot read: $!\n"; ($size, $type, $data) = unpack('nA2H*', $chunk); printf("0x%04x %2s %-64s\n", $size, $type, substr($data, 0, min($size - 4, 64))); $pointer += $size; } } } sub numerically { $a <=> $b; } sub min { return (sort numerically @_)[0]; }