BEGIN { $| = 1;
print
"1..8\n"
;
$Image::ExifTool::configFile
=
''
; }
END {
print
"not ok 1\n"
unless
$loaded
;}
$loaded
= 1;
print
"ok 1\n"
;
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"
;
}