ExifTool Forum

ExifTool => The Image::ExifTool API => Topic started by: Head for the hills on March 07, 2013, 06:20:21 AM

Title: Getting started on a Linux web hosted site
Post by: Head for the hills on March 07, 2013, 06:20:21 AM
Hi,
Please excuse my noobishness with perl modules etc.
I have a Linux hosted website. Here's what I've done.
FTP'd the uncompressed Image-ExifTool-9.13 folder (and subfolders) to the root of my site.
Created a simple shtml page that contains <!--#include virtual="/cgi-bin/exif.pl"--> in the body.
Created /cgi-bin/exif.pl and chmod 755
#!/usr/bin/perl -w
print "Content-Type: text/html\n\n";
use lib '/Image-ExifTool-9.13/lib';

use Image::ExifTool;
my $exifTool = new Image::ExifTool;

my $info = $exifTool->ImageInfo('exif.JPG');

foreach (keys %$info) {
    print "$_ => $$info{$_}\n";
}

Where have I gone wrong, and please don't just say everywhere. :-[
Any help will be much appreciated.
Title: Re: Getting started on a Linux web hosted site
Post by: Phil Harvey on March 07, 2013, 07:47:28 AM
First, see if you can get the CGI script to work without ExifTool.

Then, try one step at a time.  First just try adding your "use" statement to see if that works.  If it doesn't you have a permission problem or can't access the directory for some reason.

Then if this works, your script should work provided that you format the output in HTML.  Something as simple as this would do:

#!/usr/bin/perl -w
print "Content-Type: text/html\n\n";
use lib '/Image-ExifTool-9.13/lib';

use Image::ExifTool;
my $exifTool = new Image::ExifTool;

$exifTool->Options(Escape => 'HTML');

my $info = $exifTool->ImageInfo('exif.JPG');

print "<html><head></head><body><pre>\n";
foreach (keys %$info) {
    print "$_ =&gt; $$info{$_}\n";
}
print "</pre></body></html>\n";


Edit: Added missing semicolon in code.
Title: Re: Getting started on a Linux web hosted site
Post by: Head for the hills on March 07, 2013, 09:52:15 AM
Many thanks for your prompt reply Phil. I'm sorted now.
Title: Re: Getting started on a Linux web hosted site
Post by: Phil Harvey on March 07, 2013, 10:24:46 AM
It may help others if you explained what your problem was, and post your working cgi script.

- Phil
Title: Re: Getting started on a Linux web hosted site
Post by: Head for the hills on March 12, 2013, 07:00:38 AM
There's not a lot to add really. My problem was nothing to do with exiftool, just a silly path error pointing to the library due to using subdomains.
I tested with the code you posted (just needs a semicolon on the end of one print statement).
Title: Re: Getting started on a Linux web hosted site
Post by: Phil Harvey on March 12, 2013, 07:58:02 AM
Great, thanks.  I added the semicolon.

- Phil