MNG.pm 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684
  1. #------------------------------------------------------------------------------
  2. # File: MNG.pm
  3. #
  4. # Description: MNG and JNG meta information tags
  5. #
  6. # Revisions: 06/23/2005 - P. Harvey Created
  7. #
  8. # References: 1) http://www.libpng.org/pub/mng/
  9. #------------------------------------------------------------------------------
  10. package Image::ExifTool::MNG;
  11. use strict;
  12. use vars qw($VERSION);
  13. use Image::ExifTool qw(:DataAccess :Utils);
  14. $VERSION = '1.00';
  15. # MNG chunks
  16. %Image::ExifTool::MNG::Main = (
  17. GROUPS => { 2 => 'Image' },
  18. NOTES => q{
  19. This table contains definitions for tags found in MNG and JNG images. MNG
  20. is a superset of PNG and JNG, so a MNG image may contain any of these tags
  21. as well as any PNG tags. Conversely, only some of these tags are valid for
  22. JNG images.
  23. },
  24. BACK => {
  25. Name => 'Background',
  26. SubDirectory => { TagTable => 'Image::ExifTool::MNG::Background' },
  27. },
  28. BASI => {
  29. Name => 'BasisObject',
  30. SubDirectory => { TagTable => 'Image::ExifTool::MNG::BasisObject' },
  31. },
  32. CLIP => {
  33. Name => 'ClipObjects',
  34. SubDirectory => { TagTable => 'Image::ExifTool::MNG::ClipObjects' },
  35. },
  36. CLON => {
  37. Name => 'CloneObject',
  38. SubDirectory => { TagTable => 'Image::ExifTool::MNG::CloneObject' },
  39. },
  40. DBYK => {
  41. Name => 'DropByKeyword',
  42. Binary => 1,
  43. },
  44. DEFI => {
  45. Name => 'DefineObject',
  46. SubDirectory => { TagTable => 'Image::ExifTool::MNG::DefineObject' },
  47. },
  48. DHDR => {
  49. Name => 'DeltaPNGHeader',
  50. SubDirectory => { TagTable => 'Image::ExifTool::MNG::DeltaPNGHeader' },
  51. },
  52. DISC => {
  53. Name => 'DiscardObjects',
  54. ValueConv => 'join(" ",unpack("n*",$val))',
  55. },
  56. DROP => {
  57. Name => 'DropChunks',
  58. ValueConv => 'join(" ",$val=~/..../g)',
  59. },
  60. # ENDL
  61. eXPi => {
  62. Name => 'ExportImage',
  63. SubDirectory => { TagTable => 'Image::ExifTool::MNG::ExportImage' },
  64. },
  65. fPRI => {
  66. Name => 'FramePriority',
  67. SubDirectory => { TagTable => 'Image::ExifTool::MNG::FramePriority' },
  68. },
  69. FRAM => {
  70. Name => 'Frame',
  71. Binary => 1,
  72. },
  73. # IJNG
  74. # IPNG
  75. # JDAA (JNG)
  76. # JDAT (JNG)
  77. JHDR => { # (JNG)
  78. Name => 'JNGHeader',
  79. SubDirectory => { TagTable => 'Image::ExifTool::MNG::JNGHeader' },
  80. },
  81. # JSEP (JNG)
  82. LOOP => {
  83. Name => 'Loop',
  84. SubDirectory => { TagTable => 'Image::ExifTool::MNG::Loop' },
  85. },
  86. MAGN => {
  87. Name => 'MagnifyObject',
  88. SubDirectory => { TagTable => 'Image::ExifTool::MNG::MagnifyObject' },
  89. },
  90. # MEND
  91. MHDR => {
  92. Name => 'MNGHeader',
  93. SubDirectory => { TagTable => 'Image::ExifTool::MNG::MNGHeader' },
  94. },
  95. MOVE => {
  96. Name => 'MoveObjects',
  97. SubDirectory => { TagTable => 'Image::ExifTool::MNG::MoveObjects' },
  98. },
  99. nEED => {
  100. Name => 'ResourcesNeeded',
  101. Binary => 1,
  102. },
  103. ORDR => {
  104. Name => 'OrderingRestrictions',
  105. Binary => 1,
  106. },
  107. PAST => {
  108. Name => 'PasteImage',
  109. SubDirectory => { TagTable => 'Image::ExifTool::MNG::PasteImage' },
  110. },
  111. pHYg => {
  112. Name => 'GlobalPixelSize',
  113. SubDirectory => { TagTable => 'Image::ExifTool::PNG::PhysicalPixel' },
  114. },
  115. PPLT => {
  116. Name => 'PartialPalette',
  117. Binary => 1,
  118. },
  119. PROM => {
  120. Name => 'PromoteParent',
  121. SubDirectory => { TagTable => 'Image::ExifTool::MNG::PromoteParent' },
  122. },
  123. SAVE => {
  124. Name => 'SaveObjects',
  125. Binary => 1,
  126. },
  127. SEEK => {
  128. Name => 'SeekPoint',
  129. ValueConv => '$val=~s/\0.*//s; $val',
  130. },
  131. SHOW => {
  132. Name => 'ShowObjects',
  133. SubDirectory => { TagTable => 'Image::ExifTool::MNG::ShowObjects' },
  134. },
  135. TERM => {
  136. Name => 'TerminationAction',
  137. SubDirectory => { TagTable => 'Image::ExifTool::MNG::TerminationAction' },
  138. },
  139. );
  140. # MNG MHDR chunk
  141. %Image::ExifTool::MNG::MNGHeader = (
  142. PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
  143. GROUPS => { 2 => 'Image' },
  144. FORMAT => 'int32u',
  145. 0 => 'ImageWidth',
  146. 1 => 'ImageHeight',
  147. 2 => 'TicksPerSecond',
  148. 3 => 'NominalLayerCount',
  149. 4 => 'NominalFrameCount',
  150. 5 => 'NominalPlayTime',
  151. 6 => {
  152. Name => 'SimplicityProfile',
  153. PrintConv => 'sprintf("0x%.8x", $val)',
  154. },
  155. );
  156. # MNG BASI chunk
  157. %Image::ExifTool::MNG::BasisObject = (
  158. PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
  159. GROUPS => { 2 => 'Image' },
  160. 0 => {
  161. Name => 'ImageWidth',
  162. Format => 'int32u',
  163. },
  164. 4 => {
  165. Name => 'ImageHeight',
  166. Format => 'int32u',
  167. },
  168. 8 => 'BitDepth',
  169. 9 => {
  170. Name => 'ColorType',
  171. RawConv => '$Image::ExifTool::PNG::colorType = $val',
  172. PrintConv => {
  173. 0 => 'Grayscale',
  174. 2 => 'RGB',
  175. 3 => 'Palette',
  176. 4 => 'Grayscale with Alpha',
  177. 6 => 'RGB with Alpha',
  178. },
  179. },
  180. 10 => {
  181. Name => 'Compression',
  182. PrintConv => { 0 => 'Deflate/Inflate' },
  183. },
  184. 11 => {
  185. Name => 'Filter',
  186. PrintConv => { 0 => 'Adaptive' },
  187. },
  188. 12 => {
  189. Name => 'Interlace',
  190. PrintConv => { 0 => 'Noninterlaced', 1 => 'Adam7 Interlace' },
  191. },
  192. 13 => {
  193. Name => 'RedSample',
  194. Format => 'int32u',
  195. },
  196. 17 => {
  197. Name => 'GreenSample',
  198. Format => 'int32u',
  199. },
  200. 21 => {
  201. Name => 'BlueSample',
  202. Format => 'int32u',
  203. },
  204. 25 => {
  205. Name => 'AlphaSample',
  206. Format => 'int32u',
  207. },
  208. 26 => 'Viewable',
  209. );
  210. # MNG LOOP chunk
  211. %Image::ExifTool::MNG::Loop = (
  212. PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
  213. GROUPS => { 2 => 'Image' },
  214. 0 => 'NestLevel',
  215. 1 => {
  216. Name => 'IterationCount',
  217. Format => 'int32u',
  218. },
  219. 5 => {
  220. Name => 'TerminationCondition',
  221. PrintConv => {
  222. 0 => 'Deterministic, not cacheable',
  223. 1 => 'Decoder discretion, not cacheable',
  224. 2 => 'User discretion, not cacheable',
  225. 3 => 'External signal, not cacheable',
  226. 4 => 'Deterministic, cacheable',
  227. 5 => 'Decoder discretion, cacheable',
  228. 6 => 'User discretion, cacheable',
  229. 7 => 'External signal, cacheable',
  230. },
  231. },
  232. 6 => {
  233. Name => 'IterationMinMax',
  234. Format => 'int32u[2]',
  235. },
  236. 14 => {
  237. Name => 'SignalNumber',
  238. Format => 'int32u',
  239. },
  240. );
  241. # MNG DEFI chunk
  242. %Image::ExifTool::MNG::DefineObject = (
  243. PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
  244. GROUPS => { 2 => 'Image' },
  245. 0 => {
  246. Name => 'ObjectID',
  247. Format => 'int16u',
  248. },
  249. 2 => 'DoNotShow',
  250. 3 => 'ConcreteFlag',
  251. 4 => {
  252. Name => 'XYLocation',
  253. Format => 'int32u[2]',
  254. },
  255. 12 => {
  256. Name => 'ClippingBoundary',
  257. Format => 'int32u[4]',
  258. },
  259. );
  260. # MNG CLON chunk
  261. %Image::ExifTool::MNG::CloneObject = (
  262. PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
  263. GROUPS => { 2 => 'Image' },
  264. 0 => {
  265. Name => 'SourceID',
  266. Format => 'int16u',
  267. },
  268. 2 => {
  269. Name => 'CloneID',
  270. Format => 'int16u',
  271. },
  272. 4 => {
  273. Name => 'CloneType',
  274. PrintConv => { 0 => 'Full', 1 => 'Parital', 2 => 'Renumber object' },
  275. },
  276. 5 => 'DoNotShow',
  277. 6 => 'ConcreteFlag',
  278. 7 => {
  279. Name => 'LocalDeltaType',
  280. PrintConv => { 0 => 'Absolute', 1 => 'Relative' },
  281. },
  282. 8 => {
  283. Name => 'DeltaXY',
  284. Format => 'int32u[2]',
  285. },
  286. );
  287. # MNG PAST chunk
  288. %Image::ExifTool::MNG::PasteImage = (
  289. PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
  290. GROUPS => { 2 => 'Image' },
  291. 0 => {
  292. Name => 'DestinationID',
  293. Format => 'int16u',
  294. },
  295. 2 => {
  296. Name => 'TargetDeltaType',
  297. PrintConv => { 0 => 'Absolute', 1 => 'Relative' },
  298. },
  299. 3 => {
  300. Name => 'TargetXY',
  301. Format => 'int32u[2]',
  302. },
  303. 11 => {
  304. Name => 'SourceID',
  305. Format => 'int16u',
  306. },
  307. 13 => {
  308. Name => 'CompositionMode',
  309. PrintConv => { 0 => 'Over', 1 => 'Replace', 2 => 'Under' },
  310. },
  311. 14 => {
  312. Name => 'Orientation',
  313. PrintConv => {
  314. 0 => 'Same as source',
  315. 2 => 'Flipped left-right, then up-down',
  316. 4 => 'Flipped left-right',
  317. 6 => 'Flipped up-down',
  318. 8 => 'Tiled',
  319. },
  320. },
  321. 15 => {
  322. Name => 'OffsetOrigin',
  323. PrintConv => { 0 => 'Desination Origin', 1 => 'Target Origin' },
  324. },
  325. 16 => {
  326. Name => 'OffsetXY',
  327. Format => 'int32u[2]',
  328. },
  329. 24 => {
  330. Name => 'BoundaryOrigin',
  331. PrintConv => { 0 => 'Desination Origin', 1 => 'Target Origin' },
  332. },
  333. 25 => {
  334. Name => 'PastClippingBoundary',
  335. Format => 'int32u[4]',
  336. },
  337. );
  338. my %magMethod = (
  339. 0 => 'No Magnification',
  340. 1 => 'Pixel Replication',
  341. 2 => 'Linear Interpolation',
  342. 3 => 'Closest Pixel',
  343. 4 => 'Color Linear Interpolation and Alpha Closest Pixel',
  344. 5 => 'Color Closest Pixel and Alpha Linear Interpolation',
  345. );
  346. # MNG MAGN chunk
  347. %Image::ExifTool::MNG::MagnifyObject = (
  348. PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
  349. GROUPS => { 2 => 'Image' },
  350. 0 => {
  351. Name => 'FirstObjectID',
  352. Format => 'int16u',
  353. },
  354. 2 => {
  355. Name => 'LastObjectID',
  356. Format => 'int16u',
  357. },
  358. 4 => {
  359. Name => 'XMethod',
  360. PrintConv => \%magMethod,
  361. },
  362. 5 => {
  363. Name => 'XMag',
  364. Format => 'int16u',
  365. },
  366. 7 => {
  367. Name => 'YMag',
  368. Format => 'int16u',
  369. },
  370. 9 => {
  371. Name => 'LeftMag',
  372. Format => 'int16u',
  373. },
  374. 11 => {
  375. Name => 'RightMag',
  376. Format => 'int16u',
  377. },
  378. 13 => {
  379. Name => 'TopMag',
  380. Format => 'int16u',
  381. },
  382. 15 => {
  383. Name => 'BottomMag',
  384. Format => 'int16u',
  385. },
  386. 17 => {
  387. Name => 'YMethod',
  388. PrintConv => \%magMethod,
  389. },
  390. );
  391. # MNG TERM chunk
  392. %Image::ExifTool::MNG::TerminationAction = (
  393. PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
  394. GROUPS => { 2 => 'Image' },
  395. 0 => {
  396. Name => 'TerminationAction',
  397. PrintConv => {
  398. 0 => 'Show Last Frame',
  399. 1 => 'Display Nothing',
  400. 2 => 'Show First Frame',
  401. 3 => 'Repeat Sequence',
  402. },
  403. },
  404. 1 => {
  405. Name => 'IterationEndAction',
  406. PrintConv => {
  407. 0 => 'Show Last Frame',
  408. 1 => 'Display Nothing',
  409. 2 => 'Show First Frame',
  410. },
  411. },
  412. 2 => {
  413. Name => 'Delay',
  414. Format => 'int32u',
  415. },
  416. 6 => {
  417. Name => 'IterationMax',
  418. Format => 'int32u',
  419. },
  420. );
  421. # MNG BACK chunk
  422. %Image::ExifTool::MNG::Background = (
  423. PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
  424. GROUPS => { 2 => 'Image' },
  425. 0 => {
  426. Name => 'BackgroundColor',
  427. Format => 'int16u[3]',
  428. },
  429. 6 => {
  430. Name => 'MandatoryBackground',
  431. PrintConv => {
  432. 0 => 'Color and Image Advisory',
  433. 1 => 'Color Mandatory, Image Advisory',
  434. 2 => 'Color Advisory, Image Mandatory',
  435. 3 => 'Color and Image Mandatory',
  436. },
  437. },
  438. 7 => {
  439. Name => 'BackgroundImageID',
  440. Format => 'int16u',
  441. },
  442. 9 => {
  443. Name => 'BackgroundTiling',
  444. PrintConv => { 0 => 'No', 1 => 'Yes' },
  445. },
  446. );
  447. # MNG MOVE chunk
  448. %Image::ExifTool::MNG::MoveObjects = (
  449. PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
  450. GROUPS => { 2 => 'Image' },
  451. 0 => {
  452. Name => 'FirstObject',
  453. Format => 'int16u',
  454. },
  455. 2 => {
  456. Name => 'LastObject',
  457. Format => 'int16u',
  458. },
  459. 4 => {
  460. Name => 'DeltaType',
  461. PrintConv => { 0 => 'Absolute', 1 => 'Relative' },
  462. },
  463. 5 => {
  464. Name => 'DeltaXY',
  465. Format => 'int32u[2]',
  466. },
  467. );
  468. # MNG CLIP chunk
  469. %Image::ExifTool::MNG::ClipObjects = (
  470. PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
  471. GROUPS => { 2 => 'Image' },
  472. 0 => {
  473. Name => 'FirstObject',
  474. Format => 'int16u',
  475. },
  476. 2 => {
  477. Name => 'LastObject',
  478. Format => 'int16u',
  479. },
  480. 4 => {
  481. Name => 'DeltaType',
  482. PrintConv => { 0 => 'Absolute', 1 => 'Relative' },
  483. },
  484. 5 => {
  485. Name => 'ClipBoundary',
  486. Format => 'int32u[4]',
  487. },
  488. );
  489. # MNG SHOW chunk
  490. %Image::ExifTool::MNG::ShowObjects = (
  491. PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
  492. GROUPS => { 2 => 'Image' },
  493. 0 => {
  494. Name => 'FirstObject',
  495. Format => 'int16u',
  496. },
  497. 2 => {
  498. Name => 'LastObject',
  499. Format => 'int16u',
  500. },
  501. 4 => 'ShowMode',
  502. );
  503. # MNG eXPI chunk
  504. %Image::ExifTool::MNG::ExportImage = (
  505. PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
  506. GROUPS => { 2 => 'Image' },
  507. 0 => {
  508. Name => 'SnapshotID',
  509. Format => 'int16u',
  510. },
  511. 2 => {
  512. Name => 'SnapshotName',
  513. Format => 'string',
  514. },
  515. );
  516. # MNG fPRI chunk
  517. %Image::ExifTool::MNG::FramePriority = (
  518. PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
  519. GROUPS => { 2 => 'Image' },
  520. 0 => {
  521. Name => 'DeltaType',
  522. PrintConv => { 0 => 'Absolute', 1 => 'Relative' },
  523. },
  524. 2 => 'Priority',
  525. );
  526. # MNG DHDR chunk
  527. %Image::ExifTool::MNG::DeltaPNGHeader = (
  528. PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
  529. GROUPS => { 2 => 'Image' },
  530. 0 => {
  531. Name => 'ObjectID',
  532. Format => 'int16u',
  533. },
  534. 2 => {
  535. Name => 'ImageType',
  536. PrintConv => {
  537. 0 => 'Unspecified',
  538. 1 => 'PNG',
  539. 2 => 'JNG',
  540. },
  541. },
  542. 3 => {
  543. Name => 'DeltaType',
  544. PrintConv => {
  545. 0 => 'Full Replacement',
  546. 1 => 'Pixel Addition',
  547. 2 => 'Alpha Addition',
  548. 3 => 'Color Addition',
  549. 4 => 'Pixel Replacement',
  550. 5 => 'Alpha Replacement',
  551. 6 => 'Color Replacement',
  552. 7 => 'No Change',
  553. },
  554. },
  555. 4 => {
  556. Name => 'BlockSize',
  557. Format => 'int32u[2]',
  558. },
  559. 12 => {
  560. Name => 'BlockLocation',
  561. Format => 'int32u[2]',
  562. },
  563. );
  564. # MNG PROM chunk
  565. %Image::ExifTool::MNG::PromoteParent = (
  566. PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
  567. GROUPS => { 2 => 'Image' },
  568. 0 => 'NewColorType',
  569. 1 => 'NewBitDepth',
  570. 2 => {
  571. Name => 'FillMethod',
  572. PrintConv => { 0 => 'Bit Replication', 1 => 'Zero Fill' },
  573. },
  574. );
  575. # JNG JHDR chunk
  576. %Image::ExifTool::MNG::JNGHeader = (
  577. PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
  578. GROUPS => { 2 => 'Image' },
  579. 0 => {
  580. Name => 'ImageWidth',
  581. Format => 'int32u',
  582. },
  583. 4 => {
  584. Name => 'ImageHeight',
  585. Format => 'int32u',
  586. },
  587. 8 => {
  588. Name => 'ColorType',
  589. PrintConv => {
  590. 8 => 'Gray',
  591. 10 => 'Color',
  592. 12 => 'Gray Alpha',
  593. 14 => 'Color Alpha',
  594. },
  595. },
  596. 9 => 'BitDepth',
  597. 10 => {
  598. Name => 'Compression',
  599. PrintConv => { 8 => 'Huffman-coded baseline JPEG' },
  600. },
  601. 11 => {
  602. Name => 'Interlace',
  603. PrintConv => { 0 => 'Sequential', 8 => 'Progressive' },
  604. },
  605. 12 => 'AlphaBitDepth',
  606. 13 => {
  607. Name => 'AlphaCompression',
  608. PrintConv => {
  609. 0 => 'MNG Grayscale IDAT',
  610. 8 => 'JNG 8-bit Grayscale JDAA',
  611. },
  612. },
  613. 14 => {
  614. Name => 'AlphaFilter',
  615. PrintConv => { 0 => 'Adaptive MNG (N/A for JPEG)' },
  616. },
  617. 15 => {
  618. Name => 'AlphaInterlace',
  619. PrintConv => { 0 => 'Noninterlaced' },
  620. },
  621. );
  622. 1; # end
  623. __END__
  624. =head1 NAME
  625. Image::ExifTool::MNG - MNG and JNG meta information tags
  626. =head1 SYNOPSIS
  627. This module is used by Image::ExifTool
  628. =head1 DESCRIPTION
  629. This module contains definitions required by Image::ExifTool to read MNG
  630. (Multi-image Network Graphics) and JNG (JPEG Network Graphics) images.
  631. =head1 AUTHOR
  632. Copyright 2003-2016, Phil Harvey (phil at owl.phy.queensu.ca)
  633. This library is free software; you can redistribute it and/or modify it
  634. under the same terms as Perl itself.
  635. =head1 REFERENCES
  636. =over 4
  637. =item L<http://www.libpng.org/pub/mng/>
  638. =back
  639. =head1 SEE ALSO
  640. L<Image::ExifTool::TagNames/MNG Tags>,
  641. L<Image::ExifTool::TagNames/PNG Tags>,
  642. L<Image::ExifTool(3pm)|Image::ExifTool>
  643. =cut