|
|
OverviewGetting Exif information from a Jpeg file.
Flow
A sample code
use Image::ExifTool;
my $img;
open ($img, "< file.jpg");
my $exifinfo = Image::ExifTool->new->ImageInfo($img);
close($img);
foreach (sort keys %$exifinfo) {
print "$_ -----> $$exifinfo{$_}\n";
}
Description of the codeuse Image::ExifTool; Load Image::ExifTool. my $img; open ($img, "< file.jpg"); Open the jpeg file. Where the file name is file.jpg and file handle is $img. my $exifinfo = Image::ExifTool->new->ImageInfo($img); Create an object from Image::ExifTool. The ImageInfo method takes a file handle and returns a reference of the hash into $exifinfo. The Exif information contains in the hash referred by the reference. In this example, Making the object and executing the ImageInfo method is done in one line. If you want to do it separately, my $e = Image::ExifTool->new; my $exifinfo = $e->ImageInfo($img); you can do as above. close($img); Close the file.
foreach (sort keys %$exifinfo) {
print "$_ -----> $$exifinfo{$_}\n";
}
Display Exif information one by one from the hash. Just to consistent the outout order, this example uses a sort. |