Ignore:
Timestamp:
2021-02-26T19:39:51+13:00 (3 years ago)
Author:
anupama
Message:

Committing the improvements to EmbeddedMetaPlugin's processing of Keywords vs other metadata fields. Keywords were literally stored as arrays of words rather than phrases in PDFs (at least in Diego's sample PDF), whereas other meta fields like Subjects and Creators stored them as arrays of phrases. To get both to work, Kathy updated EXIF to a newer version, to retrieve the actual EXIF values stored in the PDF. And Kathy and Dr Bainbridge came up with a new option that I added called apply_join_before_split_to_metafields that's a regex which can list the metadata fields to apply the join_before_split to and whcih previously always got applied to all metadata fields. Now it's applied to any *Keywords metafields by default, as that's the metafield we have experience of that behaves differently to the others, as it stores by word instead of phrases. Tested on Diego's sample PDF. Diego has double-checked it to works on his sample PDF too, setting the split char to ; and turning on the join_before_split and leaving apply_join_before_split_to_metafields at its default of .*Keywords. File changes are strings.properties for the tooltip, the plugin introducing the option and working with it and Kathy's EXIF updates affecting cpan/File and cpan/Image.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/perllib/cpan/Image/ExifTool/ICC_Profile.pm

    r24107 r34921  
    1111#               4) http://www.color.org/privatetag2007-01.pdf
    1212#               5) http://www.color.org/icc_specs2.xalter (approved revisions, 2010-07-16)
     13#               6) Eef Vreeland private communication
    1314#
    1415# Notes:        The ICC profile information is different: the format of each
     
    2425use Image::ExifTool qw(:DataAccess :Utils);
    2526
    26 $VERSION = '1.22';
     27$VERSION = '1.36';
    2728
    2829sub ProcessICC($$);
     
    5354    nkpf => 'Nikon Input Device Profile (NON-STANDARD!)', # (written by Nikon utilities)
    5455);
     56my %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);
    55333
    56334# ICC_Profile tag table
     
    86364    targ => {
    87365        Name => 'CharTarget',
    88         ValueConv => 'length $val > 128 ? \$val : $val',
     366        ValueConv => '$val=~s/\0.*//; length $val > 128 ? \$val : $val',
    89367    },
    90368    chad => 'ChromaticAdaptation',
     
    257535    MS00 => 'WCSProfiles',
    258536
     537    psd3 => { #6
     538        Name => 'PostScript2CRD3',
     539        Binary => 1, # (NC)
     540    },
     541
    259542    # the following entry represents the ICC profile header, and doesn't
    260543    # exist as a tag in the directory.  It is only in this table to provide
     
    275558        Name => 'ProfileCMMType',
    276559        Format => 'string[4]',
     560        SeparateTable => 'ManuSig',
     561        PrintConv => \%manuSig,
    277562    },
    278563    8 => {
     
    327612        Name => 'DeviceManufacturer',
    328613        Format => 'string[4]',
    329         # KODA = Kodak
     614        SeparateTable => 'ManuSig',
     615        PrintConv => \%manuSig,
    330616    },
    331617    52 => {
    332618        Name => 'DeviceModel',
    333619        Format => 'string[4]',
    334         # ROMM = Refrence Output Medium Metric
     620        # ROMM = Reference Output Medium Metric
    335621    },
    336622    56 => {
     
    362648        Name => 'ProfileCreator',
    363649        Format => 'string[4]',
    364         # KODA = Kodak
     650        SeparateTable => 'ManuSig',
     651        PrintConv => \%manuSig,
    365652    },
    366653    84 => {
     
    410697        Format => 'int32u',
    411698        PrintConv => {
     699            0 => 'Unknown',
    412700            1 => '0/45 or 45/0',
    413701            2 => '0/d or d/0',
     
    517805
    518806#------------------------------------------------------------------------------
    519 # print ICC Profile ID in hex
     807# Print ICC Profile ID in hex
    520808# Inputs: 1) string of numbers
    521809# Returns: string of hex digits
     
    532820
    533821#------------------------------------------------------------------------------
    534 # get formatted value from ICC tag (which has the type embedded)
     822# Get formatted value from ICC tag (which has the type embedded)
    535823# Inputs: 0) data reference, 1) offset to tag data, 2) tag data size
    536824# Returns: Formatted value or undefined if format not supported
    537825# Notes: The following types are handled by BinaryTables:
    538826#  chromaticityType, colorantTableType, measurementType, viewingConditionsType
    539 # The following types are not currently handled (most are large tables):
     827# The following types are currently not handled (most are large tables):
    540828#  curveType, lut16Type, lut8Type, lutAtoBType, lutBtoAType, namedColor2Type,
    541829#  parametricCurveType, profileSeqDescType, responseCurveSet16Type
     
    628916sub ProcessMetadata($$$)
    629917{
    630     my ($exifTool, $dirInfo, $tagTablePtr) = @_;
     918    my ($et, $dirInfo, $tagTablePtr) = @_;
    631919    my $dataPt = $$dirInfo{DataPt};
    632920    my $dirStart = $$dirInfo{DirStart};
    633921    my $dirLen = $$dirInfo{DirLen};
    634922    my $dirEnd = $dirStart + $dirLen;
    635    
     923
    636924    if ($dirLen < 16 or substr($$dataPt, $dirStart, 4) ne 'dict') {
    637         $exifTool->Warn('Invalid ICC meta dictionary');
     925        $et->Warn('Invalid ICC meta dictionary');
    638926        return 0;
    639927    }
    640928    my $num = Get32u($dataPt, $dirStart + 8);
    641     $exifTool->VerboseDir('Metadata', $num);
     929    $et->VerboseDir('Metadata', $num);
    642930    my $size = Get32u($dataPt, $dirStart + 12);
    643     $size < 16 and $exifTool->Warn('Invalid ICC meta record size'), return 0;
     931    $size < 16 and $et->Warn('Invalid ICC meta record size'), return 0;
    644932    # NOTE: In the example the minimum offset is 20,
    645933    # but this doesn't jive with the table (both in ref 5)
     
    649937        my $entry = $dirStart + 16 + $size * $index;
    650938        if ($entry + $size > $dirEnd) {
    651             $exifTool->Warn('Truncated ICC meta dictionary');
     939            $et->Warn('Truncated ICC meta dictionary');
    652940            last;
    653941        }
     
    660948            $valuePtr < $minPtr or $valuePtr + $valueLen > $dirLen)
    661949        {
    662             $exifTool->Warn('Corrupted ICC meta dictionary');
     950            $et->Warn('Corrupted ICC meta dictionary');
    663951            last;
    664952        }
    665953        my $tag = substr($dataPt, $dirStart + $namePtr, $nameLen);
    666954        my $val = substr($dataPt, $dirStart + $valuePtr, $valueLen);
    667         $tag = $exifTool->Decode($tag, 'UTF16', 'MM', 'UTF8');
    668         $val = $exifTool->Decode($val, 'UTF16', 'MM');
     955        $tag = $et->Decode($tag, 'UTF16', 'MM', 'UTF8');
     956        $val = $et->Decode($val, 'UTF16', 'MM');
    669957        # generate tagInfo if it doesn't exist
    670958        unless ($$tagTablePtr{$tag}) {
     
    673961            $name =~ tr/-_a-zA-Z0-9//dc;
    674962            next unless length $name;
    675             Image::ExifTool::AddTagToTable($tagTablePtr, $tag, { Name => $name });
     963            AddTagToTable($tagTablePtr, $tag, { Name => $name });
    676964        }
    677         $exifTool->HandleTag($tagTablePtr, $tag, $val);
     965        $et->HandleTag($tagTablePtr, $tag, $val);
    678966    }
    679967    return 1;
     
    687975sub WriteICC($$)
    688976{
    689     my ($exifTool, $dirInfo) = @_;
     977    my ($et, $dirInfo) = @_;
    690978    # first make sure this is a valid ICC file (or no file at all)
    691979    my $raf = $$dirInfo{RAF};
     
    693981    return 0 if $raf->Read($buff, 24) and ValidateICC(\$buff);
    694982    # now write the new ICC
    695     $buff = WriteICC_Profile($exifTool, $dirInfo);
     983    $buff = WriteICC_Profile($et, $dirInfo);
    696984    if (defined $buff and length $buff) {
    697985        Write($$dirInfo{OutFile}, $buff) or return -1;
    698986    } else {
    699         $exifTool->Error('No ICC information to write');
     987        $et->Error('No ICC information to write');
    700988    }
    701989    return 1;
     
    710998sub WriteICC_Profile($$;$)
    711999{
    712     my ($exifTool, $dirInfo, $tagTablePtr) = @_;
    713     $exifTool or return 1;    # allow dummy access
     1000    my ($et, $dirInfo, $tagTablePtr) = @_;
     1001    $et or return 1;    # allow dummy access
    7141002    my $dirName = $$dirInfo{DirName} || 'ICC_Profile';
    7151003    # (don't write AsShotICCProfile or CurrentICCProfile here)
    7161004    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);
    7201007    $val = '' unless defined $val;
    721     ++$exifTool->{CHANGED};
     1008    return undef unless $et->IsOverwriting($nvHash, $val);
     1009    ++$$et{CHANGED};
    7221010    return $val;
    7231011}
     
    7471035sub ProcessICC($$)
    7481036{
    749     my ($exifTool, $dirInfo) = @_;
     1037    my ($et, $dirInfo) = @_;
    7501038    my $raf = $$dirInfo{RAF};
    7511039    my $buff;
     
    7531041    # check to see if this is a valid ICC profile file
    7541042    return 0 if ValidateICC(\$buff);
    755     $exifTool->SetFileType();
     1043    $et->SetFileType();
    7561044    # read the profile
    7571045    my $size = unpack('N', $buff);
    7581046    if ($size < 128 or $size & 0x80000000) {
    759         $exifTool->Error("Bad ICC Profile length ($size)");
     1047        $et->Error("Bad ICC Profile length ($size)");
    7601048        return 1;
    7611049    }
    7621050    $raf->Seek(0, 0);
    763     unless ($raf->Read($buff, $size)) {
    764         $exifTool->Error('Truncated ICC profile');
     1051    unless ($raf->Read($buff, $size) == $size) {
     1052        $et->Error('Truncated ICC profile');
    7651053        return 1;
    7661054    }
     
    7721060    );
    7731061    my $tagTablePtr = GetTagTable('Image::ExifTool::ICC_Profile::Main');
    774     return ProcessICC_Profile($exifTool, \%dirInfo, $tagTablePtr);
     1062    return ProcessICC_Profile($et, \%dirInfo, $tagTablePtr);
    7751063}
    7761064
     
    7821070sub ProcessICC_Profile($$$)
    7831071{
    784     my ($exifTool, $dirInfo, $tagTablePtr) = @_;
     1072    my ($et, $dirInfo, $tagTablePtr) = @_;
    7851073    my $dataPt = $$dirInfo{DataPt};
    786     my $dirStart = $$dirInfo{DirStart};
     1074    my $dirStart = $$dirInfo{DirStart} || 0;
    7871075    my $dirLen = $$dirInfo{DirLen};
    788     my $verbose = $exifTool->Options('Verbose');
     1076    my $verbose = $et->Options('Verbose');
    7891077
    7901078    return 0 if $dirLen < 4;
    7911079
    7921080    # 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
    7941083        # (don't extract from AsShotICCProfile or CurrentICCProfile)
    7951084        (not $$dirInfo{Name} or $$dirInfo{Name} eq 'ICC_Profile'))
    7961085    {
    797         $exifTool->FoundTag('ICC_Profile', substr($$dataPt, $dirStart, $dirLen));
     1086        $et->FoundTag('ICC_Profile', substr($$dataPt, $dirStart, $dirLen));
    7981087    }
    7991088
     
    8031092    my $len = Get32u($dataPt, $dirStart);
    8041093    if ($len != $dirLen or $len < 128) {
    805         $exifTool->Warn("Bad length ICC_Profile (length $len)");
     1094        $et->Warn("Bad length ICC_Profile (length $len)");
    8061095        return 0 if $len < 128 or $dirLen < $len;
    8071096    }
     
    8111100        or $numEntries * 12 + 132 > $dirLen)
    8121101    {
    813         $exifTool->Warn("Bad ICC_Profile table ($numEntries entries)");
     1102        $et->Warn("Bad ICC_Profile table ($numEntries entries)");
    8141103        return 0;
    8151104    }
    8161105
    8171106    if ($verbose) {
    818         $exifTool->VerboseDir('ICC_Profile', $numEntries, $dirLen);
     1107        $et->VerboseDir('ICC_Profile', $numEntries, $dirLen);
    8191108        my $fakeInfo = { Name=>'ProfileHeader', SubDirectory => { } };
    820         $exifTool->VerboseInfo(undef, $fakeInfo);
     1109        $et->VerboseInfo(undef, $fakeInfo);
    8211110    }
    8221111    # 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;
    8251114    # process the header block
    8261115    my %subdirInfo = (
     
    8311120        DirLen   => 128,
    8321121        Parent   => $$dirInfo{DirName},
     1122        DirName  => 'Header',
    8331123    );
    8341124    my $newTagTable = GetTagTable('Image::ExifTool::ICC_Profile::Header');
    835     $exifTool->ProcessDirectory(\%subdirInfo, $newTagTable);
     1125    $et->ProcessDirectory(\%subdirInfo, $newTagTable);
    8361126
    8371127    $pos += 4;    # skip item count
     
    8421132        my $size   = Get32u($dataPt, $pos + 8);
    8431133        $pos += 12;
    844         my $tagInfo = $exifTool->GetTagInfo($tagTablePtr, $tagID);
     1134        my $tagInfo = $et->GetTagInfo($tagTablePtr, $tagID);
    8451135        # unknown tags aren't generated automatically by GetTagInfo()
    8461136        # 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}) {
    8481138            $tagInfo = { Unknown => 1 };
    849             Image::ExifTool::AddTagToTable($tagTablePtr, $tagID, $tagInfo);
     1139            AddTagToTable($tagTablePtr, $tagID, $tagInfo);
    8501140        }
    8511141        next unless defined $tagInfo;
    8521142
    8531143        if ($offset + $size > $dirLen) {
    854             $exifTool->Warn("Bad ICC_Profile table (truncated)");
     1144            $et->Warn("Bad ICC_Profile table (truncated)");
    8551145            last;
    8561146        }
     
    8801170                    my $strLen = Get32u($dataPt, $recPos + 4);
    8811171                    my $strPos = Get32u($dataPt, $recPos + 8);
    882                     last if $strPos + $strLen > $size; 
     1172                    last if $strPos + $strLen > $size;
    8831173                    my $str = substr($$dataPt, $valuePtr + $strPos, $strLen);
    884                     $str = $exifTool->Decode($str, 'UTF16');
    885                     $exifTool->HandleTag($tagTablePtr, $tagID, $str,
     1174                    $str = $et->Decode($str, 'UTF16');
     1175                    $et->HandleTag($tagTablePtr, $tagID, $str,
    8861176                        TagInfo => $langInfo || $tagInfo,
    8871177                        Table  => $tagTablePtr,
     
    8911181                        Size   => $strLen,
    8921182                        Start  => $valuePtr + $strPos,
    893                         Format => "type '$fmt'",
     1183                        Format => "type '${fmt}'",
    8941184                    );
    8951185                }
    896                 $exifTool->Warn("Corrupted $$tagInfo{Name} data") if $i < $count;
     1186                $et->Warn("Corrupted $$tagInfo{Name} data") if $i < $count;
    8971187                next;
    8981188            }
     
    9011191        }
    9021192        $value = FormatICCTag($dataPt, $valuePtr, $size) unless $subdir;
    903         $verbose and $exifTool->VerboseInfo($tagID, $tagInfo,
     1193        $verbose and $et->VerboseInfo($tagID, $tagInfo,
    9041194            Table  => $tagTablePtr,
    9051195            Index  => $index,
     
    9081198            Size   => $size,
    9091199            Start  => $valuePtr,
    910             Format => "type '$fmt'",
     1200            Format => "type '${fmt}'",
    9111201        );
    9121202        if ($subdir) {
     
    9301220                DirStart => $valuePtr,
    9311221                DirLen   => $size,
     1222                DirName  => $name,
    9321223                Parent   => $$dirInfo{DirName},
    9331224            );
     
    9351226            #### eval Validate ($type)
    9361227            if (defined $$subdir{Validate} and not eval $$subdir{Validate}) {
    937                 $exifTool->Warn("Invalid $name data");
     1228                $et->Warn("Invalid ICC $name data");
    9381229            } else {
    939                 $exifTool->ProcessDirectory(\%subdirInfo, $newTagTable, $$subdir{ProcessProc});
     1230                $et->ProcessDirectory(\%subdirInfo, $newTagTable, $$subdir{ProcessProc});
    9401231            }
    9411232        } elsif (defined $value) {
    942             $exifTool->FoundTag($tagInfo, $value);
     1233            $et->FoundTag($tagInfo, $value);
    9431234        } else {
    9441235            $value = substr($$dataPt, $valuePtr, $size);
    9451236            # treat unsupported formats as binary data
    9461237            $$tagInfo{ValueConv} = '\$val' unless defined $$tagInfo{ValueConv};
    947             $exifTool->FoundTag($tagInfo, $value);
     1238            $et->FoundTag($tagInfo, $value);
    9481239        }
    9491240    }
    950     delete $exifTool->{SET_GROUP1};
     1241    delete $$et{SET_GROUP1};
    9511242    return 1;
    9521243}
     
    9741265=head1 AUTHOR
    9751266
    976 Copyright 2003-2011, Phil Harvey (phil at owl.phy.queensu.ca)
     1267Copyright 2003-2021, Phil Harvey (philharvey66 at gmail.com)
    9771268
    9781269This library is free software; you can redistribute it and/or modify it
Note: See TracChangeset for help on using the changeset viewer.