Exif

Image sizes in Perl

If you need for figure out the size of an image, fetch Image::Size from CPAN , it’s just what you need. The module recognizes the most common image-formats such as JPG, GIF, PNG, PSD, TIFF and plenty more. The interface is simple and will get you what you need with no trouble at all.

 #!/usr/bin/perl -w use strict; use Image::Size;

# Just fetch the size 
my ($size_x, $size_y) = Image::Size::imgsize('test.jpg'); 
print "Image is: $size_y x $size_x (height x width)\n";

# HTML-friendly format 
my $size = Image::Size::html_imgsize('test.jpg'); 

exit();

Reading Exif data with PHP

Within most photos from digital cameras besides the actual image, there’s a little ”information block” call EXIF data. If you have the correct PHP extension installed on your server – the one called ”exif” – it’s pretty easy to read the EXIF data and display them, as you like.

First, let’s check if the extension is available?

$load\_ext = get\_loaded\_extensions();
if (!in\_array(exif, $load\_ext)) {
echo "Exif is NOT available";
} else {
echo "Exif extension is available.";
};