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

    r24107 r34921  
    1818use Image::ExifTool::Minolta;
    1919
    20 $VERSION = '1.12';
     20$VERSION = '1.16';
    2121
    2222sub ProcessMRW($$;$);
     
    6060    WRITABLE => 1,
    6161    GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
     62    DATAMEMBER => [ 0 ],
    6263    FIRST_ENTRY => 0,
    6364    0 => {
    6465        Name => 'FirmwareID',
    6566        Format => 'string[8]',
     67        RawConv => '$$self{MinoltaPRD} = 1 if $$self{FILE_TYPE} eq "MRW"; $val',  # used in decoding RIF info
    6668    },
    6769    8 => {
     
    101103        Format => 'int8u',
    102104        PrintConv => {
     105            # 0 - seen in some Sony A850 ARW images
    103106            1 => 'RGGB',
    104107            4 => 'GBRG',
     
    186189                my ($val, $inv) = @_;
    187190                return int(2 ** (($val-48)/8) * 100 + 0.5) unless $inv;
    188                 return 48 + 8*log($val/100)/log(2) if Image::ExifTool::IsFloat($val);
     191                # (must check for zero below in inverse conversion)
     192                return 48 + 8*log($val/100)/log(2) if Image::ExifTool::IsFloat($val) and $val != 0;
    189193                return undef;
    190194            },
     
    213217        },
    214218    ],
    215     # NOTE: some of these WB_RBLevels may apply to other models too...
     219    # NOTE: WB_RBLevels up to Custom also apply to Minolta models which write PRD info (ref IB)
    216220    8  => { #3
    217221        Name => 'WB_RBLevelsTungsten',
    218         Condition => '$$self{Model} eq "DSLR-A100"',
     222        Condition => '$$self{Model} eq "DSLR-A100" or $$self{MinoltaPRD}',
    219223        Format => 'int16u[2]',
    220224        Notes => 'these WB_RBLevels currently decoded only for the Sony A100',
     
    222226    12 => { #3
    223227        Name => 'WB_RBLevelsDaylight',
    224         Condition => '$$self{Model} eq "DSLR-A100"',
     228        Condition => '$$self{Model} eq "DSLR-A100" or $$self{MinoltaPRD}',
    225229        Format => 'int16u[2]',
    226230    },
    227231    16 => { #3
    228232        Name => 'WB_RBLevelsCloudy',
    229         Condition => '$$self{Model} eq "DSLR-A100"',
     233        Condition => '$$self{Model} eq "DSLR-A100" or $$self{MinoltaPRD}',
    230234        Format => 'int16u[2]',
    231235    },
    232236    20 => { #3
    233237        Name => 'WB_RBLevelsCoolWhiteF',
    234         Condition => '$$self{Model} eq "DSLR-A100"',
     238        Condition => '$$self{Model} eq "DSLR-A100" or $$self{MinoltaPRD}',
    235239        Format => 'int16u[2]',
    236240    },
    237241    24 => { #3
    238242        Name => 'WB_RBLevelsFlash',
    239         Condition => '$$self{Model} eq "DSLR-A100"',
     243        Condition => '$$self{Model} eq "DSLR-A100" or $$self{MinoltaPRD}',
    240244        Format => 'int16u[2]',
    241245    },
    242246    28 => { #3
    243         Name => 'WB_RBLevelsUnknown',
    244         Condition => '$$self{Model} eq "DSLR-A100"',
    245         Format => 'int16u[2]',
    246         Unknown => 1,
     247        Name => 'WB_RBLevelsCustom', #IB
     248        Condition => '$$self{Model} eq "DSLR-A100" or $$self{MinoltaPRD}',
     249        Format => 'int16u[2]',
    247250    },
    248251    32 => { #3
     
    308311    76 => { #3
    309312        Name => 'ColorTemperature',
    310         Condition => '$$self{Make} =~ /^SONY/ and $$self{Model} eq "DSLR-A100"',
     313        Condition => '$$self{Model} eq "DSLR-A100"',
    311314        Notes => 'A100',
    312315        ValueConv => '$val * 100',
     
    317320    77 => { #3
    318321        Name => 'ColorFilter',
    319         Condition => '$$self{Make} =~ /^SONY/ and $$self{Model} eq "DSLR-A100"',
     322        Condition => '$$self{Model} eq "DSLR-A100"',
    320323        Notes => 'A100',
    321324    },
    322325    78 => { #3
    323326        Name => 'ColorTemperature',
    324         Condition => '$$self{Make} =~ /^SONY/ and $$self{Model} =~ /^DSLR-A(200|700)$/',
     327        Condition => '$$self{Model} =~ /^DSLR-A(200|700)$/',
    325328        Notes => 'A200 and A700',
    326329        ValueConv => '$val * 100',
     
    331334    79 => { #3
    332335        Name => 'ColorFilter',
    333         Condition => '$$self{Make} =~ /^SONY/ and $$self{Model} =~ /^DSLR-A(200|700)$/',
     336        Condition => '$$self{Model} =~ /^DSLR-A(200|700)$/',
    334337        Notes => 'A200 and A700',
     338    },
     339    80 => { #3
     340        Name => 'RawDataLength',
     341        Condition => '$$self{Model} eq "DSLR-A100"',
     342        Format => 'int32u',
     343        Notes => 'A100',
     344        Writable => 0,
    335345    },
    336346);
     
    362372
    363373#------------------------------------------------------------------------------
    364 # Write MRW directory (ie. in ARW images)
     374# Write MRW directory (eg. in ARW images)
    365375# Inputs: 0) ExifTool object ref, 1) dirInfo ref, 2) optional tag table ref
    366376# Returns: new MRW data or undef on error
    367377sub WriteMRW($$;$)
    368378{
    369     my ($exifTool, $dirInfo, $tagTablePtr) = @_;
    370     $exifTool or return 1;      # allow dummy access
     379    my ($et, $dirInfo, $tagTablePtr) = @_;
     380    $et or return 1;      # allow dummy access
    371381    my $buff = '';
    372382    $$dirInfo{OutFile} = \$buff;
    373     ProcessMRW($exifTool, $dirInfo, $tagTablePtr) > 0 or undef $buff;
     383    ProcessMRW($et, $dirInfo, $tagTablePtr) > 0 or undef $buff;
    374384    return $buff;
    375385}
     
    382392sub ProcessMRW($$;$)
    383393{
    384     my ($exifTool, $dirInfo, $tagTablePtr) = @_;
     394    my ($et, $dirInfo, $tagTablePtr) = @_;
    385395    my $raf = $$dirInfo{RAF};
    386396    my $outfile = $$dirInfo{OutFile};
    387     my $verbose = $exifTool->Options('Verbose');
    388     my $out = $exifTool->Options('TextOut');
     397    my $verbose = $et->Options('Verbose');
     398    my $out = $et->Options('TextOut');
    389399    my ($data, $err, $outBuff);
    390400
     
    401411    my $hdr = "\0MR$1";
    402412    SetByteOrder($1 . $1);
    403     $exifTool->SetFileType();
     413    $et->SetFileType();
    404414    $tagTablePtr = GetTagTable('Image::ExifTool::MinoltaRaw::Main');
    405415    if ($outfile) {
    406         $exifTool->InitWriteDirs('TIFF'); # use same write dirs as TIFF
     416        $et->InitWriteDirs('TIFF'); # use same write dirs as TIFF
    407417        $outBuff = '';
    408418    }
     
    418428        my $len = Get32u(\$data, 4);
    419429        if ($verbose) {
    420             print $out "MRW ",$exifTool->Printable($tag)," segment ($len bytes):\n";
     430            print $out "MRW ",$et->Printable($tag)," segment ($len bytes):\n";
    421431            if ($verbose > 2) {
    422432                $raf->Read($data,$len) == $len and $raf->Seek($pos,0) or $err = 1, last;
    423                 $exifTool->VerboseDump(\$data);
     433                $et->VerboseDump(\$data);
    424434            }
    425435        }
    426         my $tagInfo = $exifTool->GetTagInfo($tagTablePtr, $tag);
     436        my $tagInfo = $et->GetTagInfo($tagTablePtr, $tag);
    427437        if ($tagInfo and $$tagInfo{SubDirectory}) {
    428438            my $subTable = GetTagTable($tagInfo->{SubDirectory}->{TagTable});
    429439            my $buff;
    430440            # save shift for values stored with wrong base offset
    431             $$exifTool{MRW_WrongBase} = -($raf->Tell());
     441            $$et{MRW_WrongBase} = -($raf->Tell());
    432442            $raf->Read($buff, $len) == $len or $err = 1, last;
    433443            my %subdirInfo = (
     
    443453            if ($outfile) {
    444454                my $writeProc = $tagInfo->{SubDirectory}->{WriteProc};
    445                 my $val = $exifTool->WriteDirectory(\%subdirInfo, $subTable, $writeProc);
     455                my $val = $et->WriteDirectory(\%subdirInfo, $subTable, $writeProc);
    446456                if (defined $val and length $val) {
    447457                    # pad to an even 4 bytes (can't hurt, and it seems to be the standard)
     
    453463            } else {
    454464                my $processProc = $tagInfo->{SubDirectory}->{ProcessProc};
    455                 $exifTool->ProcessDirectory(\%subdirInfo, $subTable, $processProc);
     465                $et->ProcessDirectory(\%subdirInfo, $subTable, $processProc);
    456466            }
    457467        } elsif ($outfile) {
     
    477487        # Sony IDC utility corrupts MRWInfo when writing ARW images,
    478488        # so make this a minor error for these images
    479         $err and $exifTool->Error("MRW format error", $$exifTool{TIFF_TYPE} eq 'ARW');
     489        $err and $et->Error("MRW format error", $$et{TIFF_TYPE} eq 'ARW');
    480490    } else {
    481         $err and $exifTool->Warn("MRW format error");
     491        $err and $et->Warn("MRW format error");
    482492    }
    483493    return $rtnVal;
     
    503513=head1 AUTHOR
    504514
    505 Copyright 2003-2011, Phil Harvey (phil at owl.phy.queensu.ca)
     515Copyright 2003-2021, Phil Harvey (philharvey66 at gmail.com)
    506516
    507517This library is free software; you can redistribute it and/or modify it
Note: See TracChangeset for help on using the changeset viewer.