123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157 |
- BEGIN { $| = 1; print "1..8\n"; $Image::ExifTool::noConfig = 1; }
- END {print "not ok 1\n" unless $loaded;}
- use Image::ExifTool 'ImageInfo';
- use Image::ExifTool::IPTC;
- $loaded = 1;
- print "ok 1\n";
- use t::TestLib;
- my $testname = 'IPTC';
- my $testnum = 1;
- {
- ++$testnum;
- my $exifTool = new Image::ExifTool;
- my $info = $exifTool->ImageInfo('t/images/IPTC.jpg', {Duplicates => 1});
- print 'not ' unless check($exifTool, $info, $testname, $testnum);
- print "ok $testnum\n";
- }
- {
- ++$testnum;
- my $exifTool = new Image::ExifTool;
- $exifTool->ExtractInfo('t/images/IPTC.jpg', {JoinLists => 0});
- my @values = $exifTool->GetValue('Keywords','ValueConv');
- my $values = join '-', @values;
- my $expected = 'ExifTool-Test-IPTC';
- unless ($values eq $expected) {
- warn "\n Test $testnum differs with \"$values\"\n";
- print 'not ';
- }
- print "ok $testnum\n";
- }
- {
- ++$testnum;
- my $exifTool = new Image::ExifTool;
- $exifTool->Options(Duplicates => 1, Binary => 1, List => 1);
- my $info = $exifTool->ImageInfo('t/images/IPTC.jpg');
- my $tag;
- foreach $tag (keys %$info) {
- my $group = $exifTool->GetGroup($tag);
- my $val = $$info{$tag};
- if (ref $val eq 'ARRAY') {
- push @$val, 'v2';
- } elsif (ref $val eq 'SCALAR') {
- $val = 'v2';
- } elsif ($val =~ /^\d+(\.\d*)?$/) {
-
-
- $val += ($val / 10) + 1.001;
- $1 or $val = int($val);
- } else {
- $val .= '-v2';
- }
-
- my @x = $exifTool->SetNewValue($tag, $val, Group=>$group, Replace=>1);
- }
-
- $exifTool->SetNewValue(CreatorCountry => 'Canada');
- $exifTool->SetNewValue(CodedCharacterSet => 'UTF8', Protected => 1);
- undef $info;
- my $image;
- my $ok = writeInfo($exifTool,'t/images/IPTC.jpg',\$image);
-
-
- my $exifTool2 = new Image::ExifTool;
- $exifTool2->Options(Duplicates => 1);
- $info = $exifTool2->ImageInfo(\$image);
- my $testfile = "t/${testname}_${testnum}_failed.jpg";
- if (check($exifTool2, $info, $testname, $testnum) and $ok) {
- unlink $testfile;
- } else {
-
- open(TESTFILE,">$testfile");
- binmode(TESTFILE);
- print TESTFILE $image;
- close(TESTFILE);
- print 'not ';
- }
- print "ok $testnum\n";
- }
- {
- ++$testnum;
- my @writeInfo = (
-
-
-
-
-
- ['IPTC:CopyrightNotice' => "\xc2\xa9 2008 Phil Harvey"],
- );
- print 'not ' unless writeCheck(\@writeInfo, $testname, $testnum, 't/images/Writer.jpg', 1);
- print "ok $testnum\n";
- }
- {
- ++$testnum;
- my $exifTool = new Image::ExifTool;
- my $testfile = "t/${testname}_${testnum}_failed.jpg";
- unlink $testfile;
- $exifTool->Options(Charset => 'Cyrillic');
- $exifTool->SetNewValuesFromFile('t/images/MIE.mie', 'Comment-ru_RU>Caption-Abstract');
- $exifTool->Options(IPTCCharset => 'Cyrillic');
- my $ok = writeInfo($exifTool,'t/images/Writer.jpg',$testfile);
- $exifTool->Options(Charset => 'UTF8');
- my $info = $exifTool->ImageInfo($testfile, 'IPTC:*');
- if (check($exifTool, $info, $testname, $testnum) and $ok) {
- unlink $testfile;
- } else {
- print 'not ';
- }
- print "ok $testnum\n";
- }
- {
- ++$testnum;
- my @writeInfo = (
- ['IPTC:Keywords' => 'Test', DelValue => 1],
- ['IPTC:Keywords' => 'One'],
- ['IPTC:Keywords' => 'Two'],
- );
- print 'not ' unless writeCheck(\@writeInfo, $testname, $testnum, 't/images/IPTC.jpg', 1);
- print "ok $testnum\n";
- }
- {
- ++$testnum;
- my $exifTool = new Image::ExifTool;
- my $testfile = "t/${testname}_${testnum}_failed.jpg";
- unlink $testfile;
- $exifTool->SetNewValuesFromFile('t/images/IPTC.jpg', 'IPTC');
- my $ok = writeInfo($exifTool,'t/images/Writer.jpg',$testfile);
- my $info = $exifTool->ImageInfo($testfile, 'IPTC:*');
- if (check($exifTool, $info, $testname, $testnum) and $ok) {
- unlink $testfile;
- } else {
- print 'not ';
- }
- print "ok $testnum\n";
- }
|