News:

2023-08-10 - ExifTool version 12.65 released

Main Menu

Re: IPTC issues...

Started by Archive, May 12, 2010, 08:53:54 AM

Previous topic - Next topic

Archive

[Originally posted by 00coday on 2006-06-09 15:04:50-07]

No dice.  Still getting unwanted/duplicate fields.  So you have the full benefit of coding stylings, see below:

  $strInsert="";

  $strFields="";

  $strVals="";

  my @ioTagList = qw(ObjectName DateCreated By-line By-lineTitle City Province-State
Country-PrimaryLocationName Headline Credit Source Caption-Abstract Writer-Editor
OriginalTransmissionReference Category);

  my $exifTool = new Image::ExifTool;

  $info = $exifTool-)ImageInfo($imgPath, \@ioTagList, {Group =) 'IPTC'});

  foreach (sort keys %$info) {

     my $val = $$info{$_};

     if (ref $val eq 'ARRAY') {

         $val = join(', ', @$val);

     } elsif (ref $val eq 'SCALAR') {

         $val = '(Binary data)';

     }

     $strFields = $strFields.$_.",";

     $strVals = $strVals."'".$val."',";

     $strInsert = "insert into table (".substr($strFields, 0, length($strFields)-1).") values
(".substr($strVals, 0, length($strVals)-1).")";

  }

  print "\n\n$strInsert\n";

  $exifTool='';

result:

insert into table (ApplicationRecordVersion,By-line,Caption-Abstract,Category,Category
(1),City,City (1),CopyrightNotice,Credit,Credit (1),DateCreated,DateCreated
(1),Headline,Headline (1),Keywords,ObjectName,Source,Source (1),SupplementalCategories
(1),Writer-Editor) values ('2','Spc. Creighton Holub, Combat Avi','The sun sets behind a palm
tree at Forward Operating Base Kalsu on May 7. (U.S. Army photo by Spc. Creighton Holub, Combat
Aviation Brigade PAO, 4th Infantry Division)','WAR','WAR','Taji','Taji','Combat Aviation Brigade
PAO photo by Spc. Creighton Holub','U.S. Army photo by Spc. Creighton Holub, Combat Aviation
Brigade, 4 th Infantry Division','U.S. Army photo by Spc.
Creighto','2006:05:07','2006:05:07','Combat Aviation Brigade operations north of
Baghdad','Combat Aviation Brigade operations north of Baghdad','Taji, deployment, Iraq,
aviation, Army aviation, helicopters, Soldiers, soldiers, 4ID, 4th Infantry Division, Army, U.S.
Army, Operation Iraqi Freedom, OIF, Kalsu, FOB Kalsu','VIRIN 060507-A-8847H-001','Combat
Aviation Brigade Public Affairs Office, 4th Infantry Division','Combat Aviation Brigade Public
A','Iraq, Camp Taji, aviation, Operation Iraqi Freedom, OIF','Spc. Creighton Holub, Combat Avi')

any thoughts?

Archive

[Originally posted by exiftool on 2006-06-09 15:39:02-07]

Ah, that's what you meant by "(some number here)".  The keys to the $info hash are tag keys, not tag names.  The tag keys will contain a number if there is more than one tag extracted with the same name.  To get the tag name, use "$tagName = Image::ExifTool::GetTagName($tagKey)" to return the tag name.  Also, it looks like there is more than one IPTC record in the file you're using.  You can set the Duplicates option value to 0 to avoid extracting duplicate tags: "$exifTool->Options(Duplicates=>0)".

Archive

[Originally posted by 00coday on 2006-06-09 16:40:33-07]

Tried the $exifTool->Options(Duplicates=>0) with no luck and am still getting the ApplicationRecordVersion tag which I don't want or need.

Archive

[Originally posted by exiftool on 2006-06-09 16:51:09-07]

The script:

Code:
#!/usr/bin/perl -w
BEGIN { push @INC, 'lib' }
use Image::ExifTool;

my $imgPath = shift;
$strInsert="";
$strFields="";
$strVals="";

my @ioTagList = qw(ObjectName DateCreated By-line By-lineTitle City Province-State
Country-PrimaryLocationName Headline Credit Source Caption-Abstract Writer-Editor
OriginalTransmissionReference Category);
my $exifTool = new Image::ExifTool;
$info = $exifTool->ImageInfo($imgPath, \@ioTagList, {Group => 'IPTC'});
foreach (sort keys %$info) {
my $val = $$info{$_};
if (ref $val eq 'ARRAY') {
$val = join(', ', @$val);
} elsif (ref $val eq 'SCALAR') {
$val = '(Binary data)';
}
$strFields = $strFields.$_.",";
$strVals = $strVals."'".$val."',";
$strInsert = "insert into table (".substr($strFields, 0, length($strFields)-1).") values
(".substr($strVals, 0, length($strVals)-1).")";
}
print "\n\n$strInsert\n";
$exifTool='';
 
# end

The terminal session:

Code:
> ./ttt t/images/IPTC-XMP.jpg

insert into table (By-line,By-lineTitle,Caption-Abstract,Category (1),City (1),Country-PrimaryLocationName,Credit (1),DateCreated (1),Headline (1),ObjectName,OriginalTransmissionReference,Province-State,Source (1),Writer-Editor) values
('Phil Harvey','My Position','A witty caption','1','Kingston','Canada','My Credit','2004:02:26','No headline','Test IPTC picture','What is a transmission reference','Ont','I'm the source','I wrote it')

No ApplicationRecordVersion tag, even though it does exist.    Does your script work like this when run on t/images/IPTC-XMP.jpg ?