JPEG.pm 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605
  1. #------------------------------------------------------------------------------
  2. # File: JPEG.pm
  3. #
  4. # Description: Definitions for uncommon JPEG segments
  5. #
  6. # Revisions: 10/06/2006 - P. Harvey Created
  7. #------------------------------------------------------------------------------
  8. package Image::ExifTool::JPEG;
  9. use strict;
  10. use vars qw($VERSION);
  11. use Image::ExifTool qw(:DataAccess :Utils);
  12. $VERSION = '1.25';
  13. sub ProcessOcad($$$);
  14. sub ProcessJPEG_HDR($$$);
  15. # (this main JPEG table is for documentation purposes only)
  16. %Image::ExifTool::JPEG::Main = (
  17. NOTES => 'This table lists information extracted by ExifTool from JPEG images.',
  18. APP0 => [{
  19. Name => 'JFIF',
  20. Condition => '$$valPt =~ /^JFIF\0/',
  21. SubDirectory => { TagTable => 'Image::ExifTool::JFIF::Main' },
  22. }, {
  23. Name => 'JFXX',
  24. Condition => '$$valPt =~ /^JFXX\0\x10/',
  25. SubDirectory => { TagTable => 'Image::ExifTool::JFIF::Extension' },
  26. }, {
  27. Name => 'CIFF',
  28. Condition => '$$valPt =~ /^(II|MM).{4}HEAPJPGM/s',
  29. SubDirectory => { TagTable => 'Image::ExifTool::CanonRaw::Main' },
  30. }, {
  31. Name => 'AVI1',
  32. Condition => '$$valPt =~ /^AVI1/',
  33. SubDirectory => { TagTable => 'Image::ExifTool::JPEG::AVI1' },
  34. }, {
  35. Name => 'Ocad',
  36. Condition => '$$valPt =~ /^Ocad/',
  37. SubDirectory => { TagTable => 'Image::ExifTool::JPEG::Ocad' },
  38. }],
  39. APP1 => [{
  40. Name => 'EXIF',
  41. Condition => '$$valPt =~ /^Exif\0/',
  42. SubDirectory => { TagTable => 'Image::ExifTool::Exif::Main' },
  43. }, {
  44. Name => 'ExtendedXMP',
  45. Condition => '$$valPt =~ m{^http://ns.adobe.com/xmp/extension/\0}',
  46. SubDirectory => { TagTable => 'Image::ExifTool::XMP::Main' },
  47. }, {
  48. Name => 'XMP',
  49. Condition => '$$valPt =~ /^http/ or $$valPt =~ /<exif:/',
  50. SubDirectory => { TagTable => 'Image::ExifTool::XMP::Main' },
  51. }, {
  52. Name => 'QVCI',
  53. Condition => '$$valPt =~ /^QVCI\0/',
  54. SubDirectory => { TagTable => 'Image::ExifTool::Casio::QVCI' },
  55. }, {
  56. Name => 'FLIR',
  57. Condition => '$$valPt =~ /^FLIR\0/',
  58. SubDirectory => { TagTable => 'Image::ExifTool::FLIR::FFF' },
  59. }],
  60. APP2 => [{
  61. Name => 'ICC_Profile',
  62. Condition => '$$valPt =~ /^ICC_PROFILE\0/',
  63. SubDirectory => { TagTable => 'Image::ExifTool::ICC_Profile::Main' },
  64. }, {
  65. Name => 'FPXR',
  66. Condition => '$$valPt =~ /^FPXR\0/',
  67. SubDirectory => { TagTable => 'Image::ExifTool::FlashPix::Main' },
  68. }, {
  69. Name => 'MPF',
  70. Condition => '$$valPt =~ /^MPF\0/',
  71. SubDirectory => { TagTable => 'Image::ExifTool::MPF::Main' },
  72. }, {
  73. Name => 'PreviewImage',
  74. Condition => '$$valPt =~ /^(|QVGA\0|BGTH)\xff\xd8\xff\xdb/',
  75. Notes => 'Samsung APP2 preview image', # (Samsung/GoPro="", BenQ="QVGA\0", Digilife="BGTH")
  76. }],
  77. APP3 => [{
  78. Name => 'Meta',
  79. Condition => '$$valPt =~ /^(Meta|META|Exif)\0\0/',
  80. SubDirectory => { TagTable => 'Image::ExifTool::Kodak::Meta' },
  81. }, {
  82. Name => 'Stim',
  83. Condition => '$$valPt =~ /^Stim\0/',
  84. SubDirectory => { TagTable => 'Image::ExifTool::Stim::Main' },
  85. }, {
  86. Name => 'PreviewImage', # (written by HP R837 and Samsung S1060)
  87. Condition => '$$valPt =~ /^\xff\xd8\xff\xdb/',
  88. Notes => 'Samsung/HP preview image', # (Samsung, HP, BenQ)
  89. }],
  90. APP4 => [{
  91. Name => 'Scalado',
  92. Condition => '$$valPt =~ /^SCALADO\0/',
  93. SubDirectory => { TagTable => 'Image::ExifTool::Scalado::Main' },
  94. }, {
  95. Name => 'FPXR', # (non-standard location written by some HP models)
  96. Condition => '$$valPt =~ /^FPXR\0/',
  97. SubDirectory => { TagTable => 'Image::ExifTool::FlashPix::Main' },
  98. }, {
  99. Name => 'PreviewImage', # (eg. Samsung S1060)
  100. Notes => 'continued from APP3',
  101. }],
  102. APP5 => [{
  103. Name => 'RMETA',
  104. Condition => '$$valPt =~ /^RMETA\0/',
  105. SubDirectory => { TagTable => 'Image::ExifTool::Ricoh::RMETA' },
  106. }, {
  107. Name => 'PreviewImage', # (eg. BenQ DC E1050)
  108. Notes => 'continued from APP4',
  109. }],
  110. APP6 => [{
  111. Name => 'EPPIM',
  112. Condition => '$$valPt =~ /^EPPIM\0/',
  113. SubDirectory => { TagTable => 'Image::ExifTool::JPEG::EPPIM' },
  114. }, {
  115. Name => 'NITF',
  116. Condition => '$$valPt =~ /^NTIF\0/',
  117. SubDirectory => { TagTable => 'Image::ExifTool::JPEG::NITF' },
  118. }, {
  119. Name => 'HP_TDHD', # (written by R837)
  120. Condition => '$$valPt =~ /^TDHD\x01\0\0\0/',
  121. SubDirectory => { TagTable => 'Image::ExifTool::HP::TDHD' },
  122. }],
  123. APP7 => [{
  124. Name => 'Pentax',
  125. Condition => '$$valPt =~ /^PENTAX \0/',
  126. SubDirectory => { TagTable => 'Image::ExifTool::Pentax::Main' },
  127. }, {
  128. Name => 'Qualcomm',
  129. Condition => '$$valPt =~ /^\x1aQualcomm Camera Attributes/',
  130. SubDirectory => { TagTable => 'Image::ExifTool::Qualcomm::Main' },
  131. }],
  132. APP8 => {
  133. Name => 'SPIFF',
  134. Condition => '$$valPt =~ /^SPIFF\0/',
  135. SubDirectory => { TagTable => 'Image::ExifTool::JPEG::SPIFF' },
  136. },
  137. APP9 => {
  138. Name => 'MediaJukebox',
  139. Condition => '$$valPt =~ /^Media Jukebox\0/',
  140. SubDirectory => { TagTable => 'Image::ExifTool::JPEG::MediaJukebox' },
  141. },
  142. APP10 => {
  143. Name => 'Comment',
  144. Condition => '$$valPt =~ /^UNICODE\0/',
  145. Notes => 'PhotoStudio Unicode comment',
  146. },
  147. APP11 => {
  148. Name => 'JPEG-HDR',
  149. Condition => '$$valPt =~ /^HDR_RI /',
  150. SubDirectory => { TagTable => 'Image::ExifTool::JPEG::HDR' },
  151. },
  152. APP12 => [{
  153. Name => 'PictureInfo',
  154. Condition => '$$valPt =~ /(\[picture info\]|Type=)/',
  155. SubDirectory => { TagTable => 'Image::ExifTool::APP12::PictureInfo' },
  156. }, {
  157. Name => 'Ducky',
  158. Condition => '$$valPt =~ /^Ducky/',
  159. SubDirectory => { TagTable => 'Image::ExifTool::APP12::Ducky' },
  160. }],
  161. APP13 => [{
  162. Name => 'Photoshop',
  163. Condition => '$$valPt =~ /^(Photoshop 3.0\0|Adobe_Photoshop2.5)/',
  164. SubDirectory => { TagTable => 'Image::ExifTool::Photoshop::Main' },
  165. }, {
  166. Name => 'Adobe_CM',
  167. Condition => '$$valPt =~ /^Adobe_CM/',
  168. SubDirectory => { TagTable => 'Image::ExifTool::JPEG::AdobeCM' },
  169. }],
  170. APP14 => {
  171. Name => 'Adobe',
  172. Condition => '$$valPt =~ /^Adobe/',
  173. Writable => 1, # (for docs only)
  174. SubDirectory => { TagTable => 'Image::ExifTool::JPEG::Adobe' },
  175. },
  176. APP15 => {
  177. Name => 'GraphicConverter',
  178. Condition => '$$valPt =~ /^Q\s*(\d+)/',
  179. SubDirectory => { TagTable => 'Image::ExifTool::JPEG::GraphConv' },
  180. },
  181. # APP15 - Also unknown "TEXT\0" segment stored by Casio/FujiFilm
  182. COM => {
  183. Name => 'Comment',
  184. # note: flag as writable for documentation, but it won't show up
  185. # in the TagLookup as writable because there is no WRITE_PROC
  186. Writable => 1,
  187. },
  188. SOF => {
  189. Name => 'StartOfFrame',
  190. SubDirectory => { TagTable => 'Image::ExifTool::JPEG::SOF' },
  191. },
  192. DQT => {
  193. Name => 'DefineQuantizationTable',
  194. Notes => 'used to calculate the Extra JPEGDigest tag value',
  195. },
  196. Trailer => [{
  197. Name => 'AFCP',
  198. Condition => '$$valPt =~ /AXS(!|\*).{8}$/s',
  199. SubDirectory => { TagTable => 'Image::ExifTool::AFCP::Main' },
  200. }, {
  201. Name => 'CanonVRD',
  202. Condition => '$$valPt =~ /CANON OPTIONAL DATA\0.{44}$/s',
  203. SubDirectory => { TagTable => 'Image::ExifTool::CanonVRD::Main' },
  204. }, {
  205. Name => 'FotoStation',
  206. Condition => '$$valPt =~ /\xa1\xb2\xc3\xd4$/',
  207. SubDirectory => { TagTable => 'Image::ExifTool::FotoStation::Main' },
  208. }, {
  209. Name => 'PhotoMechanic',
  210. Condition => '$$valPt =~ /cbipcbbl$/',
  211. SubDirectory => { TagTable => 'Image::ExifTool::PhotoMechanic::Main' },
  212. }, {
  213. Name => 'MIE',
  214. Condition => q{
  215. $$valPt =~ /~\0\x04\0zmie~\0\0\x06.{4}[\x10\x18]\x04$/s or
  216. $$valPt =~ /~\0\x04\0zmie~\0\0\x0a.{8}[\x10\x18]\x08$/s
  217. },
  218. SubDirectory => { TagTable => 'Image::ExifTool::MIE::Main' },
  219. }, {
  220. Name => 'Samsung',
  221. Condition => '$$valPt =~ /QDIOBS$/',
  222. SubDirectory => { TagTable => 'Image::ExifTool::Samsung::Trailer' },
  223. }, {
  224. Name => 'PreviewImage',
  225. Condition => '$$valPt =~ /^\xff\xd8\xff/',
  226. Writable => 1, # (for docs only)
  227. }],
  228. );
  229. # EPPIM APP6 (Toshiba PrintIM) segment (ref PH, from PDR-M700 samples)
  230. %Image::ExifTool::JPEG::EPPIM = (
  231. GROUPS => { 0 => 'APP6', 1 => 'EPPIM', 2 => 'Image' },
  232. NOTES => q{
  233. APP6 is used in by the Toshiba PDR-M700 to store a TIFF structure containing
  234. PrintIM information.
  235. },
  236. 0xc4a5 => {
  237. Name => 'PrintIM',
  238. # must set Writable here so this tag will be saved with MakerNotes option
  239. Writable => 'undef',
  240. Description => 'Print Image Matching',
  241. SubDirectory => {
  242. TagTable => 'Image::ExifTool::PrintIM::Main',
  243. },
  244. },
  245. );
  246. # SPIFF APP8 segment. Refs:
  247. # 1) http://www.fileformat.info/format/spiff/
  248. # 2) http://www.jpeg.org/public/spiff.pdf
  249. %Image::ExifTool::JPEG::SPIFF = (
  250. PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
  251. GROUPS => { 0 => 'APP8', 1 => 'SPIFF', 2 => 'Image' },
  252. NOTES => q{
  253. This information is found in APP8 of SPIFF-style JPEG images (the "official"
  254. yet rarely used JPEG file format standard: Still Picture Interchange File
  255. Format). See L<http://www.jpeg.org/public/spiff.pdf> for the official
  256. specification.
  257. },
  258. 0 => {
  259. Name => 'SPIFFVersion',
  260. Format => 'int8u[2]',
  261. PrintConv => '$val =~ tr/ /./; $val',
  262. },
  263. 2 => {
  264. Name => 'ProfileID',
  265. PrintConv => {
  266. 0 => 'Not Specified',
  267. 1 => 'Continuous-tone Base',
  268. 2 => 'Continuous-tone Progressive',
  269. 3 => 'Bi-level Facsimile',
  270. 4 => 'Continuous-tone Facsimile',
  271. },
  272. },
  273. 3 => 'ColorComponents',
  274. 6 => {
  275. Name => 'ImageHeight',
  276. Notes => q{
  277. at index 4 in specification, but there are 2 extra bytes here in my only
  278. SPIFF sample, version 1.2
  279. },
  280. Format => 'int32u',
  281. },
  282. 10 => {
  283. Name => 'ImageWidth',
  284. Format => 'int32u',
  285. },
  286. 14 => {
  287. Name => 'ColorSpace',
  288. PrintConv => {
  289. 0 => 'Bi-level',
  290. 1 => 'YCbCr, ITU-R BT 709, video',
  291. 2 => 'No color space specified',
  292. 3 => 'YCbCr, ITU-R BT 601-1, RGB',
  293. 4 => 'YCbCr, ITU-R BT 601-1, video',
  294. 8 => 'Gray-scale',
  295. 9 => 'PhotoYCC',
  296. 10 => 'RGB',
  297. 11 => 'CMY',
  298. 12 => 'CMYK',
  299. 13 => 'YCCK',
  300. 14 => 'CIELab',
  301. },
  302. },
  303. 15 => 'BitsPerSample',
  304. 16 => {
  305. Name => 'Compression',
  306. PrintConv => {
  307. 0 => 'Uncompressed, interleaved, 8 bits per sample',
  308. 1 => 'Modified Huffman',
  309. 2 => 'Modified READ',
  310. 3 => 'Modified Modified READ',
  311. 4 => 'JBIG',
  312. 5 => 'JPEG',
  313. },
  314. },
  315. 17 => {
  316. Name => 'ResolutionUnit',
  317. PrintConv => {
  318. 0 => 'None',
  319. 1 => 'inches',
  320. 2 => 'cm',
  321. },
  322. },
  323. 18 => {
  324. Name => 'YResolution',
  325. Format => 'int32u',
  326. },
  327. 22 => {
  328. Name => 'XResolution',
  329. Format => 'int32u',
  330. },
  331. );
  332. # Media Jukebox APP9 segment (ref PH)
  333. %Image::ExifTool::JPEG::MediaJukebox = (
  334. GROUPS => { 0 => 'XML', 1 => 'MediaJukebox', 2 => 'Image' },
  335. VARS => { NO_ID => 1 },
  336. NOTES => 'Tags found in the XML metadata of the "Media Jukebox" APP9 segment.',
  337. Date => {
  338. Groups => { 2 => 'Time' },
  339. # convert from days since Dec 30, 1899 to seconds since Jan 1, 1970
  340. ValueConv => 'ConvertUnixTime(($val - (70 * 365 + 17 + 2)) * 24 * 3600)',
  341. PrintConv => '$self->ConvertDateTime($val)',
  342. },
  343. Album => { },
  344. Caption => { },
  345. Keywords => { },
  346. Name => { },
  347. People => { },
  348. Places => { },
  349. Tool_Name => { },
  350. Tool_Version => { },
  351. );
  352. # JPEG-HDR APP11 information (ref PH, guessed from http://anyhere.com/gward/papers/cic05.pdf)
  353. %Image::ExifTool::JPEG::HDR = (
  354. GROUPS => { 0 => 'APP11', 1 => 'JPEG-HDR', 2 => 'Image' },
  355. PROCESS_PROC => \&ProcessJPEG_HDR,
  356. TAG_PREFIX => '', # (no prefix for unknown tags)
  357. NOTES => 'Information extracted from APP11 of a JPEG-HDR image.',
  358. ver => 'JPEG-HDRVersion',
  359. # (need names for the next 3 tags)
  360. ln0 => { Description => 'Ln0' },
  361. ln1 => { Description => 'Ln1' },
  362. s2n => { Description => 'S2n' },
  363. alp => { Name => 'Alpha' }, # (Alpha/Beta are saturation parameters)
  364. bet => { Name => 'Beta' },
  365. cor => { Name => 'CorrectionMethod' },
  366. RatioImage => {
  367. Groups => { 2 => 'Preview' },
  368. Notes => 'the embedded JPEG-compressed ratio image',
  369. Binary => 1,
  370. },
  371. );
  372. # AdobeCM APP13 (no references)
  373. %Image::ExifTool::JPEG::AdobeCM = (
  374. PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
  375. GROUPS => { 0 => 'APP13', 1 => 'AdobeCM', 2 => 'Image' },
  376. NOTES => q{
  377. The "Adobe_CM" APP13 segment presumably contains color management
  378. information, but the meaning of the data is currently unknown. If anyone
  379. has an idea about what this means, please let me know.
  380. },
  381. FORMAT => 'int16u',
  382. 0 => 'AdobeCMType',
  383. );
  384. # Adobe APP14 refs:
  385. # http://partners.adobe.com/public/developer/en/ps/sdk/5116.DCT_Filter.pdf
  386. # http://java.sun.com/j2se/1.5.0/docs/api/javax/imageio/metadata/doc-files/jpeg_metadata.html#color
  387. %Image::ExifTool::JPEG::Adobe = (
  388. PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
  389. GROUPS => { 0 => 'APP14', 1 => 'Adobe', 2 => 'Image' },
  390. NOTES => q{
  391. The "Adobe" APP14 segment stores image encoding information for DCT filters.
  392. This segment may be copied or deleted as a block using the Extra "Adobe"
  393. tag, but note that it is not deleted by default when deleting all metadata
  394. because it may affect the appearance of the image.
  395. },
  396. FORMAT => 'int16u',
  397. 0 => 'DCTEncodeVersion',
  398. 1 => {
  399. Name => 'APP14Flags0',
  400. PrintConv => {
  401. 0 => '(none)',
  402. BITMASK => {
  403. 15 => 'Encoded with Blend=1 downsampling'
  404. },
  405. },
  406. },
  407. 2 => {
  408. Name => 'APP14Flags1',
  409. PrintConv => {
  410. 0 => '(none)',
  411. BITMASK => { },
  412. },
  413. },
  414. 3 => {
  415. Name => 'ColorTransform',
  416. Format => 'int8u',
  417. PrintConv => {
  418. 0 => 'Unknown (RGB or CMYK)',
  419. 1 => 'YCbCr',
  420. 2 => 'YCCK',
  421. },
  422. },
  423. );
  424. # GraphicConverter APP15 (ref PH)
  425. %Image::ExifTool::JPEG::GraphConv = (
  426. GROUPS => { 0 => 'APP15', 1 => 'GraphConv', 2 => 'Image' },
  427. NOTES => 'APP15 is used by GraphicConverter to store JPEG quality.',
  428. 'Q' => 'Quality',
  429. );
  430. # AVI1 APP0 segment (ref http://www.schnarff.com/file-formats/bmp/BMPDIB.TXT)
  431. %Image::ExifTool::JPEG::AVI1 = (
  432. PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
  433. GROUPS => { 0 => 'APP0', 1 => 'AVI1', 2 => 'Image' },
  434. NOTES => 'This information may be found in APP0 of JPEG image data from AVI videos.',
  435. FIRST_ENTRY => 0,
  436. 0 => {
  437. Name => 'InterleavedField',
  438. PrintConv => {
  439. 0 => 'Not Interleaved',
  440. 1 => 'Odd',
  441. 2 => 'Even',
  442. },
  443. },
  444. );
  445. # Ocad APP0 segment (ref PH)
  446. %Image::ExifTool::JPEG::Ocad = (
  447. PROCESS_PROC => \&ProcessOcad,
  448. GROUPS => { 0 => 'APP0', 1 => 'Ocad', 2 => 'Image' },
  449. TAG_PREFIX => 'Ocad',
  450. FIRST_ENTRY => 0,
  451. NOTES => q{
  452. Tags extracted from the JPEG APP0 "Ocad" segment (found in Photobucket
  453. images).
  454. },
  455. Rev => {
  456. Name => 'OcadRevision',
  457. Format => 'string[6]',
  458. }
  459. );
  460. # NITF APP6 segment (National Imagery Transmission Format)
  461. # ref http://www.gwg.nga.mil/ntb/baseline/docs/n010697/bwcguide25aug98.pdf
  462. %Image::ExifTool::JPEG::NITF = (
  463. PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
  464. GROUPS => { 0 => 'APP6', 1 => 'NITF', 2 => 'Image' },
  465. NOTES => q{
  466. Information in APP6 used by the National Imagery Transmission Format. See
  467. L<http://www.gwg.nga.mil/ntb/baseline/docs/n010697/bwcguide25aug98.pdf> for
  468. the official specification.
  469. },
  470. 0 => {
  471. Name => 'NITFVersion',
  472. Format => 'int8u[2]',
  473. ValueConv => 'sprintf("%d.%.2d", split(" ",$val))',
  474. },
  475. 2 => {
  476. Name => 'ImageFormat',
  477. ValueConv => 'chr($val)',
  478. PrintConv => { B => 'IMode B' },
  479. },
  480. 3 => {
  481. Name => 'BlocksPerRow',
  482. Format => 'int16u',
  483. },
  484. 5 => {
  485. Name => 'BlocksPerColumn',
  486. Format => 'int16u',
  487. },
  488. 7 => {
  489. Name => 'ImageColor',
  490. PrintConv => { 0 => 'Monochrome' },
  491. },
  492. 8 => 'BitDepth',
  493. 9 => {
  494. Name => 'ImageClass',
  495. PrintConv => {
  496. 0 => 'General Purpose',
  497. 4 => 'Tactical Imagery',
  498. },
  499. },
  500. 10 => {
  501. Name => 'JPEGProcess',
  502. PrintConv => {
  503. 1 => 'Baseline sequential DCT, Huffman coding, 8-bit samples',
  504. 4 => 'Extended sequential DCT, Huffman coding, 12-bit samples',
  505. },
  506. },
  507. 11 => 'Quality',
  508. 12 => {
  509. Name => 'StreamColor',
  510. PrintConv => { 0 => 'Monochrome' },
  511. },
  512. 13 => 'StreamBitDepth',
  513. 14 => {
  514. Name => 'Flags',
  515. Format => 'int32u',
  516. PrintConv => 'sprintf("0x%x", $val)',
  517. },
  518. );
  519. #------------------------------------------------------------------------------
  520. # Extract information from the JPEG APP0 Ocad segment
  521. # Inputs: 0) ExifTool object ref, 1) dirInfo ref, 2) tag table ref
  522. # Returns: 1 on success
  523. sub ProcessOcad($$$)
  524. {
  525. my ($et, $dirInfo, $tagTablePtr) = @_;
  526. my $dataPt = $$dirInfo{DataPt};
  527. $et->VerboseDir('APP0 Ocad', undef, length $$dataPt);
  528. for (;;) {
  529. last unless $$dataPt =~ /\$(\w+):([^\0\$]+)/g;
  530. my ($tag, $val) = ($1, $2);
  531. $val =~ s/^\s+//; $val =~ s/\s+$//; # remove leading/trailing spaces
  532. AddTagToTable($tagTablePtr, $tag) unless $$tagTablePtr{$tag};
  533. $et->HandleTag($tagTablePtr, $tag, $val);
  534. }
  535. return 1;
  536. }
  537. #------------------------------------------------------------------------------
  538. # Extract information from the JPEG APP0 Ocad segment
  539. # Inputs: 0) ExifTool object ref, 1) dirInfo ref, 2) tag table ref
  540. # Returns: 1 on success
  541. sub ProcessJPEG_HDR($$$)
  542. {
  543. my ($et, $dirInfo, $tagTablePtr) = @_;
  544. my $dataPt = $$dirInfo{DataPt};
  545. $$dataPt =~ /~\0/g or $et->Warn('Unrecognized JPEG-HDR format'), return 0;
  546. my $pos = pos $$dataPt;
  547. my $meta = substr($$dataPt, 7, $pos-9);
  548. $et->VerboseDir('APP11 JPEG-HDR', undef, length $$dataPt);
  549. while ($meta =~ /(\w+)=([^,\s]*)/g) {
  550. my ($tag, $val) = ($1, $2);
  551. AddTagToTable($tagTablePtr, $tag) unless $$tagTablePtr{$tag};
  552. $et->HandleTag($tagTablePtr, $tag, $val);
  553. }
  554. $et->HandleTag($tagTablePtr, 'RatioImage', substr($$dataPt, $pos));
  555. return 1;
  556. }
  557. 1; # end
  558. __END__
  559. =head1 NAME
  560. Image::ExifTool::JPEG - Definitions for uncommon JPEG segments
  561. =head1 SYNOPSIS
  562. This module is used by Image::ExifTool
  563. =head1 DESCRIPTION
  564. This module contains definitions required by Image::ExifTool for some
  565. uncommon JPEG segments. For speed reasons, definitions for more common JPEG
  566. segments are included in the Image::ExifTool module itself.
  567. =head1 AUTHOR
  568. Copyright 2003-2016, Phil Harvey (phil at owl.phy.queensu.ca)
  569. This library is free software; you can redistribute it and/or modify it
  570. under the same terms as Perl itself.
  571. =head1 SEE ALSO
  572. L<Image::ExifTool::TagNames/JPEG Tags>,
  573. L<Image::ExifTool(3pm)|Image::ExifTool>
  574. =cut