in reply to How do I find the type of an image?

I think it's quite optimistic to classify any file that starts with <?xml as an SVG file, and any file that starts with #define\s as an XBM file. I've many files on my system that match one of the patterns, and are neither SVG or XBM files.

I would use the (external) commands file (standard Unix tool) and/or identify (from the ImageMagick suite) to determine file types.

Replies are listed 'Best First'.
Re: Answer: How do I find the type of an image?
by zentara (Cardinal) on Dec 28, 2009 at 13:18 UTC
    ...try
    #!/usr/bin/perl -w use strict; use Image::Info qw(image_info); use Data::Dumper; while (@ARGV) { print Dumper(image_info(shift)), "\n"; }

    I'm not really a human, but I play one on earth.
    Old Perl Programmer Haiku