Welcome to WebmasterWorld Guest from 34.229.24.100

Forum Moderators: coopster & jatar k & phranque

Message Too Old, No Replies

Help understanding code

I'm trying to learn, but there is a curve...

     
1:23 am on Feb 6, 2004 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:June 16, 2003
posts:899
votes: 0


I hate asking for help with code, especially when it's probably very simple but I'm new to perl and it's not simple to me.

What I'm trying to do is pull the iptc data from an image using imagemagick.

I can read the image, display the image, etc. but for some reason I just can't find any info on how to read and display the iptc to the screen.

Here is something I found through several searches and modified to do what I thought would work:

#!/usr/bin/perl
#
use strict;
use warnings;
use Image::Magick;

# ---------------------------------------------------------

chdir('f:/cgi-bin') die("Can't chdir(f:/cgi-bin): $!");

my($input_file_name)= '0032.jpg';
my($image)= Image::Magick -> new();
my($result)= $image -> Read($input_file_name);
die $result if $result;

print "Reading: $input_file_name. \n\n";

my $profile = 'iptc';

print "Trying to write profile: $profile \n\n";

$result = $image -> Write("$profile:$input_file_name:-");

if ($result)
{
print "Error: $result. \n";
}
else
{
print "Wrote: $profile:0032.jpg \n";
}

What I get is:

Trying to write profile: iptc

Wrote: iptc:0032.jpg

Is there some setting that I'm missing? It seems like the data should fall between the two output lines. I know the data is there because I put it there with PhotoShop. Any ideas?

* I just noticed that the line "Reading: $input_file_name. \n\n" isn't printing. Could this be a clue?

2:57 pm on Feb 7, 2004 (gmt 0)

Preferred Member

10+ Year Member

joined:Dec 19, 2000
posts:366
votes: 0


a guess..
Try putting this line above the first print line:

print "Content-type: text/html\n\n";

if that doesn't work,
what happens if you change

print "Reading: $input_file_name. \n\n";
to
print "Reading: $input_file_name. \n";

I think your first line is read as an header, which ends with \n\n

3:59 am on Feb 9, 2004 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:June 16, 2003
posts:899
votes: 0


I was getting an incomplete headder warning before I added the second \n

I didn't realise that would affect that line. I'll try the print line, I'll get back to you on what happens.

Thanks for your help!