Sanyo.pm 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440
  1. #------------------------------------------------------------------------------
  2. # File: Sanyo.pm
  3. #
  4. # Description: Sanyo EXIF maker notes tags
  5. #
  6. # Revisions: 04/06/2004 - P. Harvey Created
  7. #
  8. # Reference: http://www.exif.org/makernotes/SanyoMakerNote.html
  9. #------------------------------------------------------------------------------
  10. package Image::ExifTool::Sanyo;
  11. use strict;
  12. use vars qw($VERSION);
  13. use Image::ExifTool::Exif;
  14. $VERSION = '1.16';
  15. my %offOn = (
  16. 0 => 'Off',
  17. 1 => 'On',
  18. );
  19. %Image::ExifTool::Sanyo::Main = (
  20. WRITE_PROC => \&Image::ExifTool::Exif::WriteExif,
  21. CHECK_PROC => \&Image::ExifTool::Exif::CheckExif,
  22. WRITABLE => 1,
  23. GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
  24. 0x00ff => {
  25. # this is an absolute offset in the JPG file... odd - PH
  26. Name => 'MakerNoteOffset',
  27. Writable => 'int32u',
  28. },
  29. 0x0100 => {
  30. Name => 'SanyoThumbnail',
  31. Groups => { 2 => 'Preview' },
  32. Writable => 'undef',
  33. WriteCheck => '$self->CheckImage(\$val)',
  34. RawConv => '$self->ValidateImage(\$val,$tag)',
  35. },
  36. 0x0200 => {
  37. Name => 'SpecialMode',
  38. Writable => 'int32u',
  39. Count => 3,
  40. },
  41. 0x0201 => {
  42. Name => 'SanyoQuality',
  43. Flags => 'PrintHex',
  44. Writable => 'int16u',
  45. PrintConv => {
  46. 0x0000 => 'Normal/Very Low',
  47. 0x0001 => 'Normal/Low',
  48. 0x0002 => 'Normal/Medium Low',
  49. 0x0003 => 'Normal/Medium',
  50. 0x0004 => 'Normal/Medium High',
  51. 0x0005 => 'Normal/High',
  52. 0x0006 => 'Normal/Very High',
  53. 0x0007 => 'Normal/Super High',
  54. # have seen 0x11 with HD2000 in '8M-H JPEG' mode - PH
  55. 0x0100 => 'Fine/Very Low',
  56. 0x0101 => 'Fine/Low',
  57. 0x0102 => 'Fine/Medium Low',
  58. 0x0103 => 'Fine/Medium',
  59. 0x0104 => 'Fine/Medium High',
  60. 0x0105 => 'Fine/High',
  61. 0x0106 => 'Fine/Very High',
  62. 0x0107 => 'Fine/Super High',
  63. 0x0200 => 'Super Fine/Very Low',
  64. 0x0201 => 'Super Fine/Low',
  65. 0x0202 => 'Super Fine/Medium Low',
  66. 0x0203 => 'Super Fine/Medium',
  67. 0x0204 => 'Super Fine/Medium High',
  68. 0x0205 => 'Super Fine/High',
  69. 0x0206 => 'Super Fine/Very High',
  70. 0x0207 => 'Super Fine/Super High',
  71. },
  72. },
  73. 0x0202 => {
  74. Name => 'Macro',
  75. Writable => 'int16u',
  76. PrintConv => {
  77. 0 => 'Normal',
  78. 1 => 'Macro',
  79. 2 => 'View',
  80. 3 => 'Manual',
  81. },
  82. },
  83. 0x0204 => {
  84. Name => 'DigitalZoom',
  85. Writable => 'rational64u',
  86. },
  87. 0x0207 => 'SoftwareVersion',
  88. 0x0208 => 'PictInfo',
  89. 0x0209 => 'CameraID',
  90. 0x020e => {
  91. Name => 'SequentialShot',
  92. Writable => 'int16u',
  93. PrintConv => {
  94. 0 => 'None',
  95. 1 => 'Standard',
  96. 2 => 'Best',
  97. 3 => 'Adjust Exposure',
  98. },
  99. },
  100. 0x020f => {
  101. Name => 'WideRange',
  102. Writable => 'int16u',
  103. PrintConv => \%offOn,
  104. },
  105. 0x0210 => {
  106. Name => 'ColorAdjustmentMode',
  107. Writable => 'int16u',
  108. PrintConv => \%offOn,
  109. },
  110. 0x0213 => {
  111. Name => 'QuickShot',
  112. Writable => 'int16u',
  113. PrintConv => \%offOn,
  114. },
  115. 0x0214 => {
  116. Name => 'SelfTimer',
  117. Writable => 'int16u',
  118. PrintConv => \%offOn,
  119. },
  120. # 0x0215 - Flash?
  121. 0x0216 => {
  122. Name => 'VoiceMemo',
  123. Writable => 'int16u',
  124. PrintConv => \%offOn,
  125. },
  126. 0x0217 => {
  127. Name => 'RecordShutterRelease',
  128. Writable => 'int16u',
  129. PrintConv => {
  130. 0 => 'Record while down',
  131. 1 => 'Press start, press stop',
  132. },
  133. },
  134. 0x0218 => {
  135. Name => 'FlickerReduce',
  136. Writable => 'int16u',
  137. PrintConv => \%offOn,
  138. },
  139. 0x0219 => {
  140. Name => 'OpticalZoomOn',
  141. Writable => 'int16u',
  142. PrintConv => \%offOn,
  143. },
  144. 0x021b => {
  145. Name => 'DigitalZoomOn',
  146. Writable => 'int16u',
  147. PrintConv => \%offOn,
  148. },
  149. 0x021d => {
  150. Name => 'LightSourceSpecial',
  151. Writable => 'int16u',
  152. PrintConv => \%offOn,
  153. },
  154. 0x021e => {
  155. Name => 'Resaved',
  156. Writable => 'int16u',
  157. PrintConv => {
  158. 0 => 'No',
  159. 1 => 'Yes',
  160. },
  161. },
  162. 0x021f => {
  163. Name => 'SceneSelect',
  164. Writable => 'int16u',
  165. PrintConv => {
  166. 0 => 'Off',
  167. 1 => 'Sport',
  168. 2 => 'TV',
  169. 3 => 'Night',
  170. 4 => 'User 1',
  171. 5 => 'User 2',
  172. 6 => 'Lamp', #PH
  173. },
  174. },
  175. 0x0223 => [
  176. {
  177. Name => 'ManualFocusDistance',
  178. Condition => '$format eq "rational64u"',
  179. Writable => 'rational64u',
  180. }, { #PH
  181. Name => 'FaceInfo',
  182. SubDirectory => { TagTable => 'Image::ExifTool::Sanyo::FaceInfo' },
  183. },
  184. ],
  185. 0x0224 => {
  186. Name => 'SequenceShotInterval',
  187. Writable => 'int16u',
  188. PrintConv => {
  189. 0 => '5 frames/s',
  190. 1 => '10 frames/s',
  191. 2 => '15 frames/s',
  192. 3 => '20 frames/s',
  193. },
  194. },
  195. 0x0225 => {
  196. Name => 'FlashMode',
  197. Writable => 'int16u',
  198. PrintConv => {
  199. 0 => 'Auto',
  200. 1 => 'Force',
  201. 2 => 'Disabled',
  202. 3 => 'Red eye',
  203. },
  204. },
  205. 0x0e00 => {
  206. Name => 'PrintIM',
  207. Description => 'Print Image Matching',
  208. Writable => 0,
  209. SubDirectory => {
  210. TagTable => 'Image::ExifTool::PrintIM::Main',
  211. },
  212. },
  213. 0x0f00 => {
  214. Name => 'DataDump',
  215. Writable => 0,
  216. Binary => 1,
  217. },
  218. );
  219. # face detection information (ref PH)
  220. %Image::ExifTool::Sanyo::FaceInfo = (
  221. PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
  222. WRITE_PROC => \&Image::ExifTool::WriteBinaryData,
  223. CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
  224. GROUPS => { 0 => 'MakerNotes', 2 => 'Image' },
  225. WRITABLE => 1,
  226. FORMAT => 'int32u',
  227. FIRST_ENTRY => 0,
  228. 0 => 'FacesDetected',
  229. 4 => {
  230. Name => 'FacePosition',
  231. Format => 'int32u[4]',
  232. Notes => q{
  233. left, top, right and bottom coordinates of detected face in an unrotated
  234. 640-pixel-wide image, with increasing Y downwards
  235. },
  236. },
  237. );
  238. # tags in Sanyo MOV videos (PH - observations from an E6 sample)
  239. # (similar information in Kodak,Minolta,Nikon,Olympus,Pentax and Sanyo videos)
  240. %Image::ExifTool::Sanyo::MOV = (
  241. PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
  242. GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
  243. NOTES => 'This information is found in Sanyo MOV videos.',
  244. 0x00 => {
  245. Name => 'Make',
  246. Format => 'string[24]',
  247. },
  248. 0x18 => {
  249. Name => 'Model',
  250. Description => 'Camera Model Name',
  251. Format => 'string[8]',
  252. },
  253. # (01 00 at offset 0x20)
  254. 0x26 => {
  255. Name => 'ExposureTime',
  256. Format => 'int32u',
  257. ValueConv => '$val ? 10 / $val : 0',
  258. PrintConv => 'Image::ExifTool::Exif::PrintExposureTime($val)',
  259. },
  260. 0x2a => {
  261. Name => 'FNumber',
  262. Format => 'int32u',
  263. ValueConv => '$val / 10',
  264. PrintConv => 'sprintf("%.1f",$val)',
  265. },
  266. 0x32 => {
  267. Name => 'ExposureCompensation',
  268. Format => 'int32s',
  269. ValueConv => '$val / 10',
  270. PrintConv => 'Image::ExifTool::Exif::PrintFraction($val)',
  271. },
  272. 0x44 => {
  273. Name => 'WhiteBalance',
  274. Format => 'int16u',
  275. PrintConv => {
  276. 0 => 'Auto',
  277. 1 => 'Daylight',
  278. 2 => 'Shade',
  279. 3 => 'Fluorescent', #2
  280. 4 => 'Tungsten',
  281. 5 => 'Manual',
  282. },
  283. },
  284. 0x48 => {
  285. Name => 'FocalLength',
  286. Format => 'int32u',
  287. ValueConv => '$val / 10',
  288. PrintConv => 'sprintf("%.1f mm",$val)',
  289. },
  290. );
  291. # tags in Sanyo MP4 videos (PH - from C4, C5 and HD1A samples)
  292. # --> very similar to Samsung MP4 information
  293. # (there is still a lot more information here that could be decoded!)
  294. %Image::ExifTool::Sanyo::MP4 = (
  295. PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
  296. GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
  297. NOTES => 'This information is found in Sanyo MP4 videos.',
  298. 0x00 => {
  299. Name => 'Make',
  300. Format => 'string[5]',
  301. PrintConv => 'ucfirst(lc($val))',
  302. },
  303. 0x18 => {
  304. Name => 'Model',
  305. Description => 'Camera Model Name',
  306. Format => 'string[8]',
  307. },
  308. # (01 00 at offset 0x28)
  309. # (0x2e has values 0x31, 0x33 and 0x3c in my samples, but
  310. # some of the shutter speeds should be around 1/500 or so)
  311. 0x32 => {
  312. Name => 'FNumber',
  313. Format => 'rational64u',
  314. PrintConv => 'sprintf("%.1f",$val)',
  315. },
  316. 0x3a => { # (NC)
  317. Name => 'ExposureCompensation',
  318. Format => 'rational64s',
  319. PrintConv => '$val ? sprintf("%+.1f", $val) : 0',
  320. },
  321. 0x6a => {
  322. Name => 'ISO',
  323. Format => 'int32u',
  324. },
  325. 0xd1 => {
  326. Name => 'Software',
  327. Notes => 'these tags are shifted up by 1 byte for some models like the HD1A',
  328. Format => 'undef[32]',
  329. RawConv => q{
  330. $val =~ /^SANYO/ or return undef;
  331. $val =~ tr/\0//d;
  332. $$self{SanyoSledder0xd1} = 1;
  333. return $val;
  334. },
  335. },
  336. 0xd2 => {
  337. Name => 'Software',
  338. Format => 'undef[32]',
  339. RawConv => q{
  340. $val =~ /^SANYO/ or return undef;
  341. $val =~ tr/\0//d;
  342. $$self{SanyoSledder0xd2} = 1;
  343. return $val;
  344. },
  345. },
  346. 0xf1 => {
  347. Name => 'Thumbnail',
  348. Condition => '$$self{SanyoSledder0xd1}',
  349. SubDirectory => {
  350. TagTable => 'Image::ExifTool::Sanyo::Thumbnail',
  351. Base => '$start',
  352. },
  353. },
  354. 0xf2 => {
  355. Name => 'Thumbnail',
  356. Condition => '$$self{SanyoSledder0xd2}',
  357. SubDirectory => {
  358. TagTable => 'Image::ExifTool::Sanyo::Thumbnail',
  359. Base => '$start',
  360. },
  361. },
  362. );
  363. # thumbnail image information found in MP4 videos (similar in Olympus,Samsung,Sanyo)
  364. %Image::ExifTool::Sanyo::Thumbnail = (
  365. PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
  366. GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
  367. FIRST_ENTRY => 0,
  368. FORMAT => 'int32u',
  369. 1 => 'ThumbnailWidth',
  370. 2 => 'ThumbnailHeight',
  371. 3 => 'ThumbnailLength',
  372. 4 => { Name => 'ThumbnailOffset', IsOffset => 1 },
  373. );
  374. #------------------------------------------------------------------------------
  375. # Patch incorrect offsets in J1, J2, J4, S1, S3 and S4 maker notes
  376. # Inputs: 0) valuePtr, 1) end of previous value, 2) value size, 3) tag ID, 4) write flag
  377. sub FixOffsets($$$$;$)
  378. {
  379. my ($valuePtr, $valEnd, $size, $tagID, $wFlag) = @_;
  380. # ignore existing offsets and calculate reasonable values instead
  381. if ($tagID == 0x100) {
  382. # just ignore the SanyoThumbnail when writing (pointer is garbage)
  383. $_[0] = undef if $wFlag;
  384. } else {
  385. $_[0] = $valEnd; # set value pointer to next logical location
  386. ++$size if $size & 0x01;
  387. $_[1] += $size; # update end-of-value pointer
  388. }
  389. }
  390. 1; # end
  391. __END__
  392. =head1 NAME
  393. Image::ExifTool::Sanyo - Sanyo EXIF maker notes tags
  394. =head1 SYNOPSIS
  395. This module is loaded automatically by Image::ExifTool when required.
  396. =head1 DESCRIPTION
  397. This module contains definitions required by Image::ExifTool to interpret
  398. Sanyo maker notes in EXIF information.
  399. =head1 AUTHOR
  400. Copyright 2003-2016, Phil Harvey (phil at owl.phy.queensu.ca)
  401. This library is free software; you can redistribute it and/or modify it
  402. under the same terms as Perl itself.
  403. =head1 REFERENCES
  404. =over 4
  405. =item L<http://www.exif.org/makernotes/SanyoMakerNote.html>
  406. =back
  407. =head1 SEE ALSO
  408. L<Image::ExifTool::TagNames/Sanyo Tags>,
  409. L<Image::ExifTool(3pm)|Image::ExifTool>
  410. =cut