use Image::Info qw(image_type); my $info = image_type($pic); print $info->{file_type},"\n"; # z.B. JPEG, GIF usw.