MIE.t 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. # Before "make install", this script should be runnable with "make test".
  2. # After "make install" it should work as "perl t/MIE.t".
  3. BEGIN { $| = 1; print "1..6\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::MIE;
  8. $loaded = 1;
  9. print "ok 1\n";
  10. use t::TestLib;
  11. my $testname = 'MIE';
  12. my $testnum = 1;
  13. # test 2: Extract information from MIE.mie
  14. {
  15. ++$testnum;
  16. my $exifTool = new Image::ExifTool;
  17. my $info = $exifTool->ImageInfo('t/images/MIE.mie', '-filename', '-directory');
  18. print 'not ' unless check($exifTool, $info, $testname, $testnum);
  19. print "ok $testnum\n";
  20. }
  21. # test 3: Write MIE information (also test Escape option when writing)
  22. {
  23. ++$testnum;
  24. my $exifTool = new Image::ExifTool;
  25. $exifTool->Options(IgnoreMinorErrors => 1); # to copy invalid thumbnail
  26. $exifTool->SetNewValuesFromFile('t/images/Nikon.jpg','*:*');
  27. $exifTool->SetNewValue('EXIF:XResolution' => 200);
  28. $exifTool->SetNewValue('MIE:FNumber' => 11);
  29. $exifTool->SetNewValue('XMP:Creator' => 'phil');
  30. $exifTool->SetNewValue('IPTC:Keywords' => 'cool');
  31. $exifTool->Options(Escape => 'HTML');
  32. $exifTool->SetNewValue('MIE:PhoneNumber' => 'kühl');
  33. $exifTool->Options(Escape => undef);
  34. my $testfile = "t/${testname}_${testnum}_failed.mie";
  35. unlink $testfile;
  36. $exifTool->WriteInfo('t/images/MIE.mie', $testfile);
  37. my $info = $exifTool->ImageInfo($testfile);
  38. if (check($exifTool, $info, $testname, $testnum)) {
  39. unlink $testfile;
  40. } else {
  41. print 'not ';
  42. }
  43. print "ok $testnum\n";
  44. }
  45. # test 4: Create a MIE file from scratch (also test Escape option when copying)
  46. {
  47. ++$testnum;
  48. my $exifTool = new Image::ExifTool;
  49. $exifTool->Options(IgnoreMinorErrors => 1); # to copy invalid thumbnail
  50. $exifTool->Options(Escape => 'HTML');
  51. $exifTool->SetNewValuesFromFile('t/images/MIE.mie');
  52. my $testfile = "t/${testname}_${testnum}_failed.mie";
  53. unlink $testfile;
  54. $exifTool->WriteInfo(undef, $testfile);
  55. $exifTool->Options(Escape => undef); # reset Escape option
  56. my $info = $exifTool->ImageInfo($testfile, '-filename', '-directory');
  57. if (check($exifTool, $info, $testname, $testnum, 2)) {
  58. unlink $testfile;
  59. } else {
  60. print 'not ';
  61. }
  62. print "ok $testnum\n";
  63. }
  64. # tests 5-6: Test reading different Charsets
  65. foreach (qw(Latin Cyrillic)) {
  66. ++$testnum;
  67. my $exifTool = new Image::ExifTool;
  68. $exifTool->Options(Charset => $_);
  69. my $info = $exifTool->ImageInfo('t/images/MIE.mie', 'comment-ru_ru');
  70. print 'not ' unless check($exifTool, $info, $testname, $testnum);
  71. print "ok $testnum\n";
  72. }
  73. # end