/usr/share/perl5/Image/ExifTool/PICT.pm is in libimage-exiftool-perl 10.10-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 | #------------------------------------------------------------------------------
# File: PICT.pm
#
# Description: Read PICT meta information
#
# Revisions: 10/10/2005 - P. Harvey Created
#
# Notes: Extraction of PICT opcodes is still experimental
#
# - size difference in PixPat color table?? (imagemagick reads only 1 long per entry)
# - other differences in the way imagemagick reads 16-bit images
#
# References: 1) http://developer.apple.com/documentation/mac/QuickDraw/QuickDraw-2.html
# 2) http://developer.apple.com/documentation/QuickTime/INMAC/QT/iqImageCompMgr.a.htm
#------------------------------------------------------------------------------
package Image::ExifTool::PICT;
use strict;
use vars qw($VERSION);
use Image::ExifTool qw(:DataAccess :Utils);
$VERSION = '1.05';
sub ReadPictValue($$$;$);
my ($vers, $extended); # PICT version number, and extended flag
my ($verbose, $out, $indent); # used in verbose mode
# ranges of reserved opcodes.
# opcodes at the start of each range must be defined in the tag table
my @reserved = (
0x0017 => 0x0019, 0x0024 => 0x0027, 0x0035 => 0x0037, 0x003d => 0x003f,
0x0045 => 0x0047, 0x004d => 0x004f, 0x0055 => 0x0057, 0x005d => 0x005f,
0x0065 => 0x0067, 0x006d => 0x006f, 0x0075 => 0x0077, 0x007d => 0x007f,
0x0085 => 0x0087, 0x008d => 0x008f, 0x0092 => 0x0097, 0x00a2 => 0x00af,
0x00b0 => 0x00cf, 0x00d0 => 0x00fe, 0x0100 => 0x01ff, 0x0300 => 0x0bfe,
0x0c01 => 0x7eff, 0x7f00 => 0x7fff, 0x8000 => 0x80ff, 0x8100 => 0x81ff,
0x8201 => 0xffff,
);
# Apple data structures in PICT images
my %structs = (
Arc => [
rect => 'Rect',
startAng => 'int16s',
arcAng => 'int16s',
],
BitMap => [
# (no baseAddr)
rowBytes => 'int16u',
bounds => 'Rect',
],
# BitsRect data for PICT version 1
BitsRect1 => [
bitMap => 'BitMap',
srcRect => 'Rect',
dstRect => 'Rect',
mode => 'int16u',
dataSize => 'int16u',
bitData => 'binary[$val{dataSize}]',
],
# BitsRect data for PICT version 2
BitsRect2 => [
pixMap => 'PixMap',
colorTable => 'ColorTable',
srcRect => 'Rect',
dstRect => 'Rect',
mode => 'int16u',
pixData => \ 'GetPixData($val{pixMap}, $raf)',
],
# BitsRgn data for PICT version 1
BitsRgn1 => [
bitMap => 'BitMap',
srcRect => 'Rect',
dstRect => 'Rect',
mode => 'int16u',
maskRgn => 'Rgn',
dataSize => 'int16u',
bitData => 'binary[$val{dataSize}]',
],
# BitsRgn data for PICT version 2
BitsRgn2 => [
pixMap => 'PixMap',
colorTable => 'ColorTable',
srcRect => 'Rect',
dstRect => 'Rect',
mode => 'int16u',
maskRgn => 'Rgn',
pixData => \ 'GetPixData($val{pixMap}, $raf)',
],
ColorSpec => [
value => 'int16u',
rgb => 'RGBColor',
],
ColorTable => [
ctSeed => 'int32u',
ctFlags => 'int16u',
ctSize => 'int16u',
ctTable => 'ColorSpec[$val{ctSize}+1]',
],
# http://developer.apple.com/documentation/QuickTime/INMAC/QT/iqImageCompMgr.a.htm
CompressedQuickTime => [
size => 'int32u', # size NOT including size word
version => 'int16u',
matrix => 'int32u[9]',
matteSize => 'int32u',
matteRect => 'Rect',
mode => 'int16u',
srcRect => 'Rect',
accuracy => 'int32u',
maskSize => 'int32u',
matteDescr => 'Int32uData[$val{matteSize} ? 1 : 0]',
matteData => 'int8u[$val{matteSize}]',
maskRgn => 'int8u[$val{maskSize}]',
imageDescr => 'ImageDescription',
# size should be $val{imageDescr}->{dataSize}, but this is unreliable
imageData => q{binary[$val{size} - 68 - $val{maskSize} - $val{imageDescr}->{size} -
($val{matteSize} ? $val{mattSize} + $val{matteDescr}->{size} : 0)]
},
],
DirectBitsRect => [
baseAddr => 'int32u',
pixMap => 'PixMap',
srcRect => 'Rect',
dstRect => 'Rect',
mode => 'int16u',
pixData => \ 'GetPixData($val{pixMap}, $raf)',
],
DirectBitsRgn => [
baseAddr => 'int32u',
pixMap => 'PixMap',
srcRect => 'Rect',
dstRect => 'Rect',
mode => 'int16u',
maskRgn => 'Rgn',
pixData => \ 'GetPixData($val{pixMap}, $raf)',
],
# http://developer.apple.com/technotes/qd/qd_01.html
FontName => [
size => 'int16u', # size NOT including size word
oldFontID => 'int16u',
nameLen => 'int8u',
fontName => 'string[$val{nameLen}]',
padding => 'binary[$val{size} - $val{nameLen} - 3]',
],
# http://developer.apple.com/documentation/QuickTime/APIREF/imagedescription.htm
ImageDescription => [
size => 'int32u', # size INCLUDING size word
cType => 'string[4]',
res1 => 'int32u',
res2 => 'int16u',
dataRefIndex => 'int16u',
version => 'int16u',
revision => 'int16u',
vendor => 'string[4]',
temporalQuality => 'int32u',
quality => 'int32u',
width => 'int16u',
height => 'int16u',
hRes => 'fixed32u',
vRes => 'fixed32u',
dataSize => 'int32u',
frameCount => 'int16u',
nameLen => 'int8u',
compressor => 'string[31]',
depth => 'int16u',
clutID => 'int16u',
clutData => 'binary[$val{size}-86]',
],
Int8uText => [
val => 'int8u',
count => 'int8u',
text => 'string[$val{count}]',
],
Int8u2Text => [
val => 'int8u[2]',
count => 'int8u',
text => 'string[$val{count}]',
],
Int16Data => [
size => 'int16u', # size NOT including size word
data => 'int8u[$val{size}]',
],
Int32uData => [
size => 'int32u', # size NOT including size word
data => 'int8u[$val{size}]',
],
LongComment => [
kind => 'int16u',
size => 'int16u', # size of data only
data => 'binary[$val{size}]',
],
PixMap => [
# Note: does not contain baseAddr
# (except for DirectBits opcodes in which it is loaded separately)
rowBytes => 'int16u',
bounds => 'Rect',
pmVersion => 'int16u',
packType => 'int16u',
packSize => 'int32u',
hRes => 'fixed32s',
vRes => 'fixed32s',
pixelType => 'int16u',
pixelSize => 'int16u',
cmpCount => 'int16u',
cmpSize => 'int16u',
planeBytes => 'int32u',
pmTable => 'int32u',
pmReserved => 'int32u',
],
PixPat => [
patType => 'int16u', # 1 = non-dithered, 2 = dithered
pat1Data => 'int8u[8]',
# dithered PixPat has RGB entry
RGB => 'RGBColor[$val{patType} == 2 ? 1 : 0]',
# non-dithered PixPat has other stuff instead
nonDithered=> 'PixPatNonDithered[$val{patType} == 2 ? 0 : 1]',
],
PixPatNonDithered => [
pixMap => 'PixMap',
colorTable => 'ColorTable',
pixData => \ 'GetPixData($val{pixMap}, $raf)',
],
Point => [
v => 'int16s',
h => 'int16s',
],
PointText => [
txLoc => 'Point',
count => 'int8u',
text => 'string[$val{count}]',
],
Polygon => [
polySize => 'int16u',
polyBBox => 'Rect',
polyPoints => 'int16u[($val{polySize}-10)/2]',
],
Rect => [
topLeft => 'Point',
botRight => 'Point',
],
RGBColor => [
red => 'int16u',
green => 'int16u',
blue => 'int16u',
],
Rgn => [
rgnSize => 'int16u',
rgnBBox => 'Rect',
data => 'int8u[$val{rgnSize}-10]',
],
ShortLine => [
pnLoc => 'Point',
dh => 'int8s',
dv => 'int8s',
],
# http://developer.apple.com/documentation/QuickTime/INMAC/QT/iqImageCompMgr.a.htm
UncompressedQuickTime => [
size => 'int32u', # size NOT including size word
version => 'int16u',
matrix => 'int32u[9]',
matteSize => 'int32u',
matteRect => 'Rect',
matteDescr => 'Int32uData[$val{matteSize} ? 1 : 0]',
matteData => 'binary[$val{matteSize}]',
subOpcodeData => q{
binary[ $val{size} - 50 -
($val{matteSize} ? $val{mattSize} + $val{matteDescr}->{size} : 0)]
},
],
);
# PICT image opcodes
%Image::ExifTool::PICT::Main = (
VARS => { NO_LOOKUP => 1 }, # omit tags from lookup
NOTES => q{
The PICT format contains no true meta information, except for the possible
exception of the LongComment opcode. By default, only ImageWidth,
ImageHeight and X/YResolution are extracted from a PICT image. Tags in the
following table represent image opcodes. Extraction of these tags is
experimental, and is only enabled with the Verbose or Unknown options.
},
0x0000 => {
Name => 'Nop',
Description => 'No Operation',
Format => 'null',
},
0x0001 => {
Name => 'ClipRgn',
Description => 'Clipping Region',
Format => 'Rgn',
},
0x0002 => {
Name => 'BkPat',
Description => 'Background Pattern',
Format => 'int8u[8]',
},
0x0003 => {
Name => 'TxFont',
Description => 'Font Number',
Format => 'int16u',
},
0x0004 => {
Name => 'TxFace',
Description => 'Text Font Style',
Format => 'int8u',
},
0x0005 => {
Name => 'TxMode',
Description => 'Text Source Mode',
Format => 'int16u',
},
0x0006 => {
Name => 'SpExtra',
Description => 'Extra Space',
Format => 'fixed32s',
},
0x0007 => {
Name => 'PnSize',
Description => 'Pen Size',
Format => 'Point',
},
0x0008 => {
Name => 'PnMode',
Description => 'Pen Mode',
Format => 'int16u',
},
0x0009 => {
Name => 'PnPat',
Description => 'Pen Pattern',
Format => 'int8u[8]',
},
0x000a => {
Name => 'FillPat',
Description => 'Fill Pattern',
Format => 'int8u[8]',
},
0x000b => {
Name => 'OvSize',
Description => 'Oval Size',
Format => 'Point',
},
0x000c => {
Name => 'Origin',
Format => 'Point',
},
0x000d => {
Name => 'TxSize',
Description => 'Text Size',
Format => 'int16u',
},
0x000e => {
Name => 'FgColor',
Description => 'Foreground Color',
Format => 'int32u',
},
0x000f => {
Name => 'BkColor',
Description => 'Background Color',
Format => 'int32u',
},
0x0010 => {
Name => 'TxRatio',
Description => 'Text Ratio',
Format => 'Rect',
},
0x0011 => {
Name => 'VersionOp',
Description => 'Version',
Format => 'int8u',
},
0x0012 => {
Name => 'BkPixPat',
Description => 'Background Pixel Pattern',
Format => 'PixPat',
},
0x0013 => {
Name => 'PnPixPat',
Description => 'Pen Pixel Pattern',
Format => 'PixPat',
},
0x0014 => {
Name => 'FillPixPat',
Description => 'Fill Pixel Pattern',
Format => 'PixPat',
},
0x0015 => {
Name => 'PnLocHFrac',
Description => 'Fractional Pen Position',
Format => 'int16u',
},
0x0016 => {
Name => 'ChExtra',
Description => 'Added Width for NonSpace Characters',
Format => 'int16u',
},
0x0017 => {
Name => 'Reserved',
Format => 'Unknown',
},
0x001a => {
Name => 'RGBFgCol',
Description => 'Foreground Color',
Format => 'RGBColor',
},
0x001b => {
Name => 'RGBBkCol',
Description => 'Background Color',
Format => 'RGBColor',
},
0x001c => {
Name => 'HiliteMode',
Description => 'Highlight Mode Flag',
Format => 'null',
},
0x001d => {
Name => 'HiliteColor',
Description => 'Highlight Color',
Format => 'RGBColor',
},
0x001e => {
Name => 'DefHilite',
Description => 'Use Default Highlight Color',
Format => 'null',
},
0x001f => {
Name => 'OpColor',
Format => 'RGBColor',
},
0x0020 => {
Name => 'Line',
Format => 'Rect',
},
0x0021 => {
Name => 'LineFrom',
Format => 'Point',
},
0x0022 => {
Name => 'ShortLine',
Format => 'ShortLine',
},
0x0023 => {
Name => 'ShortLineFrom',
Format => 'int8u[2]',
},
0x0024 => {
Name => 'Reserved',
Format => 'Int16Data',
},
0x0028 => {
Name => 'LongText',
Format => 'PointText',
},
0x0029 => {
Name => 'DHText',
Format => 'Int8uText',
},
0x002a => {
Name => 'DVText',
Format => 'Int8uText',
},
0x002b => {
Name => 'DHDVText',
Format => 'Int8u2Text',
},
0x002c => {
Name => 'FontName',
Format => 'FontName',
},
0x002d => {
Name => 'LineJustify',
Format => 'int8u[10]',
},
0x002e => {
Name => 'GlyphState',
Format => 'int8u[8]',
},
0x002f => {
Name => 'Reserved',
Format => 'Int16Data',
},
0x0030 => {
Name => 'FrameRect',
Format => 'Rect',
},
0x0031 => {
Name => 'PaintRect',
Format => 'Rect',
},
0x0032 => {
Name => 'EraseRect',
Format => 'Rect',
},
0x0033 => {
Name => 'InvertRect',
Format => 'Rect',
},
0x0034 => {
Name => 'FillRect',
Format => 'Rect',
},
0x0035 => {
Name => 'Reserved',
Format => 'Rect',
},
0x0038 => {
Name => 'FrameSameRect',
Format => 'null',
},
0x0039 => {
Name => 'PaintSameRect',
Format => 'null',
},
0x003a => {
Name => 'EraseSameRect',
Format => 'null',
},
0x003b => {
Name => 'InvertSameRect',
Format => 'null',
},
0x003c => {
Name => 'FillSameRect',
Format => 'null',
},
0x003d => {
Name => 'Reserved',
Format => 'null',
},
0x0040 => {
Name => 'FrameRRect',
Format => 'Rect',
},
0x0041 => {
Name => 'PaintRRect',
Format => 'Rect',
},
0x0042 => {
Name => 'EraseRRect',
Format => 'Rect',
},
0x0043 => {
Name => 'InvertRRect',
Format => 'Rect',
},
0x0044 => {
Name => 'FillRRect',
Format => 'Rect',
},
0x0045 => {
Name => 'Reserved',
Format => 'Rect',
},
0x0048 => {
Name => 'FrameSameRRect',
Format => 'null',
},
0x0049 => {
Name => 'PaintSameRRect',
Format => 'null',
},
0x004a => {
Name => 'EraseSameRRect',
Format => 'null',
},
0x004b => {
Name => 'InvertSameRRect',
Format => 'null',
},
0x004c => {
Name => 'FillSameRRect',
Format => 'null',
},
0x004d => {
Name => 'Reserved',
Format => 'null',
},
0x0050 => {
Name => 'FrameOval',
Format => 'Rect',
},
0x0051 => {
Name => 'PaintOval',
Format => 'Rect',
},
0x0052 => {
Name => 'EraseOval',
Format => 'Rect',
},
0x0053 => {
Name => 'InvertOval',
Format => 'Rect',
},
0x0054 => {
Name => 'FillOval',
Format => 'Rect',
},
0x0055 => {
Name => 'Reserved',
Format => 'Rect',
},
0x0058 => {
Name => 'FrameSameOval',
Format => 'null',
},
0x0059 => {
Name => 'PaintSameOval',
Format => 'null',
},
0x005a => {
Name => 'EraseSameOval',
Format => 'null',
},
0x005b => {
Name => 'InvertSameOval',
Format => 'null',
},
0x005c => {
Name => 'FillSameOval',
Format => 'null',
},
0x005d => {
Name => 'Reserved',
Format => 'null',
},
0x0060 => {
Name => 'FrameArc',
Format => 'Arc',
},
0x0061 => {
Name => 'PaintArc',
Format => 'Arc',
},
0x0062 => {
Name => 'EraseArc',
Format => 'Arc',
},
0x0063 => {
Name => 'InvertArc',
Format => 'Arc',
},
0x0064 => {
Name => 'FillArc',
Format => 'Arc',
},
0x0065 => {
Name => 'Reserved',
Format => 'Arc',
},
0x0068 => {
Name => 'FrameSameArc',
Format => 'Point',
},
0x0069 => {
Name => 'PaintSameArc',
Format => 'Point',
},
0x006a => {
Name => 'EraseSameArc',
Format => 'Point',
},
0x006b => {
Name => 'InvertSameArc',
Format => 'Point',
},
0x006c => {
Name => 'FillSameArc',
Format => 'Point',
},
0x006d => {
Name => 'Reserved',
Format => 'int32u',
},
0x0070 => {
Name => 'FramePoly',
Format => 'Polygon',
},
0x0071 => {
Name => 'PaintPoly',
Format => 'Polygon',
},
0x0072 => {
Name => 'ErasePoly',
Format => 'Polygon',
},
0x0073 => {
Name => 'InvertPoly',
Format => 'Polygon',
},
0x0074 => {
Name => 'FillPoly',
Format => 'Polygon',
},
0x0075 => {
Name => 'Reserved',
Format => 'Polygon',
},
0x0078 => {
Name => 'FrameSamePoly',
Format => 'null',
},
0x0079 => {
Name => 'PaintSamePoly',
Format => 'null',
},
0x007a => {
Name => 'EraseSamePoly',
Format => 'null',
},
0x007b => {
Name => 'InvertSamePoly',
Format => 'null',
},
0x007c => {
Name => 'FillSamePoly',
Format => 'null',
},
0x007d => {
Name => 'Reserved',
Format => 'null',
},
0x0080 => {
Name => 'FrameRgn',
Format => 'Rgn',
},
0x0081 => {
Name => 'PaintRgn',
Format => 'Rgn',
},
0x0082 => {
Name => 'EraseRgn',
Format => 'Rgn',
},
0x0083 => {
Name => 'InvertRgn',
Format => 'Rgn',
},
0x0084 => {
Name => 'FillRgn',
Format => 'Rgn',
},
0x0085 => {
Name => 'Reserved',
Format => 'Rgn',
},
0x0088 => {
Name => 'FrameSameRgn',
Format => 'null',
},
0x0089 => {
Name => 'PaintSameRgn',
Format => 'null',
},
0x008a => {
Name => 'EraseSameRgn',
Format => 'null',
},
0x008b => {
Name => 'InvertSameRgn',
Format => 'null',
},
0x008c => {
Name => 'FillSameRgn',
Format => 'null',
},
0x008d => {
Name => 'Reserved',
Format => 'null',
},
0x0090 => {
Name => 'BitsRect',
Description => 'CopyBits with Clipped Rectangle',
Format => 'BitsRect#', # (version-dependent format)
},
0x0091 => {
Name => 'BitsRgn',
Description => 'CopyBits with Clipped Region',
Format => 'BitsRgn#', # (version-dependent format)
},
0x0092 => {
Name => 'Reserved',
Format => 'Int16Data',
},
0x0098 => {
Name => 'PackBitsRect',
Description => 'Packed CopyBits with Clipped Rectangle',
Format => 'BitsRect#', # (version-dependent format)
},
0x0099 => {
Name => 'PackBitsRgn',
Description => 'Packed CopyBits with Clipped Region',
Format => 'BitsRgn#', # (version-dependent format)
},
0x009a => {
Name => 'DirectBitsRect',
Format => 'DirectBitsRect',
},
0x009b => {
Name => 'DirectBitsRgn',
Format => 'DirectBitsRgn',
},
0x009c => {
Name => 'Reserved',
Format => 'Int16Data',
},
0x009d => {
Name => 'Reserved',
Format => 'Int16Data',
},
0x009e => {
Name => 'Reserved',
Format => 'Int16Data',
},
0x009f => {
Name => 'Reserved',
Format => 'Int16Data',
},
0x00a0 => {
Name => 'ShortComment',
Format => 'int16u',
},
0x00a1 => [
# this list for documentation only [currently not extracted]
{
# (not actually a full Photohop IRB record it appears, but it does start
# with '8BIM', and does contain resolution information at offset 0x0a)
Name => 'LongComment', # kind = 498
Format => 'LongComment',
SubDirectory => { TagTable => 'Image::ExifTool::Photoshop::Main' },
},
{
Name => 'LongComment', # kind = 224
Format => 'LongComment',
SubDirectory => {
TagTable => 'Image::ExifTool::ICC_Profile::Main',
Start => '$valuePtr + 4',
},
},
],
0x00a2 => {
Name => 'Reserved',
Format => 'Int16Data',
},
0x00b0 => {
Name => 'Reserved',
Format => 'null',
},
0x00d0 => {
Name => 'Reserved',
Format => 'Int32uData',
},
0x00ff => {
Name => 'OpEndPic',
Description => 'End of picture',
Format => 'null', # 2 for version 2!?
},
0x0100 => {
Name => 'Reserved',
Format => 'int16u',
},
0x0200 => {
Name => 'Reserved',
Format => 'int32u',
},
0x02ff => {
Name => 'Version',
Description => 'Version number of picture',
Format => 'int16u',
},
0x0300 => {
Name => 'Reserved',
Format => 'int16u',
},
0x0bff => {
Name => 'Reserved',
Format => 'int8u[22]',
},
0x0c00 => {
Name => 'HeaderOp',
Format => 'int16u[12]',
},
0x0c01 => {
Name => 'Reserved',
Format => 'int8u[24]',
},
0x7f00 => {
Name => 'Reserved',
Format => 'int8u[254]',
},
0x8000 => {
Name => 'Reserved',
Format => 'null',
},
0x8100 => {
Name => 'Reserved',
Format => 'Int32uData',
},
0x8200 => {
Name => 'CompressedQuickTime',
Format => 'CompressedQuickTime',
},
0x8201 => {
Name => 'UncompressedQuickTime',
Format => 'Int32uData',
},
0xffff => {
Name => 'Reserved',
Format => 'Int32uData',
},
);
# picture comment 'kind' codes
# http://developer.apple.com/technotes/qd/qd_10.html
my %commentKind = (
150 => 'TextBegin',
151 => 'TextEnd',
152 => 'StringBegin',
153 => 'StringEnd',
154 => 'TextCenter',
155 => 'LineLayoutOff',
156 => 'LineLayoutOn',
157 => 'ClientLineLayout',
160 => 'PolyBegin',
161 => 'PolyEnd',
163 => 'PolyIgnore',
164 => 'PolySmooth',
165 => 'PolyClose',
180 => 'DashedLine',
181 => 'DashedStop',
182 => 'SetLineWidth',
190 => 'PostScriptBegin',
191 => 'PostScriptEnd',
192 => 'PostScriptHandle',
193 => 'PostScriptFile',
194 => 'TextIsPostScript',
195 => 'ResourcePS',
196 => 'PSBeginNoSave',
197 => 'SetGrayLevel',
200 => 'RotateBegin',
201 => 'RotateEnd',
202 => 'RotateCenter',
210 => 'FormsPrinting',
211 => 'EndFormsPrinting',
224 => '<ICC Profile>',
498 => '<Photoshop Data>',
1000 => 'BitMapThinningOff',
1001 => 'BitMapThinningOn',
);
#------------------------------------------------------------------------------
# Get PixData data
# Inputs: 0) reference to PixMap, 1) RAF reference
# Returns: reference to PixData or undef on error
sub GetPixData($$)
{
my ($pixMap, $raf) = @_;
my $packType = $pixMap->{packType};
my $rowBytes = $pixMap->{rowBytes} & 0x3fff; # remove flags bits
my $height = $pixMap->{bounds}->{botRight}->{v} -
$pixMap->{bounds}->{topLeft}->{v};
my ($data, $size, $buff, $i);
if ($packType == 1 or $rowBytes < 8) { # unpacked data
$size = $rowBytes * $height;
return undef unless $raf->Read($data, $size) == $size;
} elsif ($packType == 2) { # pad byte dropped
$size = int($rowBytes * $height * 3 / 4 + 0.5);
return undef unless $raf->Read($data, $size) == $size;
} else {
$data = '';
for ($i=0; $i<$height; ++$i) {
if ($rowBytes > 250) {
$raf->Read($buff,2) == 2 or return undef;
$size = unpack('n',$buff);
} else {
$raf->Read($buff,1) == 1 or return undef;
$size = unpack('C',$buff);
}
$data .= $buff;
$raf->Read($buff,$size) == $size or return undef;
$data .= $buff;
}
}
return \$data;
}
#------------------------------------------------------------------------------
# Read value from PICT file
# Inputs: 0) RAF reference, 1) tag, 2) format, 3) optional count
# Returns: value, reference to structure hash, or undef on error
sub ReadPictValue($$$;$)
{
my ($raf, $tag, $format, $count) = @_;
return undef unless $format;
unless (defined $count) {
if ($format =~ /(.+)\[(.+)\]/s) {
$format = $1;
$count = $2;
} else {
$count = 1; # count undefined: assume 1
}
}
my $cntStr = ($count == 1) ? '' : "[$count]";
# no size if count is 0
my $size = $count ? Image::ExifTool::FormatSize($format) : 0;
if (defined $size or $format eq 'null') {
my $val;
if ($size) {
my $buff;
$size *= $count;
$raf->Read($buff, $size) == $size or return undef;
$val = ReadValue(\$buff, 0, $format, $count, $size);
} else {
$val = '';
}
if ($verbose) {
print $out "${indent}$tag ($format$cntStr)";
if ($size) {
if (not defined $val) {
print $out " = <undef>\n";
} elsif ($format eq 'binary') {
print $out " = <binary data>\n";
if ($verbose > 2) {
my %parms = ( Out => $out );
$parms{MaxLen} = 96 if $verbose < 4;
HexDump(\$val, undef, %parms);
}
} else {
print $out " = $val\n";
}
} else {
print $out "\n";
}
}
return \$val if $format eq 'binary' and defined $val;
return $val;
}
$verbose and print $out "${indent}$tag ($format$cntStr):\n";
my $struct = $structs{$format} or return undef;
my ($c, @vals);
for ($c=0; $c<$count; ++$c) {
my (%val, $i);
for ($i=0; ; $i+=2) {
my $tag = $$struct[$i] or last;
my $fmt = $$struct[$i+1];
my ($cnt, $val);
$indent .= ' ';
if (ref $fmt) {
$val = eval $$fmt;
$@ and warn $@;
if ($verbose and defined $val) {
printf $out "${indent}$tag (binary[%d]) = <binary data>\n",length($$val);
if ($verbose > 2) {
my %parms = ( Out => $out );
$parms{MaxLen} = 96 if $verbose < 4;
HexDump($val, undef, %parms);
}
}
} elsif ($fmt =~ /(.+)\[(.+)\]/s) {
$fmt = $1;
$cnt = eval $2;
$@ and warn $@;
$val = ReadPictValue($raf, $tag, $fmt, $cnt);
} else {
$val = ReadPictValue($raf, $tag, $fmt);
}
$indent = substr($indent, 2);
return undef unless defined $val;
$val{$tag} = $val;
}
return \%val if $count == 1;
push @vals, \%val;
}
return \@vals;
}
#------------------------------------------------------------------------------
# Extract meta information from a PICT image
# Inputs: 0) ExifTool object reference, 1) dirInfo reference
# Returns: 1 on success, 0 if this wasn't a valid PICT image
sub ProcessPICT($$)
{
my ($et, $dirInfo) = @_;
my $raf = $$dirInfo{RAF};
$verbose = $et->Options('Verbose');
$out = $et->Options('TextOut');
$indent = '';
my ($buff, $tried, @hdr, $op, $hRes, $vRes);
# recognize both PICT files and PICT resources (PICT files have a
# 512-byte header that we ignore, but PICT resources do not)
for (;;) {
$raf->Read($buff, 12) == 12 or return 0;
@hdr = unpack('x2n5', $buff);
$op = pop @hdr;
# check for PICT version 1 format
if ($op eq 0x1101) {
$vers = 1;
undef $extended;
last;
}
# check for PICT version 2 format
if ($op eq 0x0011) {
$raf->Read($buff, 28) == 28 or return 0;
if ($buff =~ /^\x02\xff\x0c\x00\xff\xff/) {
$vers = 2;
undef $extended;
last;
}
if ($buff =~ /^\x02\xff\x0c\x00\xff\xfe/) {
$vers = 2;
$extended = 1;
($hRes, $vRes) = unpack('x8N2', $buff);
last;
}
}
return 0 if $tried;
$tried = 1;
$raf->Seek(512, 0) or return 0;
}
# make the bounding rect signed
foreach (@hdr) {
$_ >= 0x8000 and $_ -= 0x10000;
}
my $w = $hdr[3] - $hdr[1];
my $h = $hdr[2] - $hdr[0];
return 0 unless $w > 0 and $h > 0;
SetByteOrder('MM');
if ($extended) {
# extended version 2 pictures contain resolution information
# and image bounds are in 72-dpi equivalent units
$hRes = GetFixed32s(\$buff, 8);
$vRes = GetFixed32s(\$buff, 12);
return 0 unless $hRes and $vRes;
$w = int($w * $hRes / 72 + 0.5);
$h = int($h * $vRes / 72 + 0.5);
}
$et->SetFileType();
$et->FoundTag('ImageWidth', $w);
$et->FoundTag('ImageHeight', $h);
$et->FoundTag('XResolution', $hRes) if $hRes;
$et->FoundTag('YResolution', $vRes) if $vRes;
# don't extract image opcodes unless verbose
return 1 unless $verbose or $et->Options('Unknown');
$verbose and printf $out "PICT version $vers%s\n", $extended ? ' extended' : '';
my $tagTablePtr = GetTagTable('Image::ExifTool::PICT::Main');
my $success;
for (;;) {
if ($vers == 1) {
$raf->Read($buff, 1) == 1 or last;
$op = ord($buff);
} else {
# must start version 2 opcode on an even byte
$raf->Read($buff, 1) if $raf->Tell() & 0x01;
$raf->Read($buff, 2) == 2 or last;
$op = unpack('n', $buff);
}
my $tagInfo = $et->GetTagInfo($tagTablePtr, $op);
unless ($tagInfo) {
my $i;
# search for reserved tag info
for ($i=0; $i<scalar(@reserved); $i+=2) {
next unless $op >= $reserved[$i];
last if $op > $reserved[$i+1];
$tagInfo = $et->GetTagInfo($tagTablePtr, $reserved[$i]);
last;
}
last unless $tagInfo;
}
if ($op eq 0xff) {
$verbose and print $out "End of picture\n";
$success = 1;
last;
}
my $format = $$tagInfo{Format};
unless ($format) {
$et->Warn("Missing format for $$tagInfo{Name}");
last;
}
# replace version number for version-dependent formats
$format =~ s/#$/$vers/;
my $wid = $vers * 2;
$verbose and printf $out "Tag 0x%.${wid}x, ", $op;
my $val = ReadPictValue($raf, $$tagInfo{Name}, $format);
unless (defined $val) {
$et->Warn("Error reading $$tagInfo{Name} information");
last;
}
if (ref $val eq 'HASH') {
# extract JPEG image from CompressedQuickTime imageData
if ($$tagInfo{Name} eq 'CompressedQuickTime' and
ref $val->{imageDescr} eq 'HASH' and
$val->{imageDescr}->{compressor} and
$val->{imageDescr}->{compressor} eq 'Photo - JPEG' and
ref $val->{imageData} eq 'SCALAR' and
$et->ValidateImage($val->{imageData}, 'PreviewImage'))
{
$et->FoundTag('PreviewImage', $val->{imageData});
}
} else {
# $et->FoundTag($tagInfo, $val);
}
}
$success or $et->Warn('End of picture not found');
return 1;
}
1; # end
__END__
=head1 NAME
Image::ExifTool::PICT - Read PICT meta information
=head1 SYNOPSIS
This module is used by Image::ExifTool
=head1 DESCRIPTION
This module contains routines required by Image::ExifTool to read PICT
(Apple Picture) images.
=head1 NOTES
Extraction of PICT opcodes is experimental, and is only enabled with the
Verbose or the Unknown option.
=head1 AUTHOR
Copyright 2003-2016, Phil Harvey (phil at owl.phy.queensu.ca)
This library is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
=head1 REFERENCES
=over 4
=item L<http://developer.apple.com/documentation/mac/QuickDraw/QuickDraw-2.html>
=item L<http://developer.apple.com/documentation/QuickTime/INMAC/QT/iqImageCompMgr.a.htm>
=back
=head1 SEE ALSO
L<Image::ExifTool::TagNames/PICT Tags>,
L<Image::ExifTool(3pm)|Image::ExifTool>
=cut
|