Fetching Image details in Perl

Image::Size is fine, if size is the only thing, which matters. Sometimes, however, it isn’t enough, and when that is the case Image::Info (again fetched from CPAN) is your friend. Point it to a file (through various methods), and it will return a hash with all the information available about the image you pointed at. Most popular formats are supported.

1
2
3
4
5
6
7
8
9
10
11
#!/usr/bin/perl -w
use strict;
use Image::Info;
 
# Just fetch the size
my $imgInfo = Image::Info::image_info("test.jpg");
 
# Print out all info fetched from the image
for (keys %$imgInfo) { print " $_ -> $imgInfo->{$_}n"; }
 
exit();