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

    r24107 r34921  
    55#
    66# Revisions:    2010/10/05 - P. Harvey Created
     7#               2018/08/21 - PH Updated to current XCF specification (v013)
    78#
    89# References:   1) GIMP source code
    9 #               2) http://svn.gnome.org/viewvc/gimp/trunk/devel-docs/xcf.txt?view=markup
     10#               2) https://gitlab.gnome.org/GNOME/gimp/blob/master/devel-docs/xcf.txt
    1011#------------------------------------------------------------------------------
    1112
     
    1617use Image::ExifTool qw(:DataAccess :Utils);
    1718
    18 $VERSION = '1.01';
     19$VERSION = '1.03';
    1920
    2021sub ProcessParasites($$$);
     
    2930    },
    3031    header => { SubDirectory => { TagTable => 'Image::ExifTool::GIMP::Header' } },
     32    # recognized properties
     33    # 1 - ColorMap
     34    # 17 - SamplePoints? (doc says 17 is also "PROP_SAMPLE_POINTS"??)
    3135    17 => {
    3236        Name => 'Compression',
     
    3943        },
    4044    },
     45    # 18 - Guides
    4146    19 => {
    4247        Name => 'Resolution',
    4348        SubDirectory => { TagTable => 'Image::ExifTool::GIMP::Resolution' },
    4449    },
     50    20 => {
     51        Name => 'Tattoo',
     52        Format => 'int32u',
     53    },
    4554    21 => {
    4655        Name => 'Parasites',
    4756        SubDirectory => { TagTable => 'Image::ExifTool::GIMP::Parasite' },
    4857    },
     58    22 => {
     59        Name => 'Units',
     60        Format => 'int32u',
     61        PrintConv => {
     62            1 => 'Inches',
     63            2 => 'mm',
     64            3 => 'Points',
     65            4 => 'Picas',
     66        },
     67    },
     68    # 23 Paths
     69    # 24 UserUnit
     70    # 25 Vectors
    4971);
    5072
     
    5678        Name => 'XCFVersion',
    5779        Format => 'string[5]',
     80        DataMember => 'XCFVersion',
     81        RawConv => '$$self{XCFVersion} = $val',
    5882        PrintConv => {
    5983            'file' => '0',
    6084            'v001' => '1',
    6185            'v002' => '2',
     86            OTHER => sub { my $val = shift; $val =~ s/^v0*//; return $val },
    6287        },
    6388    },
     
    7398        },
    7499    },
     100    # 26 - [XCF 4 or later] Precision
    75101);
    76102
     
    127153        },
    128154    },
     155    'gimp-image-metadata' => {
     156        Name => 'XML',
     157        SubDirectory => { TagTable => 'Image::ExifTool::XMP::XML' },
     158    },
     159    # Seen, but not yet decoded:
     160    #  gimp-image-grid
     161    #  jpeg-settings
    129162);
    130163
     
    135168sub ProcessParasites($$$)
    136169{
    137     my ($exifTool, $dirInfo, $tagTablePtr) = @_;
    138     my $unknown = $exifTool->Options('Unknown') || $exifTool->Options('Verbose');
     170    my ($et, $dirInfo, $tagTablePtr) = @_;
     171    my $unknown = $et->Options('Unknown') || $et->Options('Verbose');
    139172    my $dataPt = $$dirInfo{DataPt};
    140173    my $pos = $$dirInfo{DirStart} || 0;
    141174    my $end = length $$dataPt;
    142     $exifTool->VerboseDir('Parasites', undef, $end);
     175    $et->VerboseDir('Parasites', undef, $end);
    143176    for (;;) {
    144177        last if $pos + 4 > $end;
     
    161194            $name =~ s/([a-z])-([a-z])/$1\u$2/g;
    162195            $name = "GIMP-$name" unless length($name) > 1;
    163             Image::ExifTool::AddTagToTable($tagTablePtr, $tag, { Name => $name, Unknown => 1 });
     196            AddTagToTable($tagTablePtr, $tag, { Name => $name, Unknown => 1 });
    164197        }
    165         $exifTool->HandleTag($tagTablePtr, $tag, undef,
     198        $et->HandleTag($tagTablePtr, $tag, undef,
    166199            DataPt => $dataPt,
    167200            Start  => $pos,
     
    179212sub ProcessXCF($$)
    180213{
    181     my ($exifTool, $dirInfo) = @_;
     214    my ($et, $dirInfo) = @_;
    182215    my $raf = $$dirInfo{RAF};
    183216    my $buff;
     
    187220
    188221    my $tagTablePtr = GetTagTable('Image::ExifTool::GIMP::Main');
    189     my $verbose = $exifTool->Options('Verbose');
    190     $exifTool->SetFileType();
     222    my $verbose = $et->Options('Verbose');
     223    $et->SetFileType();
    191224    SetByteOrder('MM');
    192225
    193226    # process the XCF header
    194     $exifTool->HandleTag($tagTablePtr, 'header', $buff);
     227    $et->HandleTag($tagTablePtr, 'header', $buff);
     228
     229    # skip over precision for XCV version 4 or later
     230    $raf->Seek(4, 1) if $$et{XCFVersion} =~ /^v0*(\d+)/ and $1 >= 4;
    195231
    196232    # loop through image properties
     
    199235        my $tag  = Get32u(\$buff, 0) or last;
    200236        my $size = Get32u(\$buff, 4);
    201         $verbose and $exifTool->VPrint(0, "XCF property $tag ($size bytes):\n");
     237        $verbose and $et->VPrint(0, "XCF property $tag ($size bytes):\n");
    202238        unless ($$tagTablePtr{$tag}) {
    203239            $raf->Seek($size, 1);
     
    205241        }
    206242        $raf->Read($buff, $size) == $size or last;
    207         $exifTool->HandleTag($tagTablePtr, $tag, undef,
     243        $et->HandleTag($tagTablePtr, $tag, undef,
    208244            DataPt  => \$buff,
    209245            DataPos => $raf->Tell() - $size,
     
    235271=head1 AUTHOR
    236272
    237 Copyright 2003-2011, Phil Harvey (phil at owl.phy.queensu.ca)
     273Copyright 2003-2021, Phil Harvey (philharvey66 at gmail.com)
    238274
    239275This library is free software; you can redistribute it and/or modify it
Note: See TracChangeset for help on using the changeset viewer.