develooper Front page | perl.beginners | Postings from February 2012

extracting exif information from images

Thread Next
From:
Harry Putnam
Date:
February 6, 2012 03:59
Subject:
extracting exif information from images
Message ID:
87bopcp3zm.fsf@newsguy.com
I've been looking around, googling for a way to extract exif info from
images. There are many tools out there.  But I wanted to fiddle with
the information in very specific ways.

I hit on the perl module: Image-ExifTool (Phil Harvey) on cpan.

However I am apparently badly misunderstanding the usages shown here:
http://search.cpan.org/~exiftool/Image-ExifTool-8.77/lib/Image/ExifTool.pod

(A few bits:
 
  use Image::ExifTool qw(:Public);

  # ---- Simple procedural usage ----

  # Get hash of meta information tag names/values from an image
  $info = ImageInfo('a.jpg');

  # ---- Object-oriented usage ----

  # Create a new Image::ExifTool object
  $exifTool = new Image::ExifTool;

  # Extract meta information from an image
  $exifTool->ExtractInfo($file, \%options);
-------        ---------       ---=---       ---------      -------- 

But my lame attempts at using this fail miserably:

 (with no attempt at pretty output)
------- 8< snip ---------- 8< snip ---------- 8<snip ------- 
use strict;
use warnings;
use Image::ExifTool qw(:Public);

  # Create a new Image::ExifTool object
  my $exifTool = new Image::ExifTool;
  my $info;
while (<>) {
  chomp;
  # Extract meta information from an image
  # $exifTool->ExtractInfo($file, \%options);

$exifTool->ExtractInfo("$_");
}

print $info;
------- 8< snip ---------- 8< snip ---------- 8<snip ------- 

There is not enough information in that pod page for me to understand
how to really get at the information.  No doubt my lack of skill is
awfully evident here.

Outputs a mess:
 ./myscript t1.jpg
,----
| sh: 1: Syntax error: Unterminated quoted string
| sh: 1: ������:+Y�0y�: not found
| sh: 1: �: not found
| sh: 1: Syntax error: EOF in backquote substitution
| 
| [...]
`----



Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About