2022-10-08 17:37:59 +08:00
|
|
|
# Before "make install", this script should be runnable with "make test".
|
|
|
|
# After "make install" it should work as "perl t/CanonVRD.t".
|
|
|
|
|
|
|
|
BEGIN {
|
|
|
|
$| = 1; print "1..24\n"; $Image::ExifTool::configFile = '';
|
|
|
|
require './t/TestLib.pm'; t::TestLib->import();
|
|
|
|
}
|
|
|
|
END {print "not ok 1\n" unless $loaded;}
|
|
|
|
|
|
|
|
# test 1: Load the module(s)
|
|
|
|
use Image::ExifTool 'ImageInfo';
|
|
|
|
use Image::ExifTool::CanonVRD;
|
|
|
|
$loaded = 1;
|
|
|
|
print "ok 1\n";
|
|
|
|
|
|
|
|
my $testname = 'CanonVRD';
|
|
|
|
my $testnum = 1;
|
|
|
|
|
|
|
|
# short list of tags to check in tests
|
|
|
|
my @checkTags = qw(FileSize Warning VRDVersion VRDOffset);
|
|
|
|
my @checkDR4 = qw(FileSize Warning GammaBlackPoint RedHSL GreenHSL SharpnessAdjOn);
|
|
|
|
|
|
|
|
# test 2: Extract information from CanonVRD.vrd
|
|
|
|
{
|
|
|
|
++$testnum;
|
2024-07-09 10:17:06 +08:00
|
|
|
my $exifTool = Image::ExifTool->new;
|
2022-10-08 17:37:59 +08:00
|
|
|
my $info = $exifTool->ImageInfo('t/images/CanonVRD.vrd');
|
2024-07-09 10:17:06 +08:00
|
|
|
notOK() unless check($exifTool, $info, $testname, $testnum);
|
2022-10-08 17:37:59 +08:00
|
|
|
print "ok $testnum\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
# test 3: Test writing some information
|
|
|
|
{
|
|
|
|
++$testnum;
|
2024-07-09 10:17:06 +08:00
|
|
|
my $exifTool = Image::ExifTool->new;
|
2022-10-08 17:37:59 +08:00
|
|
|
$exifTool->SetNewValuesFromFile('t/images/ExifTool.jpg');
|
|
|
|
$exifTool->SetNewValue('xmp:*');
|
|
|
|
my $testfile = "t/${testname}_${testnum}_failed.vrd";
|
|
|
|
unlink $testfile;
|
|
|
|
$exifTool->WriteInfo('t/images/CanonVRD.vrd', $testfile);
|
|
|
|
my $info = $exifTool->ImageInfo($testfile);
|
|
|
|
if (check($exifTool, $info, $testname, $testnum)) {
|
|
|
|
unlink $testfile;
|
|
|
|
} else {
|
2024-07-09 10:17:06 +08:00
|
|
|
notOK();
|
2022-10-08 17:37:59 +08:00
|
|
|
}
|
|
|
|
print "ok $testnum\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
# tests 4-8: Write CanonVRD as a block to various images
|
|
|
|
{
|
2024-07-09 10:17:06 +08:00
|
|
|
my $exifTool = Image::ExifTool->new;
|
2022-10-08 17:37:59 +08:00
|
|
|
$exifTool->SetNewValuesFromFile('t/images/CanonVRD.vrd', 'CanonVRD');
|
|
|
|
$exifTool->Options(PrintConv => 0);
|
|
|
|
my ($file, $ext);
|
|
|
|
foreach $file (qw(Writer.jpg ExifTool.jpg CanonRaw.cr2 CanonRaw.crw CanonVRD.vrd)) {
|
|
|
|
++$testnum;
|
|
|
|
if ($file eq 'CanonVRD.vrd') {
|
|
|
|
$exifTool->SetNewValuesFromFile('t/images/ExifTool.jpg', 'CanonVRD');
|
|
|
|
}
|
|
|
|
($ext = $file) =~ s/^\w+//;
|
|
|
|
my $testfile = "t/${testname}_${testnum}_failed$ext";
|
|
|
|
unlink $testfile;
|
|
|
|
$exifTool->WriteInfo("t/images/$file", $testfile);
|
|
|
|
my $info = $exifTool->ImageInfo($testfile, @checkTags);
|
|
|
|
if (check($exifTool, $info, $testname, $testnum)) {
|
|
|
|
unlink $testfile;
|
|
|
|
} else {
|
2024-07-09 10:17:06 +08:00
|
|
|
notOK();
|
2022-10-08 17:37:59 +08:00
|
|
|
}
|
|
|
|
print "ok $testnum\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# test 9: Delete VRD as a block
|
|
|
|
{
|
|
|
|
++$testnum;
|
2024-07-09 10:17:06 +08:00
|
|
|
my $exifTool = Image::ExifTool->new;
|
2022-10-08 17:37:59 +08:00
|
|
|
$exifTool->SetNewValue(CanonVRD => undef, Protected => 1);
|
|
|
|
my $testfile = "t/${testname}_${testnum}_failed.jpg";
|
|
|
|
unlink $testfile;
|
|
|
|
$exifTool->WriteInfo('t/images/ExifTool.jpg', $testfile);
|
|
|
|
$exifTool->Options(PrintConv => 0);
|
|
|
|
my $info = $exifTool->ImageInfo($testfile, @checkTags);
|
|
|
|
if (check($exifTool, $info, $testname, $testnum)) {
|
|
|
|
unlink $testfile;
|
|
|
|
} else {
|
2024-07-09 10:17:06 +08:00
|
|
|
notOK();
|
2022-10-08 17:37:59 +08:00
|
|
|
}
|
|
|
|
print "ok $testnum\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
# test 10: Create a VRD file from scratch
|
|
|
|
{
|
|
|
|
++$testnum;
|
2024-07-09 10:17:06 +08:00
|
|
|
my $exifTool = Image::ExifTool->new;
|
2022-10-08 17:37:59 +08:00
|
|
|
$exifTool->SetNewValuesFromFile('t/images/ExifTool.jpg', 'CanonVRD');
|
|
|
|
$exifTool->Options(PrintConv => 0);
|
|
|
|
my $testfile = "t/${testname}_${testnum}_failed.vrd";
|
|
|
|
unlink $testfile;
|
|
|
|
$exifTool->WriteInfo(undef, $testfile);
|
|
|
|
my $info = $exifTool->ImageInfo($testfile, @checkTags);
|
|
|
|
if (check($exifTool, $info, $testname, $testnum, 8)) {
|
|
|
|
unlink $testfile;
|
|
|
|
} else {
|
2024-07-09 10:17:06 +08:00
|
|
|
notOK();
|
2022-10-08 17:37:59 +08:00
|
|
|
}
|
|
|
|
print "ok $testnum\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
# test 11-12: Add XMP to a VRD file
|
|
|
|
{
|
2024-07-09 10:17:06 +08:00
|
|
|
my $exifTool = Image::ExifTool->new;
|
2022-10-08 17:37:59 +08:00
|
|
|
$exifTool->SetNewValue('XMP:Title', 'XMP in VRD test');
|
|
|
|
my $srcfile;
|
|
|
|
foreach $srcfile ('t/images/CanonVRD.vrd', undef) {
|
|
|
|
++$testnum;
|
|
|
|
my $testfile = "t/${testname}_${testnum}_failed.vrd";
|
|
|
|
unlink $testfile;
|
|
|
|
$exifTool->WriteInfo($srcfile, $testfile);
|
|
|
|
my $info = $exifTool->ImageInfo($testfile);
|
|
|
|
if (check($exifTool, $info, $testname, $testnum)) {
|
|
|
|
unlink $testfile;
|
|
|
|
} else {
|
2024-07-09 10:17:06 +08:00
|
|
|
notOK();
|
2022-10-08 17:37:59 +08:00
|
|
|
}
|
|
|
|
print "ok $testnum\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# test 13: Extract information from CanonVRD.dr4
|
|
|
|
{
|
|
|
|
++$testnum;
|
2024-07-09 10:17:06 +08:00
|
|
|
my $exifTool = Image::ExifTool->new;
|
2022-10-08 17:37:59 +08:00
|
|
|
my $info = $exifTool->ImageInfo('t/images/CanonVRD.dr4');
|
2024-07-09 10:17:06 +08:00
|
|
|
notOK() unless check($exifTool, $info, $testname, $testnum);
|
2022-10-08 17:37:59 +08:00
|
|
|
print "ok $testnum\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
# test 14: Test writing to DR4
|
|
|
|
{
|
|
|
|
++$testnum;
|
2024-07-09 10:17:06 +08:00
|
|
|
my $exifTool = Image::ExifTool->new;
|
2022-10-08 17:37:59 +08:00
|
|
|
$exifTool->Options(PrintConv => 0);
|
|
|
|
$exifTool->SetNewValue(CropX => 123);
|
|
|
|
$exifTool->SetNewValue(SharpnessAdjOn => 0);
|
|
|
|
$exifTool->SetNewValue(RedHSL => '-4.3 1.2 3.8');
|
|
|
|
$exifTool->SetNewValue('CanonVRD:GammaBlackPoint' => '1.234');
|
|
|
|
my $testfile = "t/${testname}_${testnum}_failed.dr4";
|
|
|
|
unlink $testfile;
|
|
|
|
$exifTool->WriteInfo('t/images/CanonVRD.dr4', $testfile);
|
|
|
|
my $info = $exifTool->ImageInfo($testfile, '-filename');
|
2024-07-09 10:17:06 +08:00
|
|
|
notOK() unless check($exifTool, $info, $testname, $testnum);
|
2022-10-08 17:37:59 +08:00
|
|
|
print "ok $testnum\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
# tests 15-21: Write CanonDR4 as a block to various images
|
|
|
|
{
|
2024-07-09 10:17:06 +08:00
|
|
|
my $exifTool = Image::ExifTool->new;
|
2022-10-08 17:37:59 +08:00
|
|
|
my $srcfile = "t/${testname}_14_failed.dr4";
|
|
|
|
$exifTool->SetNewValuesFromFile($srcfile, 'CanonDR4');
|
|
|
|
$exifTool->Options(PrintConv => 0);
|
|
|
|
my ($file, $ext);
|
|
|
|
foreach $file (qw(Writer.jpg ExifTool.jpg CanonRaw.cr2 CanonRaw.crw CanonVRD.vrd CanonVRD.dr4 CanonRaw.cr3)) {
|
|
|
|
++$testnum;
|
|
|
|
($ext = $file) =~ s/^\w+//;
|
|
|
|
my $testfile = "t/${testname}_${testnum}_failed$ext";
|
|
|
|
unlink $testfile;
|
|
|
|
$exifTool->WriteInfo("t/images/$file", $testfile);
|
|
|
|
my $info = $exifTool->ImageInfo($testfile, @checkDR4);
|
|
|
|
if (check($exifTool, $info, $testname, $testnum)) {
|
|
|
|
unlink $testfile unless $testnum == 15 or $testnum == 17 or $testnum == 21;
|
|
|
|
unlink $srcfile if $testnum == 20;
|
|
|
|
} else {
|
2024-07-09 10:17:06 +08:00
|
|
|
notOK();
|
2022-10-08 17:37:59 +08:00
|
|
|
}
|
|
|
|
print "ok $testnum\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# test 22: Delete DR4(VRD) as a block
|
|
|
|
{
|
|
|
|
++$testnum;
|
2024-07-09 10:17:06 +08:00
|
|
|
my $exifTool = Image::ExifTool->new;
|
2022-10-08 17:37:59 +08:00
|
|
|
my $srcfile = "t/${testname}_15_failed.jpg";
|
|
|
|
$exifTool->SetNewValue(CanonDR4 => undef, Protected => 1);
|
|
|
|
my $testfile = "t/${testname}_${testnum}_failed.jpg";
|
|
|
|
unlink $testfile;
|
|
|
|
$exifTool->WriteInfo($srcfile, $testfile);
|
|
|
|
$exifTool->Options(PrintConv => 0);
|
|
|
|
my $info = $exifTool->ImageInfo($testfile, @checkDR4);
|
|
|
|
if (check($exifTool, $info, $testname, $testnum)) {
|
|
|
|
unlink $testfile;
|
|
|
|
unlink $srcfile;
|
|
|
|
} else {
|
2024-07-09 10:17:06 +08:00
|
|
|
notOK();
|
2022-10-08 17:37:59 +08:00
|
|
|
}
|
|
|
|
print "ok $testnum\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
# test 23: Create a DR4 file from scratch
|
|
|
|
{
|
|
|
|
++$testnum;
|
2024-07-09 10:17:06 +08:00
|
|
|
my $exifTool = Image::ExifTool->new;
|
2022-10-08 17:37:59 +08:00
|
|
|
$exifTool->Options(PrintConv => 0);
|
|
|
|
my $srcfile = "t/${testname}_17_failed.cr2";
|
|
|
|
$exifTool->SetNewValuesFromFile($srcfile, 'CanonDR4');
|
|
|
|
my $testfile = "t/${testname}_${testnum}_failed.dr4";
|
|
|
|
unlink $testfile;
|
|
|
|
$exifTool->WriteInfo(undef, $testfile);
|
|
|
|
my $info = $exifTool->ImageInfo($testfile, '-filename');
|
|
|
|
if (check($exifTool, $info, $testname, $testnum, 14)) {
|
|
|
|
unlink $testfile;
|
|
|
|
unlink $srcfile;
|
|
|
|
} else {
|
2024-07-09 10:17:06 +08:00
|
|
|
notOK();
|
2022-10-08 17:37:59 +08:00
|
|
|
}
|
|
|
|
print "ok $testnum\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
# test 24: Edit DR4 information in CR3 image
|
|
|
|
{
|
|
|
|
++$testnum;
|
2024-07-09 10:17:06 +08:00
|
|
|
my $exifTool = Image::ExifTool->new;
|
2022-10-08 17:37:59 +08:00
|
|
|
my @writeInfo = ( ['CanonVRD:GammaBlackPoint' => 1.5] );
|
|
|
|
my $srcfile = "t/${testname}_21_failed.cr3";
|
2024-07-09 10:17:06 +08:00
|
|
|
notOK() unless writeCheck(\@writeInfo, $testname, $testnum, $srcfile, \@checkDR4);
|
2022-10-08 17:37:59 +08:00
|
|
|
print "ok $testnum\n";
|
|
|
|
unlink $srcfile;
|
|
|
|
}
|
|
|
|
|
2024-07-09 10:17:06 +08:00
|
|
|
done(); # end
|