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/MakerNotes.pm

    r24107 r34921  
    1818sub ProcessCanon($$$);
    1919sub ProcessGE2($$$);
     20sub ProcessKodakPatch($$$);
    2021sub WriteUnknownOrPreview($$$);
    2122sub FixLeicaBase($$;$);
    2223
    23 $VERSION = '1.66';
     24$VERSION = '2.10';
    2425
    2526my $debug;          # set to 1 to enable debugging code
     
    3233# - Put these in alphabetical order to make TagNames documentation nicer.
    3334@Image::ExifTool::MakerNotes::Main = (
    34     # decide which MakerNotes to use (based on camera make/model)
     35    # decide which MakerNotes to use (based on makernote header and camera make/model)
     36    {
     37        Name => 'MakerNoteApple',
     38        Condition => '$$valPt =~ /^Apple iOS\0/',
     39        SubDirectory => {
     40            TagTable => 'Image::ExifTool::Apple::Main',
     41            Start => '$valuePtr + 14',
     42            Base => '$start - 14',
     43            ByteOrder => 'Unknown',
     44        },
     45    },
     46    {
     47        # this maker notes starts with a standard TIFF header at offset 0x0a
     48        # (must check Nikon signature first because Nikon Capture NX can generate
     49        #  NEF images containing Nikon maker notes from JPEG images of any camera model)
     50        Name => 'MakerNoteNikon',
     51        Condition => '$$valPt=~/^Nikon\x00\x02/',
     52        SubDirectory => {
     53            TagTable => 'Image::ExifTool::Nikon::Main',
     54            Start => '$valuePtr + 18',
     55            Base => '$start - 8',
     56            ByteOrder => 'Unknown',
     57        },
     58    },
    3559    {
    3660        Name => 'MakerNoteCanon',
     
    6488            ByteOrder => 'Unknown',
    6589            FixBase => 1, # necessary for AVI and MOV videos
     90        },
     91    },
     92    {
     93        Name => 'MakerNoteDJI',
     94        Condition => '$$self{Make} eq "DJI" and $$valPt !~ /^...\@AMBA/s',
     95        SubDirectory => {
     96            TagTable => 'Image::ExifTool::DJI::Main',
     97            Start => '$valuePtr',
     98            ByteOrder => 'Unknown',
     99        },
     100    },
     101    {
     102        Name => 'MakerNoteFLIR',
     103        # (starts with IFD, Make is 'FLIR Systems AB' or 'FLIR Systems')
     104        Condition => '$$self{Make} =~ /^FLIR Systems/',
     105        SubDirectory => {
     106            TagTable => 'Image::ExifTool::FLIR::Main',
     107            Start => '$valuePtr',
     108            ByteOrder => 'Unknown',
    66109        },
    67110    },
     
    109152       },
    110153    },
     154    {
     155        Name => 'MakerNoteHasselblad',
     156        Condition => '$$self{Make} eq "Hasselblad"',
     157        SubDirectory => {
     158            TagTable => 'Image::ExifTool::Unknown::Main',
     159            ByteOrder => 'Unknown',
     160            Start => '$valuePtr',
     161            Base => 0, # (avoids warnings since maker notes are not self-contained)
     162        },
     163        # 0x0011 - sensor code (ref IB)
     164        # 0x0012 - camera model id?
     165        # 0x0015 - camera model name
     166        # 0x0016 - coating code (ref IB)
     167    },
    111168    # (the GE X5 has really messed up EXIF-like maker notes starting with
    112169    #  "GENIC\x0c\0" --> currently not decoded)
     
    310367    {
    311368        Name => 'MakerNoteKodak8b',
     369        # these maker notes have an extra 2 bytes after the entry count
     370        # (this is handled by the patch).  Also, the IFD uses a Format 13,
     371        # which is some 2-byte format (not Float, as decoded by ExifTool)
     372        # - written by the PixPro AZ251, AZ361, AZ262, AZ521
     373        Condition => q{
     374            $$self{Make}=~/Kodak/i and
     375            $$valPt =~ /^MM\0\x2a\0\0\0\x08\0.\0\0/
     376        },
     377        SubDirectory => {
     378            TagTable => 'Image::ExifTool::Kodak::Type8',
     379            ProcessProc => \&ProcessKodakPatch,
     380            ByteOrder => 'BigEndian',
     381            Start => '$valuePtr + 8',
     382            Base => '$start - 8',
     383        },
     384    },
     385    {
     386        Name => 'MakerNoteKodak8c',
    312387        # TIFF-format maker notes
    313388        Condition => q{
     
    347422            ByteOrder => 'Unknown',
    348423            Start => '$valuePtr + 2',
     424        },
     425    },
     426    {
     427        Name => 'MakerNoteKodak11',
     428        # these maker notes have a 4-byte entry count
     429        # - written by the PixPro S-1 (Note: Make is "JK Imaging, Ltd.", so check Model for "Kodak")
     430        Condition => q{
     431            $$self{Model}=~/(Kodak|PixPro)/i and
     432            $$valPt =~ /^II\x2a\0\x08\0\0\0.\0\0\0/s
     433        },
     434        SubDirectory => {
     435            TagTable => 'Image::ExifTool::Kodak::Type11',
     436            ProcessProc => \&ProcessKodakPatch,
     437            ByteOrder => 'LittleEndian',
     438            Start => '$valuePtr + 8',
     439            Base => '$start - 8',
     440        },
     441    },
     442    {
     443        Name => 'MakerNoteKodak12',
     444        # these maker notes have a 4-byte entry count
     445        # - written by the PixPro AZ901 (Note: Make is "JK Imaging, Ltd.", so check Model for "Kodak")
     446        Condition => q{
     447            $$self{Model}=~/(Kodak|PixPro)/i and
     448            $$valPt =~ /^MM\0\x2a\0\0\0\x08\0\0\0./s
     449        },
     450        SubDirectory => {
     451            TagTable => 'Image::ExifTool::Kodak::Type11',
     452            ProcessProc => \&ProcessKodakPatch,
     453            ByteOrder => 'BigEndian',
     454            Start => '$valuePtr + 8',
     455            Base => '$start - 8',
    349456        },
    350457    },
     
    404511    },
    405512    {
    406         # this maker notes starts with a standard TIFF header at offset 0x0a
    407         Name => 'MakerNoteNikon',
    408         Condition => '$$self{Make}=~/^NIKON/i and $$valPt=~/^Nikon\x00\x02/',
    409         SubDirectory => {
    410             TagTable => 'Image::ExifTool::Nikon::Main',
    411             Start => '$valuePtr + 18',
     513        Name => 'MakerNoteMotorola',
     514        Condition => '$$valPt=~/^MOT\0/',
     515        SubDirectory => {
     516            TagTable => 'Image::ExifTool::Motorola::Main',
     517            Start => '$valuePtr + 8',
    412518            Base => '$start - 8',
    413519            ByteOrder => 'Unknown',
     
    417523        # older Nikon maker notes
    418524        Name => 'MakerNoteNikon2',
    419         Condition => '$$self{Make}=~/^NIKON/ and $$valPt=~/^Nikon\x00\x01/',
     525        Condition => '$$valPt=~/^Nikon\x00\x01/',
    420526        SubDirectory => {
    421527            TagTable => 'Image::ExifTool::Nikon::Type2',
     
    431537            TagTable => 'Image::ExifTool::Nikon::Main',
    432538            ByteOrder => 'Unknown', # most are little-endian, but D1 is big
     539        },
     540    },
     541    {
     542        Name => 'MakerNoteNintendo',
     543        # (starts with an IFD)
     544        Condition => '$$self{Make} eq "Nintendo"',
     545        SubDirectory => {
     546            TagTable => 'Image::ExifTool::Nintendo::Main',
     547            ByteOrder => 'Unknown',
    433548        },
    434549    },
     
    485600        Name => 'MakerNoteLeica3', # used by the R8 and R9
    486601        # (starts with IFD)
    487         Condition => '$$self{Make} =~ /^Leica Camera AG/ and $$valPt !~ /^LEICA/ and $$self{Model} ne "S2"',
     602        Condition => q{
     603            $$self{Make} =~ /^Leica Camera AG/ and $$valPt !~ /^LEICA/ and
     604            $$self{Model} ne "S2" and $$self{Model} ne "LEICA M (Typ 240)"
     605        },
    488606        SubDirectory => {
    489607            TagTable => 'Image::ExifTool::Panasonic::Leica3',
     
    493611    },
    494612    {
    495         Name => 'MakerNoteLeica4', # used by the M9
    496         # (M9 starts with "LEICA0\x03\0")
     613        Name => 'MakerNoteLeica4', # used by the M9/M-Monochrom
     614        # (M9 and M Monochrom start with "LEICA0\x03\0")
    497615        Condition => '$$self{Make} =~ /^Leica Camera AG/ and $$valPt =~ /^LEICA0/',
    498616        SubDirectory => {
     
    504622    },
    505623    {
    506         Name => 'MakerNoteLeica5', # used by the X1
     624        Name => 'MakerNoteLeica5', # used by the X1/X2/X VARIO/T/X-U
    507625        # (X1 starts with "LEICA\0\x01\0", Make is "LEICA CAMERA AG")
    508         Condition => '$$valPt =~ /^LEICA\0\x01\0/',
     626        # (X2 starts with "LEICA\0\x05\0", Make is "LEICA CAMERA AG")
     627        # (X VARIO starts with "LEICA\0\x04\0", Make is "LEICA CAMERA AG")
     628        # (T (Typ 701) starts with "LEICA\0\0x6", Make is "LEICA CAMERA AG")
     629        # (X (Typ 113) starts with "LEICA\0\0x7", Make is "LEICA CAMERA AG")
     630        # (X-U (Typ 113) starts with "LEICA\0\x10\0", Make is "LEICA CAMERA AG")
     631        Condition => '$$valPt =~ /^LEICA\0[\x01\x04\x05\x06\x07\x10\x1a]\0/',
    509632        SubDirectory => {
    510633            TagTable => 'Image::ExifTool::Panasonic::Leica5',
     
    515638    },
    516639    {
    517         Name => 'MakerNoteLeica6', # used by the S2 (CAUTION: this tag name is special cased in the code)
    518         # (S2 starts with "LEICA\0\x02\xff", Make is "LEICA CAMERA AG",
    519         #  but maker notes aren't loaded at the time this is tested)
    520         Condition => '$$self{Model} eq "S2"',
     640        Name => 'MakerNoteLeica6', # used by the S2, M (Typ 240) and S (Typ 006)
     641        # (starts with "LEICA\0\x02\xff", Make is "Leica Camera AG", but test the
     642        # model names separately because the maker notes data may not be loaded
     643        # at the time this is tested if they are in a JPEG trailer.  Also, this
     644        # header is used by the M Monochrom (Type 246), with different offsets.)
     645        Condition => q{
     646            ($$self{Make} eq 'Leica Camera AG' and ($$self{Model} eq 'S2' or
     647            $$self{Model} eq 'LEICA M (Typ 240)' or $$self{Model} eq 'LEICA S (Typ 006)'))
     648        },
    521649        DataTag => 'LeicaTrailer',  # (generates fixup name for this tag)
     650        LeicaTrailer => 1, # flag to special-case this tag in the Exif code
    522651        SubDirectory => {
    523652            TagTable => 'Image::ExifTool::Panasonic::Leica6',
     
    527656            # as a JPEG trailer -- this case is handled by ProcessLeicaTrailer in
    528657            # Panasonic.pm, and any "Base" defined here is ignored for this case.
    529             # ExifTool may also create S2 maker notes inside the APP1 segment when
     658            # ExifTool may also create S2/M maker notes inside the APP1 segment when
    530659            # copying from other files, and for this the normal EXIF offsets are used,
    531660            # Base should not be defined!
     
    533662    },
    534663    {
     664        Name => 'MakerNoteLeica7', # used by the M Monochrom (Typ 246)
     665        # (starts with "LEICA\0\x02\xff", Make is "Leica Camera AG")
     666        Condition => '$$valPt =~ /^LEICA\0\x02\xff/',
     667        DataTag => 'LeicaTrailer',  # (generates fixup name for this tag)
     668        LeicaTrailer => 1, # flag to special-case this tag in the Exif code
     669        SubDirectory => {
     670            TagTable => 'Image::ExifTool::Panasonic::Leica6',
     671            Start => '$valuePtr + 8',
     672            ByteOrder => 'Unknown',
     673            Base => '-$base',  # uses absolute file offsets (not based on TIFF header offset)
     674        },
     675    },
     676    {
     677        Name => 'MakerNoteLeica8', # used by the Q (Type 116)
     678        # (Q (Typ 116) starts with "LEICA\0\x08\0", Make is "LEICA CAMERA AG")
     679        # (SL (Typ 601) and CL start with "LEICA\0\x09\0", Make is "LEICA CAMERA AG")
     680        Condition => '$$valPt =~ /^LEICA\0[\x08\x09]\0/',
     681        SubDirectory => {
     682            TagTable => 'Image::ExifTool::Panasonic::Leica5',
     683            Start => '$valuePtr + 8',
     684            ByteOrder => 'Unknown',
     685        },
     686    },
     687    {
     688        Name => 'MakerNoteLeica9', # used by the M10/S
     689        # (M10 and S start with "LEICA0\x02\0")
     690        Condition => '$$self{Make} =~ /^Leica Camera AG/ and $$valPt =~ /^LEICA\0\x02\0/',
     691        SubDirectory => {
     692            TagTable => 'Image::ExifTool::Panasonic::Leica9',
     693            Start => '$valuePtr + 8',
     694            ByteOrder => 'Unknown',
     695        },
     696    },
     697    {
     698        Name => 'MakerNoteLeica10', # used by the D-Lux7
     699        Condition => '$$valPt =~ /^LEICA CAMERA AG\0/',
     700        SubDirectory => {
     701            TagTable => 'Image::ExifTool::Panasonic::Main',
     702            Start => '$valuePtr + 18',
     703            ByteOrder => 'Unknown',
     704        },
     705    },
     706    {
    535707        Name => 'MakerNotePanasonic',
    536708        # (starts with "Panasonic\0")
    537         Condition => '$$valPt=~/^Panasonic/',
     709        Condition => '$$valPt=~/^Panasonic/ and $$self{Model} ne "DC-FT7"',
    538710        SubDirectory => {
    539711            TagTable => 'Image::ExifTool::Panasonic::Main',
     
    549721            TagTable => 'Image::ExifTool::Panasonic::Type2',
    550722            ByteOrder => 'LittleEndian',
     723        },
     724    },
     725    {
     726        Name => 'MakerNotePanasonic3', # (DC-FT7)
     727        # (starts with "Panasonic\0")
     728        Condition => '$$valPt=~/^Panasonic/',
     729        SubDirectory => {
     730            TagTable => 'Image::ExifTool::Panasonic::Main',
     731            Start => '$valuePtr + 12',
     732            Base => 12, # crazy!
     733            ByteOrder => 'Unknown',
    551734        },
    552735    },
     
    609792        Name => 'MakerNotePentax5',
    610793        # (starts with "PENTAX \0")
     794        # used by cameras such as the Q, Optio S1, RS1500 and WG-1
    611795        Condition => '$$valPt=~/^PENTAX \0/',
    612796        SubDirectory => {
     
    618802    },
    619803    {
     804        Name => 'MakerNotePentax6',
     805        # (starts with "S1\0\0\0\0\0\0\x0c\0\0\0")
     806        Condition => '$$valPt=~/^S1\0{6}\x0c\0{3}/',
     807        SubDirectory => {
     808            TagTable => 'Image::ExifTool::Pentax::S1',
     809            Start => '$valuePtr + 12',
     810            Base => '$start - 12',
     811            ByteOrder => 'Unknown',
     812        },
     813    },
     814    {
    620815        Name => 'MakerNotePhaseOne',
    621816        # Starts with: 'IIIITwaR' or 'IIIICwaR' (have seen both written by P25)
     
    627822        },
    628823        NotIFD => 1,
    629         Binary => 1,
    630         PutFirst => 1, # place immediately after TIFF header
    631         Notes => 'the raw image data in PhaseOne IIQ images',
     824        IsPhaseOne => 1,    # flag to rebuild these differently
     825        SubDirectory => { TagTable => 'Image::ExifTool::PhaseOne::Main' },
     826        PutFirst => 1,      # place immediately after TIFF header
    632827    },
    633828    {
    634829        Name => 'MakerNoteReconyx',
    635         Condition => '$$valPt =~ /^\x01\xf1[\x02\x03]\x00/',
     830        Condition => q{
     831            $$valPt =~ /^\x01\xf1([\x02\x03]\x00)?/ and
     832            ($1 or $$self{Make} eq "RECONYX")
     833        },
    636834        SubDirectory => {
    637835            TagTable => 'Image::ExifTool::Reconyx::Main',
     
    640838    },
    641839    {
     840        Name => 'MakerNoteReconyx2',
     841        Condition => '$$valPt =~ /^RECONYXUF\0/',
     842        SubDirectory => {
     843            TagTable => 'Image::ExifTool::Reconyx::Type2',
     844            ByteOrder => 'Little-endian',
     845        },
     846    },
     847    {
     848        Name => 'MakerNoteReconyx3',
     849        Condition => '$$valPt =~ /^RECONYXH2\0/',
     850        SubDirectory => {
     851            TagTable => 'Image::ExifTool::Reconyx::Type3',
     852            ByteOrder => 'Little-endian',
     853        },
     854    },
     855    {
     856        Name => 'MakerNoteRicohPentax',
     857        # used by cameras such as the Ricoh GR III
     858        Condition => '$$valPt=~/^RICOH\0(II|MM)/',
     859        SubDirectory => {
     860            TagTable => 'Image::ExifTool::Pentax::Main',
     861            Start => '$valuePtr + 8',
     862            Base => '$start - 8',
     863            ByteOrder => 'Unknown',
     864        },
     865    },
     866    {
    642867        Name => 'MakerNoteRicoh',
    643868        # (my test R50 image starts with "      \x02\x01" - PH)
    644         Condition => '$$self{Make}=~/^RICOH/ and $$valPt=~/^(Ricoh|      )/i',
     869        Condition => q{
     870            $$self{Make} =~ /^(PENTAX )?RICOH/ and
     871            $$valPt =~ /^(Ricoh|      |MM\0\x2a|II\x2a\0)/i and
     872            $$valPt !~ /^(MM\0\x2a\0\0\0\x08\0.\0\0|II\x2a\0\x08\0\0\0.\0\0\0)/s and
     873            $$self{Model} ne 'RICOH WG-M1'
     874        },
    645875        SubDirectory => {
    646876            TagTable => 'Image::ExifTool::Ricoh::Main',
    647877            Start => '$valuePtr + 8',
    648878            ByteOrder => 'Unknown',
     879        },
     880    },
     881    {
     882        Name => 'MakerNoteRicoh2',
     883        # (the Ricoh HZ15 starts with "MM\0\x2a" and the Pentax XG-1 starts with "II\x2a\0",
     884        # but an extra 2 bytes of padding after the IFD entry count prevents these from
     885        # being processed as a standard IFD.  Note that the offsets for the HZ15 are all
     886        # zeros, but they seem to be mostly OK for the XG-1)
     887        Condition => q{
     888            $$self{Make} =~ /^(PENTAX )?RICOH/ and ($$self{Model} eq 'RICOH WG-M1' or
     889            $$valPt =~ /^(MM\0\x2a\0\0\0\x08\0.\0\0|II\x2a\0\x08\0\0\0.\0\0\0)/s)
     890        },
     891        SubDirectory => {
     892            TagTable => 'Image::ExifTool::Ricoh::Type2',
     893            Start => '$valuePtr + 8',
     894            Base => '$start - 8',
     895            ByteOrder => 'Unknown',
     896            ProcessProc => \&ProcessKodakPatch,
    649897        },
    650898    },
     
    670918        Condition => '$$valPt =~ /^STMN\d{3}/',
    671919        SubDirectory => {
    672             TagTable => 'Image::ExifTool::Samsung::Type1',
     920            TagTable => 'Image::ExifTool::Samsung::Main',
    673921        },
    674922    },
    675923    {
    676924        Name => 'MakerNoteSamsung2',
    677         # Samsung EXIF-format maker notes
    678         Condition => q{
    679             $$self{Make} eq 'SAMSUNG' and ($$self{TIFF_TYPE} eq 'SRW' or
     925        # Samsung EXIF-format maker notes (
     926        Condition => q{
     927            uc $$self{Make} eq 'SAMSUNG' and ($$self{TIFF_TYPE} eq 'SRW' or
    680928            $$valPt=~/^(\0.\0\x01\0\x07\0{3}\x04|.\0\x01\0\x07\0\x04\0{3})0100/s)
    681929        },
     
    726974    {
    727975        Name => 'MakerNoteSigma',
    728         # (starts with "SIGMA\0")
    729         Condition => '$$self{Make}=~/^(SIGMA|FOVEON)/',
     976        Condition => q{
     977            return undef unless $$self{Make}=~/^(SIGMA|FOVEON)/;
     978            # save version number in "MakerNoteSigmaVer" member variable
     979            $$self{MakerNoteSigmaVer} = $$valPt=~/^SIGMA\0\0\0\0(.)/ ? ord($1) : -1;
     980            return 1;
     981        },
    730982        SubDirectory => {
    731983            TagTable => 'Image::ExifTool::Sigma::Main',
     
    738990        Name => 'MakerNoteSony',
    739991        # (starts with "SONY DSC \0" or "SONY CAM \0")
    740         Condition => '$$self{Make}=~/^SONY/ and $$valPt=~/^SONY (DSC|CAM)/',
     992        # (TF1 starts with "\0\0SONY PIC\0")
     993        # (Hasselblad models start with "VHAB     \0")
     994        Condition => '$$valPt=~/^(SONY (DSC|CAM|MOBILE)|\0\0SONY PIC\0|VHAB     \0)/',
    741995        SubDirectory => {
    742996            TagTable => 'Image::ExifTool::Sony::Main',
     
    7481002        Name => 'MakerNoteSony2',
    7491003        # (starts with "SONY PI\0" -- DSC-S650/S700/S750)
    750         Condition => '$$self{Make}=~/^SONY/ and $$valPt=~/^SONY PI\0/ and $$self{OlympusCAMER}=1',
     1004        Condition => '$$valPt=~/^SONY PI\0/ and $$self{OlympusCAMER}=1',
    7511005        SubDirectory => {
    7521006            TagTable => 'Image::ExifTool::Olympus::Main',
     
    7581012        Name => 'MakerNoteSony3',
    7591013        # (starts with "PREMI\0" -- DSC-S45/S500)
    760         Condition => '$$self{Make}=~/^SONY/ and $$valPt=~/^(PREMI)\0/ and $$self{OlympusCAMER}=1',
     1014        Condition => '$$valPt=~/^(PREMI)\0/ and $$self{OlympusCAMER}=1',
    7611015        SubDirectory => {
    7621016            TagTable => 'Image::ExifTool::Olympus::Main',
     
    7661020    },
    7671021    {
    768         Name => 'MakerNoteSony4', # used in SR2 and ARW images
     1022        Name => 'MakerNoteSony4',
     1023        # (starts with "SONY PIC\0" -- DSC-H200/J20/W370/W510, MHS-TS20)
     1024        Condition => '$$valPt=~/^SONY PIC\0/',
     1025        SubDirectory => { TagTable => 'Image::ExifTool::Sony::PIC' },
     1026    },
     1027    {
     1028        Name => 'MakerNoteSony5', # used in SR2 and ARW images
    7691029        Condition => '$$self{Make}=~/^SONY/ and $$valPt!~/^\x01\x00/',
     1030        Condition => q{
     1031            ($$self{Make}=~/^SONY/ or ($$self{Make}=~/^HASSELBLAD/ and
     1032            $$self{Model}=~/^(HV|Stellar|Lusso|Lunar)/)) and $$valPt!~/^\x01\x00/
     1033        },
    7701034        SubDirectory => {
    7711035            TagTable => 'Image::ExifTool::Sony::Main',
     
    8021066    },
    8031067    {
     1068        Name => 'MakerNoteUnknownBinary',
     1069        # "LSI1\0" - SilverFast
     1070        Condition => '$$valPt =~ /^LSI1\0/',
     1071        Notes => 'unknown binary maker notes',
     1072        Binary => 1,
     1073    },
     1074    {
    8041075        Name => 'MakerNoteUnknown',
    8051076        PossiblePreview => 1,
     
    8181089foreach $tagInfo (@Image::ExifTool::MakerNotes::Main) {
    8191090    $$tagInfo{Writable} = 'undef';
     1091    $$tagInfo{Format} = 'undef', # (make sure we don't convert this when reading)
    8201092    $$tagInfo{WriteGroup} = 'ExifIFD';
    8211093    $$tagInfo{Groups} = { 1 => 'MakerNotes' };
     
    8351107sub GetMakerNoteOffset($)
    8361108{
    837     my $exifTool = shift;
     1109    my $et = shift;
    8381110    # figure out where we expect the value data based on camera type
    839     my $make = $exifTool->{Make};
    840     my $model = $exifTool->{Model};
     1111    my $make = $$et{Make};
     1112    my $model = $$et{Model};
    8411113    my ($relative, @offsets);
    8421114
     
    8551127        # except some models like the EX-S770,Z65,Z70,Z75 and Z700 which use 16,
    8561128        # and the EX-Z35 which uses 2 (grrrr...)
    857         push @offsets, $$exifTool{FILE_TYPE} =~ /^(RIFF|MOV)$/ ? 0 : (4, 16, 2);
     1129        push @offsets, $$et{FILE_TYPE} =~ /^(RIFF|MOV)$/ ? 0 : (4, 16, 2);
    8581130    } elsif ($make =~ /^(General Imaging Co.|GEDSC IMAGING CORP.)/i) {
    8591131        push @offsets, 0;
     
    8631135        if ($model eq 'S2') {
    8641136            # lots of empty space before first value in S2 images
    865             push @offsets, 4, ($$exifTool{FILE_TYPE} eq 'JPEG' ? 286 : 274);
     1137            push @offsets, 4, ($$et{FILE_TYPE} eq 'JPEG' ? 286 : 274);
     1138        } elsif ($model eq 'LEICA M MONOCHROM (Typ 246)') {
     1139            push @offsets, 4, 130;
     1140        } elsif ($model eq 'LEICA M (Typ 240)') {
     1141            push @offsets, 4, 118;
    8661142        } elsif ($model =~ /^(R8|R9|M8)\b/) {
    8671143            push @offsets, 6;
     
    8791155        push @offsets, 0;
    8801156    } elsif ($make =~ /^SONY/) {
    881         # DSLR and "PREMI" models use an offset of 4
    882         if ($model =~ /DSLR/ or $$exifTool{OlympusCAMER}) {
     1157        # earlier DSLR and "PREMI" models use an offset of 4
     1158        if ($model =~ /^(DSLR-.*|SLT-A(33|35|55V)|NEX-(3|5|C3|VG10E))$/ or
     1159            $$et{OlympusCAMER})
     1160        {
    8831161            push @offsets, 4;
    8841162        } else {
    8851163            push @offsets, 0;
    8861164        }
     1165    } elsif ($$et{TIFF_TYPE} eq 'SRW' and $make eq 'SAMSUNG' and $model eq 'EK-GN120') {
     1166        push @offsets, 40;  # patch to read most of the maker notes, but breaks PreviewIFD
    8871167    } elsif ($make eq 'FUJIFILM') {
    8881168        # some models have offset of 6, so allow that too (A345,A350,A360,A370)
     
    9611241{
    9621242    local $_;
    963     my ($exifTool, $dirInfo) = @_;
     1243    my ($et, $dirInfo) = @_;
    9641244    # don't fix base if fixing offsets individually or if we don't want to fix them
    9651245    return 0 if $$dirInfo{FixOffsets} or $$dirInfo{NoFixBase};
     
    9701250    my $entryBased = $$dirInfo{EntryBased};
    9711251    my $dirName = $$dirInfo{DirName};
    972     my $fixBase = $exifTool->Options('FixBase');
     1252    my $fixBase = $et->Options('FixBase');
    9731253    my $setBase = (defined $fixBase and $fixBase ne '') ? 1 : 0;
    9741254    my ($fix, $fixedBy, %tagPtr);
     
    9821262# handle special case of Canon maker notes with TIFF footer containing original offset
    9831263#
    984     if ($$exifTool{Make} =~ /^Canon/ and $$dirInfo{DirLen} > 8) {
     1264    if ($$et{Make} =~ /^Canon/ and $$dirInfo{DirLen} > 8) {
    9851265        my $footerPos = $dirStart + $$dirInfo{DirLen} - 8;
    9861266        my $footer = substr($$dataPt, $footerPos, 8);
     
    10041284                # (allow for possible padding byte, although I have never seen this)
    10051285                if (not $endDiff or $endDiff == 1) {
    1006                     $exifTool->Warn('Canon maker note footer may be invalid (ignored)',1);
     1286                    $et->Warn('Canon maker note footer may be invalid (ignored)',1);
    10071287                    return 0;
    10081288                }
    10091289            }
    1010             $exifTool->Warn("Adjusted $dirName base by $fix",1);
     1290            $et->Warn("Adjusted $dirName base by $fix",1);
    10111291            $$dirInfo{FixedBy} = $fix;
    10121292            $$dirInfo{Base} += $fix;
     
    10231303    my $ifdLen = 2 + 12 * Get16u($$dirInfo{DataPt}, $dirStart);
    10241304    my $ifdEnd = $dirStart + $ifdLen;
    1025     my ($relative, @offsets) = GetMakerNoteOffset($exifTool);
     1305    my ($relative, @offsets) = GetMakerNoteOffset($et);
    10261306    my $makeDiff = $offsets[0];
    1027     my $verbose = $exifTool->Options('Verbose');
     1307    my $verbose = $et->Options('Verbose');
    10281308    my ($diff, $shift);
    10291309
     
    10661346        # which have been correcting for individual entry position
    10671347        $entryBased = 1;
    1068         $verbose and $exifTool->Warn("$dirName offsets are entry-based",1);
     1348        $verbose and $et->Warn("$dirName offsets are entry-based",1);
    10691349    } else {
    10701350        # calculate offset difference from end of IFD to first value
    10711351        $diff = ($minPt - $dataPos) - $ifdEnd;
    10721352        $shift = 0;
    1073         $countOverlap and $exifTool->Warn("Overlapping $dirName values",1);
     1353        $countOverlap and $et->Warn("Overlapping $dirName values",1);
    10741354        if ($entryBased) {
    1075             $exifTool->Warn("$dirName offsets do NOT look entry-based",1);
     1355            $et->Warn("$dirName offsets do NOT look entry-based",1);
    10761356            undef $entryBased;
    10771357            undef $relative;
     
    10871367            return 0 if $diff >=0 and $diff <= 24;
    10881368        }
    1089         # (used for testing to extract differences)
    1090         # $exifTool->FoundTag('Diff', $diff);
     1369        # ******** (used for testing to extract differences) ********
     1370        # $et->FoundTag('Diff', $diff);
     1371        # $et->FoundTag('MakeDiff',$makeDiff);
    10911372    }
    10921373#
     
    11471428        # print warning unless difference looks reasonable
    11481429        if ($diff < 0 or $diff > 16 or ($diff & 0x01)) {
    1149             $exifTool->Warn("Possibly incorrect maker notes offsets (fix by $fix?)",1);
     1430            $et->Warn("Possibly incorrect maker notes offsets (fix by $fix?)",1);
    11501431        }
    11511432        # don't do the fix (but we already adjusted base if entry-based)
     
    11531434    }
    11541435    if (defined $fixedBy) {
    1155         $exifTool->Warn("Adjusted $dirName base by $fixedBy",1);
     1436        $et->Warn("Adjusted $dirName base by $fixedBy",1);
    11561437        $$dirInfo{FixedBy} = $fixedBy;
    11571438    }
     
    11711452sub LocateIFD($$)
    11721453{
    1173     my ($exifTool, $dirInfo) = @_;
     1454    my ($et, $dirInfo) = @_;
    11741455    my $dataPt = $$dirInfo{DataPt};
    11751456    my $dirStart = $$dirInfo{DirStart} || 0;
    11761457    # (ignore MakerNotes DirLen since sometimes this is incorrect)
    11771458    my $size = $$dirInfo{DataLen} - $dirStart;
    1178     my $dirLen = $$dirInfo{DirLen} || $size;
     1459    my $dirLen = defined $$dirInfo{DirLen} ? $$dirInfo{DirLen} : $size;
    11791460    my $tagInfo = $$dirInfo{TagInfo};
    11801461    my $ifdOffsetPos;
     
    11911472    if ($tagInfo and $$tagInfo{SubDirectory}) {
    11921473        my $subdir = $$tagInfo{SubDirectory};
    1193         unless ($$subdir{ProcessProc} and 
     1474        unless ($$subdir{ProcessProc} and
    11941475               ($$subdir{ProcessProc} eq \&ProcessUnknown or
    11951476                $$subdir{ProcessProc} eq \&ProcessUnknownOrPreview))
     
    12201501                        my $oldStart = $$dirInfo{DirStart};
    12211502                        $$dirInfo{DirStart} = $newStart;
    1222                         FixLeicaBase($exifTool, $dirInfo);
     1503                        FixLeicaBase($et, $dirInfo);
    12231504                        $$dirInfo{DirStart} = $oldStart;
    12241505                    }
     
    12981579                my $format = Get16u($dataPt, $entry+2);
    12991580                my $count = Get32u($dataPt, $entry+4);
    1300                 # allow everything to be zero if not first entry
    1301                 # because some manufacturers pad with null entries
    1302                 next unless $format or $count or $index == 0;
    1303                 # patch for Canon EOS 40D firmware 1.0.4 bug: allow zero format for last entry
    1304                 next if $format==0 and $index==$num-1 and $$exifTool{Model}=~/EOS 40D/;
     1581                unless ($format) {
     1582                    # patch for buggy Samsung NX200 JPEG MakerNotes entry count
     1583                    if ($num == 23 and $index == 21 and $$et{Make} eq 'SAMSUNG') {
     1584                        Set16u(21, $dataPt, $pos);  # really 21 IFD entries!
     1585                        $et->Warn('Fixed incorrect Makernote entry count', 1);
     1586                        last;
     1587                    }
     1588                    # allow everything to be zero if not first entry
     1589                    # because some manufacturers pad with null entries
     1590                    next unless $count or $index == 0;
     1591                    # patch for Canon EOS 40D firmware 1.0.4 bug: allow zero format for last entry
     1592                    next if $index==$num-1 and $$et{Model}=~/EOS 40D/;
     1593                }
     1594                # patch for Sony cameras like the DSC-P10 that have invalid MakerNote entries
     1595                next if $num == 12 and $$et{Make} eq 'SONY' and $index >= 8;
    13051596                # (would like to verify tag ID, but some manufactures don't
    13061597                #  sort entries in order of tag ID so we don't have much of
     
    13341625sub FixLeicaBase($$;$)
    13351626{
    1336     my ($exifTool, $dirInfo, $tagTablePtr) = @_;
     1627    my ($et, $dirInfo, $tagTablePtr) = @_;
    13371628    my $dataPt = $$dirInfo{DataPt};
    13381629    my $dirStart = $$dirInfo{DirStart} || 0;
     
    13511642    my $success = 1;
    13521643    if ($tagTablePtr) {
    1353         $success = Image::ExifTool::Exif::ProcessExif($exifTool, $dirInfo, $tagTablePtr);
     1644        $success = Image::ExifTool::Exif::ProcessExif($et, $dirInfo, $tagTablePtr);
    13541645    }
    13551646    return $success;
     
    13621653sub ProcessCanon($$$)
    13631654{
    1364     my ($exifTool, $dirInfo, $tagTablePtr) = @_;
     1655    my ($et, $dirInfo, $tagTablePtr) = @_;
    13651656    # identify Canon MakerNote footer in HtmlDump
    13661657    # (this code moved from FixBase so it also works for Adobe MakN in DNG images)
    1367     if ($$exifTool{HTML_DUMP} and $$dirInfo{DirLen} > 8) {
     1658    if ($$et{HTML_DUMP} and $$dirInfo{DirLen} > 8) {
    13681659        my $dataPos = $$dirInfo{DataPos};
    13691660        my $dirStart = $$dirInfo{DirStart} || 0;
     
    13781669            }
    13791670            my $filePos = ($$dirInfo{Base} || 0) + $dataPos + $footerPos;
    1380             $exifTool->HDump($filePos, 8, '[Canon MakerNotes footer]', $str);
     1671            $et->HDump($filePos, 8, '[Canon MakerNotes footer]', $str);
    13811672        }
    13821673    }
    13831674    # process as normal
    1384     return Image::ExifTool::Exif::ProcessExif($exifTool, $dirInfo, $tagTablePtr);
     1675    return Image::ExifTool::Exif::ProcessExif($et, $dirInfo, $tagTablePtr);
    13851676}
    13861677
     
    13911682sub ProcessGE2($$$)
    13921683{
    1393     my ($exifTool, $dirInfo, $tagTablePtr) = @_;
     1684    my ($et, $dirInfo, $tagTablePtr) = @_;
    13941685    my $dataPt = $$dirInfo{DataPt} or return 0;
    13951686    my $dirStart = $$dirInfo{DirStart} || 0;
     
    13981689    # always have 25 entries, so write the entry count manually
    13991690    Set16u(25, $dataPt, $dirStart);
    1400     return Image::ExifTool::Exif::ProcessExif($exifTool, $dirInfo, $tagTablePtr);
     1691    return Image::ExifTool::Exif::ProcessExif($et, $dirInfo, $tagTablePtr);
     1692}
     1693
     1694#------------------------------------------------------------------------------
     1695# Process broken Kodak type 8b maker notes
     1696# Inputs: 0) ExifTool object ref, 1) DirInfo ref, 2) tag table ref
     1697# Returns: 1 on success
     1698sub ProcessKodakPatch($$$)
     1699{
     1700    my ($et, $dirInfo, $tagTablePtr) = @_;
     1701    my $dataPt = $$dirInfo{DataPt} or return 0;
     1702    my $dirStart = $$dirInfo{DirStart} || 0;
     1703
     1704    # these maker notes have an 2 extra null bytes either before or after the entry count,
     1705    # so fix this by making a 2-byte entry count just before the first IFD entry
     1706    return 0 unless $$dirInfo{DirLen} >= 4;
     1707    my $t1 = Get16u($dataPt,$dirStart);
     1708    my $t2 = Get16u($dataPt,$dirStart+2);
     1709    Set16u($t1 || $t2, $dataPt, $dirStart+2);
     1710    $$dirInfo{DirStart} += 2;
     1711    return Image::ExifTool::Exif::ProcessExif($et, $dirInfo, $tagTablePtr);
    14011712}
    14021713
     
    14071718sub ProcessUnknownOrPreview($$$)
    14081719{
    1409     my ($exifTool, $dirInfo, $tagTablePtr) = @_;
     1720    my ($et, $dirInfo, $tagTablePtr) = @_;
    14101721    my $dataPt = $$dirInfo{DataPt};
    14111722    my $dirStart = $$dirInfo{DirStart};
     
    14131724    # check to see if this is a preview image
    14141725    if ($dirLen > 6 and substr($$dataPt, $dirStart, 3) eq "\xff\xd8\xff") {
    1415         $exifTool->VerboseDir('PreviewImage');
    1416         if ($$exifTool{HTML_DUMP}) {
     1726        $et->VerboseDir('PreviewImage');
     1727        if ($$et{HTML_DUMP}) {
    14171728            my $pos = $$dirInfo{DataPos} + $$dirInfo{Base} + $dirStart;
    1418             $exifTool->HDump($pos, $dirLen, '(MakerNotes:PreviewImage data)', "Size: $dirLen bytes")
    1419         }
    1420         $exifTool->FoundTag('PreviewImage', substr($$dataPt, $dirStart, $dirLen));
     1729            $et->HDump($pos, $dirLen, '(MakerNotes:PreviewImage data)', "Size: $dirLen bytes")
     1730        }
     1731        $et->FoundTag('PreviewImage', substr($$dataPt, $dirStart, $dirLen));
    14211732        return 1;
    14221733    }
    1423     return ProcessUnknown($exifTool, $dirInfo, $tagTablePtr);
     1734    return ProcessUnknown($et, $dirInfo, $tagTablePtr);
    14241735}
    14251736
     
    14301741sub WriteUnknownOrPreview($$$)
    14311742{
    1432     my ($exifTool, $dirInfo, $tagTablePtr) = @_;
     1743    my ($et, $dirInfo, $tagTablePtr) = @_;
    14331744    my $dataPt = $$dirInfo{DataPt};
    14341745    my $dirStart = $$dirInfo{DirStart};
     
    14371748    # check to see if this is a preview image
    14381749    if ($dirLen > 6 and substr($$dataPt, $dirStart, 3) eq "\xff\xd8\xff") {
    1439         if ($$exifTool{NEW_VALUE}{$Image::ExifTool::Extra{PreviewImage}}) {
     1750        if ($$et{NEW_VALUE}{$Image::ExifTool::Extra{PreviewImage}}) {
    14401751            # write or delete new preview (if deleted, it can't currently be added back again)
    1441             $newVal = $exifTool->GetNewValues('PreviewImage') || '';
    1442             if ($exifTool->Options('Verbose') > 1) {
    1443                 $exifTool->VerboseValue("- MakerNotes:PreviewImage", substr($$dataPt, $dirStart, $dirLen));
    1444                 $exifTool->VerboseValue("+ MakerNotes:PreviewImage", $newVal) if $newVal;
     1752            $newVal = $et->GetNewValue('PreviewImage') || '';
     1753            if ($et->Options('Verbose') > 1) {
     1754                $et->VerboseValue("- MakerNotes:PreviewImage", substr($$dataPt, $dirStart, $dirLen));
     1755                $et->VerboseValue("+ MakerNotes:PreviewImage", $newVal) if $newVal;
    14451756            }
    1446             ++$$exifTool{CHANGED};
     1757            ++$$et{CHANGED};
    14471758        } else {
    14481759            $newVal = substr($$dataPt, $dirStart, $dirLen);
     
    14501761    } else {
    14511762        # rewrite MakerNote IFD
    1452         $newVal = Image::ExifTool::Exif::WriteExif($exifTool, $dirInfo, $tagTablePtr);
     1763        $newVal = Image::ExifTool::Exif::WriteExif($et, $dirInfo, $tagTablePtr);
    14531764    }
    14541765    return $newVal;
     
    14611772sub ProcessUnknown($$$)
    14621773{
    1463     my ($exifTool, $dirInfo, $tagTablePtr) = @_;
     1774    my ($et, $dirInfo, $tagTablePtr) = @_;
    14641775    my $success = 0;
    14651776
    1466     my $loc = LocateIFD($exifTool, $dirInfo);
     1777    my $loc = LocateIFD($et, $dirInfo);
    14671778    if (defined $loc) {
    1468         $exifTool->{UnknownByteOrder} = GetByteOrder();
    1469         if ($exifTool->Options('Verbose') > 1) {
    1470             my $out = $exifTool->Options('TextOut');
    1471             my $indent = $exifTool->{INDENT};
     1779        $$et{UnknownByteOrder} = GetByteOrder();
     1780        if ($et->Options('Verbose') > 1) {
     1781            my $out = $et->Options('TextOut');
     1782            my $indent = $$et{INDENT};
    14721783            $indent =~ s/\| $/  /;
    14731784            printf $out "${indent}Found IFD at offset 0x%.4x in maker notes:\n",
    14741785                    $$dirInfo{DirStart} + $$dirInfo{DataPos} + $$dirInfo{Base};
    14751786        }
    1476         $success = Image::ExifTool::Exif::ProcessExif($exifTool, $dirInfo, $tagTablePtr);
     1787        $success = Image::ExifTool::Exif::ProcessExif($et, $dirInfo, $tagTablePtr);
    14771788    } else {
    1478         $exifTool->{UnknownByteOrder} = ''; # indicates we tried but didn't set byte order
    1479         $exifTool->Warn("Unrecognized $$dirInfo{DirName}", 1);
     1789        $$et{UnknownByteOrder} = ''; # indicates we tried but didn't set byte order
     1790        $et->Warn("Unrecognized $$dirInfo{DirName}", 1);
    14801791    }
    14811792    return $success;
     
    15021813=head1 AUTHOR
    15031814
    1504 Copyright 2003-2011, Phil Harvey (phil at owl.phy.queensu.ca)
     1815Copyright 2003-2021, Phil Harvey (philharvey66 at gmail.com)
    15051816
    15061817This library is free software; you can redistribute it and/or modify it
Note: See TracChangeset for help on using the changeset viewer.