CanonVRD.t 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. # Before "make install", this script should be runnable with "make test".
  2. # After "make install" it should work as "perl t/CanonVRD.t".
  3. BEGIN { $| = 1; print "1..22\n"; $Image::ExifTool::noConfig = 1; }
  4. END {print "not ok 1\n" unless $loaded;}
  5. # test 1: Load the module(s)
  6. use Image::ExifTool 'ImageInfo';
  7. use Image::ExifTool::CanonVRD;
  8. $loaded = 1;
  9. print "ok 1\n";
  10. use t::TestLib;
  11. my $testname = 'CanonVRD';
  12. my $testnum = 1;
  13. # short list of tags to check in tests
  14. my @checkTags = qw(FileSize Warning VRDVersion VRDOffset);
  15. my @checkDR4 = qw(FileSize Warning GammaBlackPoint RedHSL GreenHSL SharpnessAdjOn);
  16. # test 2: Extract information from CanonVRD.vrd
  17. {
  18. ++$testnum;
  19. my $exifTool = new Image::ExifTool;
  20. my $info = $exifTool->ImageInfo('t/images/CanonVRD.vrd');
  21. print 'not ' unless check($exifTool, $info, $testname, $testnum);
  22. print "ok $testnum\n";
  23. }
  24. # test 3: Test writing some information
  25. {
  26. ++$testnum;
  27. my $exifTool = new Image::ExifTool;
  28. $exifTool->SetNewValuesFromFile('t/images/ExifTool.jpg');
  29. $exifTool->SetNewValue('xmp:*');
  30. my $testfile = "t/${testname}_${testnum}_failed.vrd";
  31. unlink $testfile;
  32. $exifTool->WriteInfo('t/images/CanonVRD.vrd', $testfile);
  33. my $info = $exifTool->ImageInfo($testfile);
  34. if (check($exifTool, $info, $testname, $testnum)) {
  35. unlink $testfile;
  36. } else {
  37. print 'not ';
  38. }
  39. print "ok $testnum\n";
  40. }
  41. # tests 4-8: Write CanonVRD as a block to various images
  42. {
  43. my $exifTool = new Image::ExifTool;
  44. $exifTool->SetNewValuesFromFile('t/images/CanonVRD.vrd', 'CanonVRD');
  45. $exifTool->Options(PrintConv => 0);
  46. my ($file, $ext);
  47. foreach $file (qw(Writer.jpg ExifTool.jpg CanonRaw.cr2 CanonRaw.crw CanonVRD.vrd)) {
  48. ++$testnum;
  49. if ($file eq 'CanonVRD.vrd') {
  50. $exifTool->SetNewValuesFromFile('t/images/ExifTool.jpg', 'CanonVRD');
  51. }
  52. ($ext = $file) =~ s/^\w+//;
  53. my $testfile = "t/${testname}_${testnum}_failed$ext";
  54. unlink $testfile;
  55. $exifTool->WriteInfo("t/images/$file", $testfile);
  56. my $info = $exifTool->ImageInfo($testfile, @checkTags);
  57. if (check($exifTool, $info, $testname, $testnum)) {
  58. unlink $testfile;
  59. } else {
  60. print 'not ';
  61. }
  62. print "ok $testnum\n";
  63. }
  64. }
  65. # test 9: Delete VRD as a block
  66. {
  67. ++$testnum;
  68. my $exifTool = new Image::ExifTool;
  69. $exifTool->SetNewValue(CanonVRD => undef, Protected => 1);
  70. my $testfile = "t/${testname}_${testnum}_failed.jpg";
  71. unlink $testfile;
  72. $exifTool->WriteInfo('t/images/ExifTool.jpg', $testfile);
  73. $exifTool->Options(PrintConv => 0);
  74. my $info = $exifTool->ImageInfo($testfile, @checkTags);
  75. if (check($exifTool, $info, $testname, $testnum)) {
  76. unlink $testfile;
  77. } else {
  78. print 'not ';
  79. }
  80. print "ok $testnum\n";
  81. }
  82. # test 10: Create a VRD file from scratch
  83. {
  84. ++$testnum;
  85. my $exifTool = new Image::ExifTool;
  86. $exifTool->SetNewValuesFromFile('t/images/ExifTool.jpg', 'CanonVRD');
  87. $exifTool->Options(PrintConv => 0);
  88. my $testfile = "t/${testname}_${testnum}_failed.vrd";
  89. unlink $testfile;
  90. $exifTool->WriteInfo(undef, $testfile);
  91. my $info = $exifTool->ImageInfo($testfile, @checkTags);
  92. if (check($exifTool, $info, $testname, $testnum, 8)) {
  93. unlink $testfile;
  94. } else {
  95. print 'not ';
  96. }
  97. print "ok $testnum\n";
  98. }
  99. # test 11-12: Add XMP to a VRD file
  100. {
  101. my $exifTool = new Image::ExifTool;
  102. $exifTool->SetNewValue('XMP:Title', 'XMP in VRD test');
  103. my $srcfile;
  104. foreach $srcfile ('t/images/CanonVRD.vrd', undef) {
  105. ++$testnum;
  106. my $testfile = "t/${testname}_${testnum}_failed.vrd";
  107. unlink $testfile;
  108. $exifTool->WriteInfo($srcfile, $testfile);
  109. my $info = $exifTool->ImageInfo($testfile);
  110. if (check($exifTool, $info, $testname, $testnum)) {
  111. unlink $testfile;
  112. } else {
  113. print 'not ';
  114. }
  115. print "ok $testnum\n";
  116. }
  117. }
  118. # test 13: Extract information from CanonVRD.dr4
  119. {
  120. ++$testnum;
  121. my $exifTool = new Image::ExifTool;
  122. my $info = $exifTool->ImageInfo('t/images/CanonVRD.dr4');
  123. print 'not ' unless check($exifTool, $info, $testname, $testnum);
  124. print "ok $testnum\n";
  125. }
  126. # test 14: Test writing to DR4
  127. {
  128. ++$testnum;
  129. my $exifTool = new Image::ExifTool;
  130. $exifTool->Options(PrintConv => 0);
  131. $exifTool->SetNewValue(CropX => 123);
  132. $exifTool->SetNewValue(SharpnessAdjOn => 0);
  133. $exifTool->SetNewValue(RedHSL => '-4.3 1.2 3.8');
  134. $exifTool->SetNewValue('CanonVRD:GammaBlackPoint' => '1.234');
  135. my $testfile = "t/${testname}_${testnum}_failed.dr4";
  136. unlink $testfile;
  137. $exifTool->WriteInfo('t/images/CanonVRD.dr4', $testfile);
  138. my $info = $exifTool->ImageInfo($testfile, '-filename');
  139. print 'not ' unless check($exifTool, $info, $testname, $testnum);
  140. print "ok $testnum\n";
  141. }
  142. # tests 15-20: Write CanonDR4 as a block to various images
  143. {
  144. my $exifTool = new Image::ExifTool;
  145. my $srcfile = "t/${testname}_14_failed.dr4";
  146. $exifTool->SetNewValuesFromFile($srcfile, 'CanonDR4');
  147. $exifTool->Options(PrintConv => 0);
  148. my ($file, $ext);
  149. foreach $file (qw(Writer.jpg ExifTool.jpg CanonRaw.cr2 CanonRaw.crw CanonVRD.vrd CanonVRD.dr4)) {
  150. ++$testnum;
  151. ($ext = $file) =~ s/^\w+//;
  152. my $testfile = "t/${testname}_${testnum}_failed$ext";
  153. unlink $testfile;
  154. $exifTool->WriteInfo("t/images/$file", $testfile);
  155. my $info = $exifTool->ImageInfo($testfile, @checkDR4);
  156. if (check($exifTool, $info, $testname, $testnum)) {
  157. unlink $testfile unless $testnum == 15 or $testnum == 17;
  158. unlink $srcfile if $testnum == 20;
  159. } else {
  160. print 'not ';
  161. }
  162. print "ok $testnum\n";
  163. }
  164. }
  165. # test 21: Delete DR4(VRD) as a block
  166. {
  167. ++$testnum;
  168. my $exifTool = new Image::ExifTool;
  169. my $srcfile = "t/${testname}_15_failed.jpg";
  170. $exifTool->SetNewValue(CanonDR4 => undef, Protected => 1);
  171. my $testfile = "t/${testname}_${testnum}_failed.jpg";
  172. unlink $testfile;
  173. $exifTool->WriteInfo($srcfile, $testfile);
  174. $exifTool->Options(PrintConv => 0);
  175. my $info = $exifTool->ImageInfo($testfile, @checkDR4);
  176. if (check($exifTool, $info, $testname, $testnum)) {
  177. unlink $testfile;
  178. unlink $srcfile;
  179. } else {
  180. print 'not ';
  181. }
  182. print "ok $testnum\n";
  183. }
  184. # test 22: Create a DR4 file from scratch
  185. {
  186. ++$testnum;
  187. my $exifTool = new Image::ExifTool;
  188. $exifTool->Options(PrintConv => 0);
  189. my $srcfile = "t/${testname}_17_failed.cr2";
  190. $exifTool->SetNewValuesFromFile($srcfile, 'CanonDR4');
  191. my $testfile = "t/${testname}_${testnum}_failed.dr4";
  192. unlink $testfile;
  193. $exifTool->WriteInfo(undef, $testfile);
  194. my $info = $exifTool->ImageInfo($testfile, '-filename');
  195. if (check($exifTool, $info, $testname, $testnum, 14)) {
  196. unlink $testfile;
  197. unlink $srcfile;
  198. } else {
  199. print 'not ';
  200. }
  201. print "ok $testnum\n";
  202. }
  203. # end