- Timestamp:
- 2021-02-26T19:39:51+13:00 (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone2/perllib/cpan/Image/ExifTool/ICC_Profile.pm
r24107 r34921 11 11 # 4) http://www.color.org/privatetag2007-01.pdf 12 12 # 5) http://www.color.org/icc_specs2.xalter (approved revisions, 2010-07-16) 13 # 6) Eef Vreeland private communication 13 14 # 14 15 # Notes: The ICC profile information is different: the format of each … … 24 25 use Image::ExifTool qw(:DataAccess :Utils); 25 26 26 $VERSION = '1. 22';27 $VERSION = '1.36'; 27 28 28 29 sub ProcessICC($$); … … 53 54 nkpf => 'Nikon Input Device Profile (NON-STANDARD!)', # (written by Nikon utilities) 54 55 ); 56 my %manuSig = ( #6 57 'NONE' => 'none', 58 'none' => 'none', #PH 59 '' => '', #PH 60 '4d2p' => 'Erdt Systems GmbH & Co KG', 61 'AAMA' => 'Aamazing Technologies, Inc.', 62 'ACER' => 'Acer Peripherals', 63 'ACLT' => 'Acolyte Color Research', 64 'ACTI' => 'Actix Systems, Inc.', 65 'ADAR' => 'Adara Technology, Inc.', 66 'ADBE' => 'Adobe Systems Inc.', 67 'ADI ' => 'ADI Systems, Inc.', 68 'AGFA' => 'Agfa Graphics N.V.', 69 'ALMD' => 'Alps Electric USA, Inc.', 70 'ALPS' => 'Alps Electric USA, Inc.', 71 'ALWN' => 'Alwan Color Expertise', 72 'AMTI' => 'Amiable Technologies, Inc.', 73 'AOC ' => 'AOC International (U.S.A), Ltd.', 74 'APAG' => 'Apago', 75 'APPL' => 'Apple Computer Inc.', 76 'appl' => 'Apple Computer Inc.', 77 'AST ' => 'AST', 78 'AT&T' => 'AT&T Computer Systems', 79 'BAEL' => 'BARBIERI electronic', 80 'berg' => 'bergdesign incorporated', 81 'bICC' => 'basICColor GmbH', 82 'BRCO' => 'Barco NV', 83 'BRKP' => 'Breakpoint Pty Limited', 84 'BROT' => 'Brother Industries, LTD', 85 'BULL' => 'Bull', 86 'BUS ' => 'Bus Computer Systems', 87 'C-IT' => 'C-Itoh', 88 'CAMR' => 'Intel Corporation', 89 'CANO' => 'Canon, Inc. (Canon Development Americas, Inc.)', 90 'CARR' => 'Carroll Touch', 91 'CASI' => 'Casio Computer Co., Ltd.', 92 'CBUS' => 'Colorbus PL', 93 'CEL ' => 'Crossfield', 94 'CELx' => 'Crossfield', 95 'ceyd' => 'Integrated Color Solutions, Inc.', 96 'CGS ' => 'CGS Publishing Technologies International GmbH', 97 'CHM ' => 'Rochester Robotics', 98 'CIGL' => 'Colour Imaging Group, London', 99 'CITI' => 'Citizen', 100 'CL00' => 'Candela, Ltd.', 101 'CLIQ' => 'Color IQ', 102 'clsp' => 'MacDermid ColorSpan, Inc.', 103 'CMCO' => 'Chromaco, Inc.', 104 'CMiX' => 'CHROMiX', 105 'COLO' => 'Colorgraphic Communications Corporation', 106 'COMP' => 'COMPAQ Computer Corporation', 107 'COMp' => 'Compeq USA/Focus Technology', 108 'CONR' => 'Conrac Display Products', 109 'CORD' => 'Cordata Technologies, Inc.', 110 'CPQ ' => 'Compaq Computer Corporation', 111 'CPRO' => 'ColorPro', 112 'CRN ' => 'Cornerstone', 113 'CTX ' => 'CTX International, Inc.', 114 'CVIS' => 'ColorVision', 115 'CWC ' => 'Fujitsu Laboratories, Ltd.', 116 'DARI' => 'Darius Technology, Ltd.', 117 'DATA' => 'Dataproducts', 118 'DCP ' => 'Dry Creek Photo', 119 'DCRC' => 'Digital Contents Resource Center, Chung-Ang University', 120 'DELL' => 'Dell Computer Corporation', 121 'DIC ' => 'Dainippon Ink and Chemicals', 122 'DICO' => 'Diconix', 123 'DIGI' => 'Digital', 124 'DL&C' => 'Digital Light & Color', 125 'DPLG' => 'Doppelganger, LLC', 126 'DS ' => 'Dainippon Screen', 127 'ds ' => 'Dainippon Screen', 128 'DSOL' => 'DOOSOL', 129 'DUPN' => 'DuPont', 130 'dupn' => 'DuPont', 131 'Eizo' => 'EIZO NANAO CORPORATION', 132 'EPSO' => 'Epson', 133 'ESKO' => 'Esko-Graphics', 134 'ETRI' => 'Electronics and Telecommunications Research Institute', 135 'EVER' => 'Everex Systems, Inc.', 136 'EXAC' => 'ExactCODE GmbH', 137 'FALC' => 'Falco Data Products, Inc.', 138 'FF ' => 'Fuji Photo Film Co.,LTD', 139 'FFEI' => 'FujiFilm Electronic Imaging, Ltd.', 140 'ffei' => 'FujiFilm Electronic Imaging, Ltd.', 141 'flux' => 'FluxData Corporation', 142 'FNRD' => 'fnord software', 143 'FORA' => 'Fora, Inc.', 144 'FORE' => 'Forefront Technology Corporation', 145 'FP ' => 'Fujitsu', 146 'FPA ' => 'WayTech Development, Inc.', 147 'FUJI' => 'Fujitsu', 148 'FX ' => 'Fuji Xerox Co., Ltd.', 149 'GCC ' => 'GCC Technologies, Inc.', 150 'GGSL' => 'Global Graphics Software Limited', 151 'GMB ' => 'Gretagmacbeth', 152 'GMG ' => 'GMG GmbH & Co. KG', 153 'GOLD' => 'GoldStar Technology, Inc.', 154 'GOOG' => 'Google', #PH 155 'GPRT' => 'Giantprint Pty Ltd', 156 'GTMB' => 'Gretagmacbeth', 157 'GVC ' => 'WayTech Development, Inc.', 158 'GW2K' => 'Sony Corporation', 159 'HCI ' => 'HCI', 160 'HDM ' => 'Heidelberger Druckmaschinen AG', 161 'HERM' => 'Hermes', 162 'HITA' => 'Hitachi America, Ltd.', 163 'HiTi' => 'HiTi Digital, Inc.', 164 'HP ' => 'Hewlett-Packard', 165 'HTC ' => 'Hitachi, Ltd.', 166 'IBM ' => 'IBM Corporation', 167 'IDNT' => 'Scitex Corporation, Ltd.', 168 'Idnt' => 'Scitex Corporation, Ltd.', 169 'IEC ' => 'Hewlett-Packard', 170 'IIYA' => 'Iiyama North America, Inc.', 171 'IKEG' => 'Ikegami Electronics, Inc.', 172 'IMAG' => 'Image Systems Corporation', 173 'IMI ' => 'Ingram Micro, Inc.', 174 'Inca' => 'Inca Digital Printers Ltd.', 175 'INTC' => 'Intel Corporation', 176 'INTL' => 'N/A (INTL)', 177 'INTR' => 'Intra Electronics USA, Inc.', 178 'IOCO' => 'Iocomm International Technology Corporation', 179 'IPS ' => 'InfoPrint Solutions Company', 180 'IRIS' => 'Scitex Corporation, Ltd.', 181 'Iris' => 'Scitex Corporation, Ltd.', 182 'iris' => 'Scitex Corporation, Ltd.', 183 'ISL ' => 'Ichikawa Soft Laboratory', 184 'ITNL' => 'N/A (ITNL)', 185 'IVM ' => 'IVM', 186 'IWAT' => 'Iwatsu Electric Co., Ltd.', 187 'JPEG' => 'Joint Photographic Experts Group', #PH 188 'JSFT' => 'Jetsoft Development', 189 'JVC ' => 'JVC Information Products Co.', 190 'KART' => 'Scitex Corporation, Ltd.', 191 'Kart' => 'Scitex Corporation, Ltd.', 192 'kart' => 'Scitex Corporation, Ltd.', 193 'KFC ' => 'KFC Computek Components Corporation', 194 'KLH ' => 'KLH Computers', 195 'KMHD' => 'Konica Minolta Holdings, Inc.', 196 'KNCA' => 'Konica Corporation', 197 'KODA' => 'Kodak', 198 'KYOC' => 'Kyocera', 199 'LCAG' => 'Leica Camera AG', 200 'LCCD' => 'Leeds Colour', 201 'lcms' => 'Little CMS', #NealKrawetz 202 'LDAK' => 'Left Dakota', 203 'LEAD' => 'Leading Technology, Inc.', 204 'Leaf' => 'Leaf', #PH 205 'LEXM' => 'Lexmark International, Inc.', 206 'LINK' => 'Link Computer, Inc.', 207 'LINO' => 'Linotronic', 208 'Lino' => 'Linotronic', #PH (NC) 209 'lino' => 'Linotronic', #PH (NC) 210 'LITE' => 'Lite-On, Inc.', 211 'MAGC' => 'Mag Computronic (USA) Inc.', 212 'MAGI' => 'MAG Innovision, Inc.', 213 'MANN' => 'Mannesmann', 214 'MICN' => 'Micron Technology, Inc.', 215 'MICR' => 'Microtek', 216 'MICV' => 'Microvitec, Inc.', 217 'MINO' => 'Minolta', 218 'MITS' => 'Mitsubishi Electronics America, Inc.', 219 'MITs' => 'Mitsuba Corporation', 220 'Mits' => 'Mitsubishi Electric Corporation Kyoto Works', 221 'MNLT' => 'Minolta', 222 'MODG' => 'Modgraph, Inc.', 223 'MONI' => 'Monitronix, Inc.', 224 'MONS' => 'Monaco Systems Inc.', 225 'MORS' => 'Morse Technology, Inc.', 226 'MOTI' => 'Motive Systems', 227 'MSFT' => 'Microsoft Corporation', 228 'MUTO' => 'MUTOH INDUSTRIES LTD.', 229 'NANA' => 'NANAO USA Corporation', 230 'NEC ' => 'NEC Corporation', 231 'NEXP' => 'NexPress Solutions LLC', 232 'NISS' => 'Nissei Sangyo America, Ltd.', 233 'NKON' => 'Nikon Corporation', 234 'ob4d' => 'Erdt Systems GmbH & Co KG', 235 'obic' => 'Medigraph GmbH', 236 'OCE ' => 'Oce Technologies B.V.', 237 'OCEC' => 'OceColor', 238 'OKI ' => 'Oki', 239 'OKID' => 'Okidata', 240 'OKIP' => 'Okidata', 241 'OLIV' => 'Olivetti', 242 'OLYM' => 'OLYMPUS OPTICAL CO., LTD', 243 'ONYX' => 'Onyx Graphics', 244 'OPTI' => 'Optiquest', 245 'PACK' => 'Packard Bell', 246 'PANA' => 'Matsushita Electric Industrial Co., Ltd.', 247 'PANT' => 'Pantone, Inc.', 248 'PBN ' => 'Packard Bell', 249 'PFU ' => 'PFU Limited', 250 'PHIL' => 'Philips Consumer Electronics Co.', 251 'PNTX' => 'HOYA Corporation PENTAX Imaging Systems Division', 252 'POne' => 'Phase One A/S', 253 'PREM' => 'Premier Computer Innovations', 254 'PRIN' => 'Princeton Graphic Systems', 255 'PRIP' => 'Princeton Publishing Labs', 256 'QLUX' => 'Hong Kong', 257 'QMS ' => 'QMS, Inc.', 258 'QPCD' => 'QPcard AB', 259 'QUAD' => 'QuadLaser', 260 'quby' => 'Qubyx Sarl', 261 'QUME' => 'Qume Corporation', 262 'RADI' => 'Radius, Inc.', 263 'RDDx' => 'Integrated Color Solutions, Inc.', 264 'RDG ' => 'Roland DG Corporation', 265 'REDM' => 'REDMS Group, Inc.', 266 'RELI' => 'Relisys', 267 'RGMS' => 'Rolf Gierling Multitools', 268 'RICO' => 'Ricoh Corporation', 269 'RNLD' => 'Edmund Ronald', 270 'ROYA' => 'Royal', 271 'RPC ' => 'Ricoh Printing Systems,Ltd.', 272 'RTL ' => 'Royal Information Electronics Co., Ltd.', 273 'SAMP' => 'Sampo Corporation of America', 274 'SAMS' => 'Samsung, Inc.', 275 'SANT' => 'Jaime Santana Pomares', 276 'SCIT' => 'Scitex Corporation, Ltd.', 277 'Scit' => 'Scitex Corporation, Ltd.', 278 'scit' => 'Scitex Corporation, Ltd.', 279 'SCRN' => 'Dainippon Screen', 280 'scrn' => 'Dainippon Screen', 281 'SDP ' => 'Scitex Corporation, Ltd.', 282 'Sdp ' => 'Scitex Corporation, Ltd.', 283 'sdp ' => 'Scitex Corporation, Ltd.', 284 'SEC ' => 'SAMSUNG ELECTRONICS CO.,LTD', 285 'SEIK' => 'Seiko Instruments U.S.A., Inc.', 286 'SEIk' => 'Seikosha', 287 'SGUY' => 'ScanGuy.com', 288 'SHAR' => 'Sharp Laboratories', 289 'SICC' => 'International Color Consortium', 290 'siwi' => 'SIWI GRAFIKA CORPORATION', 291 'SONY' => 'SONY Corporation', 292 'Sony' => 'Sony Corporation', 293 'SPCL' => 'SpectraCal', 294 'STAR' => 'Star', 295 'STC ' => 'Sampo Technology Corporation', 296 'TALO' => 'Talon Technology Corporation', 297 'TAND' => 'Tandy', 298 'TATU' => 'Tatung Co. of America, Inc.', 299 'TAXA' => 'TAXAN America, Inc.', 300 'TDS ' => 'Tokyo Denshi Sekei K.K.', 301 'TECO' => 'TECO Information Systems, Inc.', 302 'TEGR' => 'Tegra', 303 'TEKT' => 'Tektronix, Inc.', 304 'TI ' => 'Texas Instruments', 305 'TMKR' => 'TypeMaker Ltd.', 306 'TOSB' => 'TOSHIBA corp.', 307 'TOSH' => 'Toshiba, Inc.', 308 'TOTK' => 'TOTOKU ELECTRIC Co., LTD', 309 'TRIU' => 'Triumph', 310 'TSBT' => 'TOSHIBA TEC CORPORATION', 311 'TTX ' => 'TTX Computer Products, Inc.', 312 'TVM ' => 'TVM Professional Monitor Corporation', 313 'TW ' => 'TW Casper Corporation', 314 'ULSX' => 'Ulead Systems', 315 'UNIS' => 'Unisys', 316 'UTZF' => 'Utz Fehlau & Sohn', 317 'VARI' => 'Varityper', 318 'VIEW' => 'Viewsonic', 319 'VISL' => 'Visual communication', 320 'VIVO' => 'Vivo Mobile Communication Co., Ltd', 321 'WANG' => 'Wang', 322 'WLBR' => 'Wilbur Imaging', 323 'WTG2' => 'Ware To Go', 324 'WYSE' => 'WYSE Technology', 325 'XERX' => 'Xerox Corporation', 326 'XRIT' => 'X-Rite', 327 'yxym' => 'YxyMaster GmbH', 328 'Z123' => "Lavanya's test Company", 329 'Zebr' => 'Zebra Technologies Inc', 330 'ZRAN' => 'Zoran Corporation', 331 # also seen: " ",ACMS,KCMS,UCCM,etc2,SCTX 332 ); 55 333 56 334 # ICC_Profile tag table … … 86 364 targ => { 87 365 Name => 'CharTarget', 88 ValueConv => ' length $val > 128 ? \$val : $val',366 ValueConv => '$val=~s/\0.*//; length $val > 128 ? \$val : $val', 89 367 }, 90 368 chad => 'ChromaticAdaptation', … … 257 535 MS00 => 'WCSProfiles', 258 536 537 psd3 => { #6 538 Name => 'PostScript2CRD3', 539 Binary => 1, # (NC) 540 }, 541 259 542 # the following entry represents the ICC profile header, and doesn't 260 543 # exist as a tag in the directory. It is only in this table to provide … … 275 558 Name => 'ProfileCMMType', 276 559 Format => 'string[4]', 560 SeparateTable => 'ManuSig', 561 PrintConv => \%manuSig, 277 562 }, 278 563 8 => { … … 327 612 Name => 'DeviceManufacturer', 328 613 Format => 'string[4]', 329 # KODA = Kodak 614 SeparateTable => 'ManuSig', 615 PrintConv => \%manuSig, 330 616 }, 331 617 52 => { 332 618 Name => 'DeviceModel', 333 619 Format => 'string[4]', 334 # ROMM = Ref rence Output Medium Metric620 # ROMM = Reference Output Medium Metric 335 621 }, 336 622 56 => { … … 362 648 Name => 'ProfileCreator', 363 649 Format => 'string[4]', 364 # KODA = Kodak 650 SeparateTable => 'ManuSig', 651 PrintConv => \%manuSig, 365 652 }, 366 653 84 => { … … 410 697 Format => 'int32u', 411 698 PrintConv => { 699 0 => 'Unknown', 412 700 1 => '0/45 or 45/0', 413 701 2 => '0/d or d/0', … … 517 805 518 806 #------------------------------------------------------------------------------ 519 # print ICC Profile ID in hex807 # Print ICC Profile ID in hex 520 808 # Inputs: 1) string of numbers 521 809 # Returns: string of hex digits … … 532 820 533 821 #------------------------------------------------------------------------------ 534 # get formatted value from ICC tag (which has the type embedded)822 # Get formatted value from ICC tag (which has the type embedded) 535 823 # Inputs: 0) data reference, 1) offset to tag data, 2) tag data size 536 824 # Returns: Formatted value or undefined if format not supported 537 825 # Notes: The following types are handled by BinaryTables: 538 826 # chromaticityType, colorantTableType, measurementType, viewingConditionsType 539 # The following types are not currentlyhandled (most are large tables):827 # The following types are currently not handled (most are large tables): 540 828 # curveType, lut16Type, lut8Type, lutAtoBType, lutBtoAType, namedColor2Type, 541 829 # parametricCurveType, profileSeqDescType, responseCurveSet16Type … … 628 916 sub ProcessMetadata($$$) 629 917 { 630 my ($e xifTool, $dirInfo, $tagTablePtr) = @_;918 my ($et, $dirInfo, $tagTablePtr) = @_; 631 919 my $dataPt = $$dirInfo{DataPt}; 632 920 my $dirStart = $$dirInfo{DirStart}; 633 921 my $dirLen = $$dirInfo{DirLen}; 634 922 my $dirEnd = $dirStart + $dirLen; 635 923 636 924 if ($dirLen < 16 or substr($$dataPt, $dirStart, 4) ne 'dict') { 637 $e xifTool->Warn('Invalid ICC meta dictionary');925 $et->Warn('Invalid ICC meta dictionary'); 638 926 return 0; 639 927 } 640 928 my $num = Get32u($dataPt, $dirStart + 8); 641 $e xifTool->VerboseDir('Metadata', $num);929 $et->VerboseDir('Metadata', $num); 642 930 my $size = Get32u($dataPt, $dirStart + 12); 643 $size < 16 and $e xifTool->Warn('Invalid ICC meta record size'), return 0;931 $size < 16 and $et->Warn('Invalid ICC meta record size'), return 0; 644 932 # NOTE: In the example the minimum offset is 20, 645 933 # but this doesn't jive with the table (both in ref 5) … … 649 937 my $entry = $dirStart + 16 + $size * $index; 650 938 if ($entry + $size > $dirEnd) { 651 $e xifTool->Warn('Truncated ICC meta dictionary');939 $et->Warn('Truncated ICC meta dictionary'); 652 940 last; 653 941 } … … 660 948 $valuePtr < $minPtr or $valuePtr + $valueLen > $dirLen) 661 949 { 662 $e xifTool->Warn('Corrupted ICC meta dictionary');950 $et->Warn('Corrupted ICC meta dictionary'); 663 951 last; 664 952 } 665 953 my $tag = substr($dataPt, $dirStart + $namePtr, $nameLen); 666 954 my $val = substr($dataPt, $dirStart + $valuePtr, $valueLen); 667 $tag = $e xifTool->Decode($tag, 'UTF16', 'MM', 'UTF8');668 $val = $e xifTool->Decode($val, 'UTF16', 'MM');955 $tag = $et->Decode($tag, 'UTF16', 'MM', 'UTF8'); 956 $val = $et->Decode($val, 'UTF16', 'MM'); 669 957 # generate tagInfo if it doesn't exist 670 958 unless ($$tagTablePtr{$tag}) { … … 673 961 $name =~ tr/-_a-zA-Z0-9//dc; 674 962 next unless length $name; 675 Image::ExifTool::AddTagToTable($tagTablePtr, $tag, { Name => $name });963 AddTagToTable($tagTablePtr, $tag, { Name => $name }); 676 964 } 677 $e xifTool->HandleTag($tagTablePtr, $tag, $val);965 $et->HandleTag($tagTablePtr, $tag, $val); 678 966 } 679 967 return 1; … … 687 975 sub WriteICC($$) 688 976 { 689 my ($e xifTool, $dirInfo) = @_;977 my ($et, $dirInfo) = @_; 690 978 # first make sure this is a valid ICC file (or no file at all) 691 979 my $raf = $$dirInfo{RAF}; … … 693 981 return 0 if $raf->Read($buff, 24) and ValidateICC(\$buff); 694 982 # now write the new ICC 695 $buff = WriteICC_Profile($e xifTool, $dirInfo);983 $buff = WriteICC_Profile($et, $dirInfo); 696 984 if (defined $buff and length $buff) { 697 985 Write($$dirInfo{OutFile}, $buff) or return -1; 698 986 } else { 699 $e xifTool->Error('No ICC information to write');987 $et->Error('No ICC information to write'); 700 988 } 701 989 return 1; … … 710 998 sub WriteICC_Profile($$;$) 711 999 { 712 my ($e xifTool, $dirInfo, $tagTablePtr) = @_;713 $e xifToolor return 1; # allow dummy access1000 my ($et, $dirInfo, $tagTablePtr) = @_; 1001 $et or return 1; # allow dummy access 714 1002 my $dirName = $$dirInfo{DirName} || 'ICC_Profile'; 715 1003 # (don't write AsShotICCProfile or CurrentICCProfile here) 716 1004 return undef unless $dirName eq 'ICC_Profile'; 717 my $nvHash = $exifTool->GetNewValueHash($Image::ExifTool::Extra{$dirName}); 718 return undef unless Image::ExifTool::IsOverwriting($nvHash); 719 my $val = Image::ExifTool::GetNewValues($nvHash); 1005 my $nvHash = $et->GetNewValueHash($Image::ExifTool::Extra{$dirName}); 1006 my $val = $et->GetNewValue($nvHash); 720 1007 $val = '' unless defined $val; 721 ++$exifTool->{CHANGED}; 1008 return undef unless $et->IsOverwriting($nvHash, $val); 1009 ++$$et{CHANGED}; 722 1010 return $val; 723 1011 } … … 747 1035 sub ProcessICC($$) 748 1036 { 749 my ($e xifTool, $dirInfo) = @_;1037 my ($et, $dirInfo) = @_; 750 1038 my $raf = $$dirInfo{RAF}; 751 1039 my $buff; … … 753 1041 # check to see if this is a valid ICC profile file 754 1042 return 0 if ValidateICC(\$buff); 755 $e xifTool->SetFileType();1043 $et->SetFileType(); 756 1044 # read the profile 757 1045 my $size = unpack('N', $buff); 758 1046 if ($size < 128 or $size & 0x80000000) { 759 $e xifTool->Error("Bad ICC Profile length ($size)");1047 $et->Error("Bad ICC Profile length ($size)"); 760 1048 return 1; 761 1049 } 762 1050 $raf->Seek(0, 0); 763 unless ($raf->Read($buff, $size) ) {764 $e xifTool->Error('Truncated ICC profile');1051 unless ($raf->Read($buff, $size) == $size) { 1052 $et->Error('Truncated ICC profile'); 765 1053 return 1; 766 1054 } … … 772 1060 ); 773 1061 my $tagTablePtr = GetTagTable('Image::ExifTool::ICC_Profile::Main'); 774 return ProcessICC_Profile($e xifTool, \%dirInfo, $tagTablePtr);1062 return ProcessICC_Profile($et, \%dirInfo, $tagTablePtr); 775 1063 } 776 1064 … … 782 1070 sub ProcessICC_Profile($$$) 783 1071 { 784 my ($e xifTool, $dirInfo, $tagTablePtr) = @_;1072 my ($et, $dirInfo, $tagTablePtr) = @_; 785 1073 my $dataPt = $$dirInfo{DataPt}; 786 my $dirStart = $$dirInfo{DirStart} ;1074 my $dirStart = $$dirInfo{DirStart} || 0; 787 1075 my $dirLen = $$dirInfo{DirLen}; 788 my $verbose = $e xifTool->Options('Verbose');1076 my $verbose = $et->Options('Verbose'); 789 1077 790 1078 return 0 if $dirLen < 4; 791 1079 792 1080 # extract binary ICC_Profile data block if binary mode or requested 793 if ($exifTool->{OPTIONS}->{Binary} or $exifTool->{REQ_TAG_LOOKUP}->{icc_profile} and 1081 if ((($$et{TAGS_FROM_FILE} and not $$et{EXCL_TAG_LOOKUP}{icc_profile}) or 1082 $$et{REQ_TAG_LOOKUP}{icc_profile}) and 794 1083 # (don't extract from AsShotICCProfile or CurrentICCProfile) 795 1084 (not $$dirInfo{Name} or $$dirInfo{Name} eq 'ICC_Profile')) 796 1085 { 797 $e xifTool->FoundTag('ICC_Profile', substr($$dataPt, $dirStart, $dirLen));1086 $et->FoundTag('ICC_Profile', substr($$dataPt, $dirStart, $dirLen)); 798 1087 } 799 1088 … … 803 1092 my $len = Get32u($dataPt, $dirStart); 804 1093 if ($len != $dirLen or $len < 128) { 805 $e xifTool->Warn("Bad length ICC_Profile (length $len)");1094 $et->Warn("Bad length ICC_Profile (length $len)"); 806 1095 return 0 if $len < 128 or $dirLen < $len; 807 1096 } … … 811 1100 or $numEntries * 12 + 132 > $dirLen) 812 1101 { 813 $e xifTool->Warn("Bad ICC_Profile table ($numEntries entries)");1102 $et->Warn("Bad ICC_Profile table ($numEntries entries)"); 814 1103 return 0; 815 1104 } 816 1105 817 1106 if ($verbose) { 818 $e xifTool->VerboseDir('ICC_Profile', $numEntries, $dirLen);1107 $et->VerboseDir('ICC_Profile', $numEntries, $dirLen); 819 1108 my $fakeInfo = { Name=>'ProfileHeader', SubDirectory => { } }; 820 $e xifTool->VerboseInfo(undef, $fakeInfo);1109 $et->VerboseInfo(undef, $fakeInfo); 821 1110 } 822 1111 # increment ICC dir count 823 my $dirCount = $ exifTool->{DIR_COUNT}->{ICC} = ($exifTool->{DIR_COUNT}->{ICC} || 0) + 1;824 $ exifTool->{SET_GROUP1} = '+' . $dirCount if $dirCount > 1;1112 my $dirCount = $$et{DIR_COUNT}{ICC} = ($$et{DIR_COUNT}{ICC} || 0) + 1; 1113 $$et{SET_GROUP1} = '+' . $dirCount if $dirCount > 1; 825 1114 # process the header block 826 1115 my %subdirInfo = ( … … 831 1120 DirLen => 128, 832 1121 Parent => $$dirInfo{DirName}, 1122 DirName => 'Header', 833 1123 ); 834 1124 my $newTagTable = GetTagTable('Image::ExifTool::ICC_Profile::Header'); 835 $e xifTool->ProcessDirectory(\%subdirInfo, $newTagTable);1125 $et->ProcessDirectory(\%subdirInfo, $newTagTable); 836 1126 837 1127 $pos += 4; # skip item count … … 842 1132 my $size = Get32u($dataPt, $pos + 8); 843 1133 $pos += 12; 844 my $tagInfo = $e xifTool->GetTagInfo($tagTablePtr, $tagID);1134 my $tagInfo = $et->GetTagInfo($tagTablePtr, $tagID); 845 1135 # unknown tags aren't generated automatically by GetTagInfo() 846 1136 # if the tagID's aren't numeric, so we must do this manually: 847 if (not $tagInfo and $ exifTool->{OPTIONS}->{Unknown}) {1137 if (not $tagInfo and $$et{OPTIONS}{Unknown}) { 848 1138 $tagInfo = { Unknown => 1 }; 849 Image::ExifTool::AddTagToTable($tagTablePtr, $tagID, $tagInfo);1139 AddTagToTable($tagTablePtr, $tagID, $tagInfo); 850 1140 } 851 1141 next unless defined $tagInfo; 852 1142 853 1143 if ($offset + $size > $dirLen) { 854 $e xifTool->Warn("Bad ICC_Profile table (truncated)");1144 $et->Warn("Bad ICC_Profile table (truncated)"); 855 1145 last; 856 1146 } … … 880 1170 my $strLen = Get32u($dataPt, $recPos + 4); 881 1171 my $strPos = Get32u($dataPt, $recPos + 8); 882 last if $strPos + $strLen > $size; 1172 last if $strPos + $strLen > $size; 883 1173 my $str = substr($$dataPt, $valuePtr + $strPos, $strLen); 884 $str = $e xifTool->Decode($str, 'UTF16');885 $e xifTool->HandleTag($tagTablePtr, $tagID, $str,1174 $str = $et->Decode($str, 'UTF16'); 1175 $et->HandleTag($tagTablePtr, $tagID, $str, 886 1176 TagInfo => $langInfo || $tagInfo, 887 1177 Table => $tagTablePtr, … … 891 1181 Size => $strLen, 892 1182 Start => $valuePtr + $strPos, 893 Format => "type '$ fmt'",1183 Format => "type '${fmt}'", 894 1184 ); 895 1185 } 896 $e xifTool->Warn("Corrupted $$tagInfo{Name} data") if $i < $count;1186 $et->Warn("Corrupted $$tagInfo{Name} data") if $i < $count; 897 1187 next; 898 1188 } … … 901 1191 } 902 1192 $value = FormatICCTag($dataPt, $valuePtr, $size) unless $subdir; 903 $verbose and $e xifTool->VerboseInfo($tagID, $tagInfo,1193 $verbose and $et->VerboseInfo($tagID, $tagInfo, 904 1194 Table => $tagTablePtr, 905 1195 Index => $index, … … 908 1198 Size => $size, 909 1199 Start => $valuePtr, 910 Format => "type '$ fmt'",1200 Format => "type '${fmt}'", 911 1201 ); 912 1202 if ($subdir) { … … 930 1220 DirStart => $valuePtr, 931 1221 DirLen => $size, 1222 DirName => $name, 932 1223 Parent => $$dirInfo{DirName}, 933 1224 ); … … 935 1226 #### eval Validate ($type) 936 1227 if (defined $$subdir{Validate} and not eval $$subdir{Validate}) { 937 $e xifTool->Warn("Invalid$name data");1228 $et->Warn("Invalid ICC $name data"); 938 1229 } else { 939 $e xifTool->ProcessDirectory(\%subdirInfo, $newTagTable, $$subdir{ProcessProc});1230 $et->ProcessDirectory(\%subdirInfo, $newTagTable, $$subdir{ProcessProc}); 940 1231 } 941 1232 } elsif (defined $value) { 942 $e xifTool->FoundTag($tagInfo, $value);1233 $et->FoundTag($tagInfo, $value); 943 1234 } else { 944 1235 $value = substr($$dataPt, $valuePtr, $size); 945 1236 # treat unsupported formats as binary data 946 1237 $$tagInfo{ValueConv} = '\$val' unless defined $$tagInfo{ValueConv}; 947 $e xifTool->FoundTag($tagInfo, $value);1238 $et->FoundTag($tagInfo, $value); 948 1239 } 949 1240 } 950 delete $ exifTool->{SET_GROUP1};1241 delete $$et{SET_GROUP1}; 951 1242 return 1; 952 1243 } … … 974 1265 =head1 AUTHOR 975 1266 976 Copyright 2003-20 11, Phil Harvey (phil at owl.phy.queensu.ca)1267 Copyright 2003-2021, Phil Harvey (philharvey66 at gmail.com) 977 1268 978 1269 This library is free software; you can redistribute it and/or modify it
Note:
See TracChangeset
for help on using the changeset viewer.