elsif ( $_[0] =~ m/^^\xFF\xD8.{4}JFIF/s ) { $sig = 'JPEG'; # found JPG signature ($height,$width) = unpack( "nn", $1 ) if $_[0] =~ /\xFF\xC0...(....)/s; to elsif ( $_[0] =~ m/^^\xFF\xD8.{4}JFIF/s ) { $sig = 'JPEG'; ($height,$width) = unpack( "nn", $1 ) if $_[0] =~ /\xFF\xC2...(....)/s; along with the driver for my $img ( qw( ./sample.jpg ./sampleC.jpg ) ) { my $data = get_file($img); my @res = image_size($data); print "\nNative $img $res[2] width $res[0] height $res[1]\n"; ($x, $y) = imgsize($img); print "Image::Size ($x, $y)\n"