Harry Putnam wrote:
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;

That is usually written as:

my $exifTool = Image::ExifTool->new();


   my $info;
while (<>) {
   chomp;
   # Extract meta information from an image
   # $exifTool->ExtractInfo($file, \%options);

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

There is no need to copy the string in $_ to another string:

$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
|
| [...]
`----

The "sh" at the beginning of the error message means that the _shell_ is trying to run your program, not perl, and is reporting the error.

The _first_ line of your program _must_ be:

#!/usr/bin/perl

Where "#!" has to be the first two bytes and "/usr/bin/perl" has to be the path to perl on your system.



John
--
Any intelligent fool can make things bigger and
more complex... It takes a touch of genius -
and a lot of courage to move in the opposite
direction.                   -- Albert Einstein

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to