my ($width,$height)=unpack "nn", /\xFF\xC0...(....)/ ? $1 : ''; # or "\0" x 4, maybe?