KyoceraRaw.pm 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. #------------------------------------------------------------------------------
  2. # File: KyoceraRaw.pm
  3. #
  4. # Description: Read Kyocera RAW meta information
  5. #
  6. # Revisions: 02/17/2006 - P. Harvey Created
  7. #
  8. # References: 1) http://www.cybercom.net/~dcoffin/dcraw/
  9. #------------------------------------------------------------------------------
  10. package Image::ExifTool::KyoceraRaw;
  11. use strict;
  12. use vars qw($VERSION);
  13. use Image::ExifTool qw(:DataAccess :Utils);
  14. $VERSION = '1.03';
  15. sub ProcessRAW($$);
  16. # utility to reverse order of characters in a string
  17. sub ReverseString($) { pack('C*',reverse unpack('C*',shift)) }
  18. # Contax N Digital tags (ref PH)
  19. %Image::ExifTool::KyoceraRaw::Main = (
  20. PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
  21. GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
  22. NOTES => 'Tags for Kyocera Contax N Digital RAW images.',
  23. 0x01 => {
  24. Name => 'FirmwareVersion',
  25. Format => 'string[10]',
  26. ValueConv => \&ReverseString,
  27. },
  28. 0x0c => {
  29. Name => 'Model',
  30. Format => 'string[12]',
  31. ValueConv => \&ReverseString,
  32. },
  33. 0x19 => { #1
  34. Name => 'Make',
  35. Format => 'string[7]',
  36. ValueConv => \&ReverseString,
  37. },
  38. 0x21 => { #1
  39. Name => 'DateTimeOriginal',
  40. Description => 'Date/Time Original',
  41. Groups => { 2 => 'Time' },
  42. Format => 'string[20]',
  43. ValueConv => \&ReverseString,
  44. PrintConv => '$self->ConvertDateTime($val)',
  45. },
  46. 0x34 => {
  47. Name => 'ISO',
  48. Groups => { 2 => 'Image' },
  49. Format => 'int32u',
  50. PrintConv => {
  51. 7 => 25,
  52. 8 => 32,
  53. 9 => 40,
  54. 10 => 50,
  55. 11 => 64,
  56. 12 => 80,
  57. 13 => 100,
  58. 14 => 125,
  59. 15 => 160,
  60. 16 => 200,
  61. 17 => 250,
  62. 18 => 320,
  63. 19 => 400,
  64. },
  65. },
  66. 0x38 => {
  67. Name => 'ExposureTime',
  68. Groups => { 2 => 'Image' },
  69. Format => 'int32u',
  70. ValueConv => '2**($val / 8) / 16000',
  71. PrintConv => 'Image::ExifTool::Exif::PrintExposureTime($val)',
  72. },
  73. 0x3c => { #1
  74. Name => 'WB_RGGBLevels',
  75. Groups => { 2 => 'Image' },
  76. Format => 'int32u[4]',
  77. },
  78. 0x58 => {
  79. Name => 'FNumber',
  80. Groups => { 2 => 'Image' },
  81. Format => 'int32u',
  82. ValueConv => '2**($val/16)',
  83. PrintConv => 'sprintf("%.2g",$val)',
  84. },
  85. 0x68 => {
  86. Name => 'MaxAperture',
  87. Format => 'int32u',
  88. ValueConv => '2**($val/16)',
  89. PrintConv => 'sprintf("%.2g",$val)',
  90. },
  91. 0x70 => {
  92. Name => 'FocalLength',
  93. Format => 'int32u',
  94. PrintConv => '"$val mm"',
  95. },
  96. 0x7c => {
  97. Name => 'Lens',
  98. Format => 'string[32]',
  99. },
  100. );
  101. #------------------------------------------------------------------------------
  102. # Extract information from Kyocera RAW image
  103. # Inputs: 0) ExifTool object reference, 1) dirInfo reference
  104. # Returns: 1 if this was a valid Kyocera RAW image
  105. sub ProcessRAW($$)
  106. {
  107. my ($et, $dirInfo) = @_;
  108. my $raf = $$dirInfo{RAF};
  109. my $size = 156; # size of header
  110. my $buff;
  111. $raf->Read($buff, $size) == $size or return 0;
  112. # validate Make string ('KYOCERA' reversed)
  113. substr($buff, 0x19, 7) eq 'ARECOYK' or return 0;
  114. $et->SetFileType();
  115. SetByteOrder('MM');
  116. my %dirInfo = (
  117. DataPt => \$buff,
  118. DataPos => 0,
  119. DataLen => $size,
  120. DirStart => 0,
  121. DirLen => $size,
  122. );
  123. my $tagTablePtr = GetTagTable('Image::ExifTool::KyoceraRaw::Main');
  124. $et->ProcessDirectory(\%dirInfo, $tagTablePtr);
  125. return 1;
  126. }
  127. 1; # end
  128. __END__
  129. =head1 NAME
  130. Image::ExifTool::KyoceraRaw - Read Kyocera RAW meta information
  131. =head1 SYNOPSIS
  132. This module is loaded automatically by Image::ExifTool when required.
  133. =head1 DESCRIPTION
  134. This module contains definitions required by Image::ExifTool to read
  135. meta information from Kyocera Contax N Digital RAW images.
  136. =head1 AUTHOR
  137. Copyright 2003-2016, Phil Harvey (phil at owl.phy.queensu.ca)
  138. This library is free software; you can redistribute it and/or modify it
  139. under the same terms as Perl itself.
  140. =head1 REFERENCES
  141. =over 4
  142. =item L<http://www.cybercom.net/~dcoffin/dcraw/>
  143. =back
  144. =head1 SEE ALSO
  145. L<Image::ExifTool::TagNames/KyoceraRaw Tags>,
  146. L<Image::ExifTool(3pm)|Image::ExifTool>
  147. =cut