Ignore:
Timestamp:
2011-06-01T12:33:42+12:00 (13 years ago)
Author:
sjm84
Message:

Updating the ExifTool perl modules

File:
1 edited

Legend:

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

    r16842 r24107  
    44# Description:  Read/write Photoshop IRB meta information
    55#
    6 # Revisions:    02/06/04 - P. Harvey Created
    7 #               02/25/04 - P. Harvey Added hack for problem with old photoshops
    8 #               10/04/04 - P. Harvey Added a bunch of tags (ref Image::MetaData::JPEG)
    9 #                          but left most of them commented out until I have enough
    10 #                          information to write PrintConv routines for them to
    11 #                          display something useful
    12 #               07/08/05 - P. Harvey Added support for reading PSD files
    13 #               01/07/06 - P. Harvey Added PSD write support
    14 #               11/04/06 - P. Harvey Added handling of resource name
     6# Revisions:    02/06/2004 - P. Harvey Created
     7#               02/25/2004 - P. Harvey Added hack for problem with old photoshops
     8#               10/04/2004 - P. Harvey Added a bunch of tags (ref Image::MetaData::JPEG)
     9#                            but left most of them commented out until I have enough
     10#                            information to write PrintConv routines for them to
     11#                            display something useful
     12#               07/08/2005 - P. Harvey Added support for reading PSD files
     13#               01/07/2006 - P. Harvey Added PSD write support
     14#               11/04/2006 - P. Harvey Added handling of resource name
    1515#
    1616# References:   1) http://www.fine-view.com/jp/lab/doc/ps6ffspecsv2.pdf
     
    1818#               3) Matt Mueller private communication (tests with PS CS2)
    1919#               4) http://www.fileformat.info/format/psd/egff.htm
     20#               5) http://www.telegraphics.com.au/svn/psdparse/trunk/resources.c
     21#               6) http://libpsd.graphest.com/files/Photoshop%20File%20Formats.pdf
    2022#------------------------------------------------------------------------------
    2123
     
    2325
    2426use strict;
    25 use vars qw($VERSION $AUTOLOAD);
    26 use Image::ExifTool qw(:DataAccess);
    27 
    28 $VERSION = '1.32';
     27use vars qw($VERSION $AUTOLOAD $iptcDigestInfo);
     28use Image::ExifTool qw(:DataAccess :Utils);
     29
     30$VERSION = '1.41';
    2931
    3032sub ProcessPhotoshop($$$);
     
    5658    0x03e8 => { Unknown => 1, Name => 'Photoshop2Info' },
    5759    0x03e9 => { Unknown => 1, Name => 'MacintoshPrintInfo' },
    58     0x03ea => { Unknown => 1, Name => 'XMLData' }, #PH
     60    0x03ea => { Unknown => 1, Name => 'XMLData', Binary => 1 }, #PH
    5961    0x03eb => { Unknown => 1, Name => 'Photoshop2ColorTable' },
    6062    0x03ed => {
     
    6668    0x03ee => {
    6769        Name => 'AlphaChannelsNames',
    68         PrintConv => 'Image::ExifTool::Photoshop::ConvertPascalString($val)',
     70        ValueConv => 'Image::ExifTool::Photoshop::ConvertPascalString($self,$val)',
    6971    },
    7072    0x03ef => { Unknown => 1, Name => 'DisplayInfo' },
     
    107109        Name => 'PhotoshopBGRThumbnail',
    108110        Notes => 'this is a JPEG image, but in BGR format instead of RGB',
    109         ValueConv => 'my $img=substr($val,0x1c);$self->ValidateImage(\$img,$tag)',
     111        RawConv => 'my $img=substr($val,0x1c);$self->ValidateImage(\$img,$tag)',
    110112    },
    111113    0x040a => {
     
    127129    0x040c => {
    128130        Name => 'PhotoshopThumbnail',
    129         ValueConv => 'my $img=substr($val,0x1c);$self->ValidateImage(\$img,$tag)',
     131        RawConv => 'my $img=substr($val,0x1c);$self->ValidateImage(\$img,$tag)',
    130132    },
    131133    0x040d => {
     
    146148    0x0412 => { Unknown => 1, Name => 'EffectsVisible' },
    147149    0x0413 => { Unknown => 1, Name => 'SpotHalftone' },
    148     0x0414 => { Unknown => 1, Name => 'IDsBaseValue', Description => "ID's Base Value" },
     150    0x0414 => { Unknown => 1, Name => 'IDsBaseValue', Description => 'IDs Base Value' },
    149151    0x0415 => { Unknown => 1, Name => 'UnicodeAlphaNames' },
    150152    0x0416 => { Unknown => 1, Name => 'IndexedColourTableCount' },
     
    170172        },
    171173    },
     174    0x0423 => { Unknown => 1, Name => 'ExifInfo2', Binary => 1 }, #5
    172175    0x0424 => {
    173176        Name => 'XMP',
     
    176179        },
    177180    },
     181    0x0425 => {
     182        Name => 'IPTCDigest',
     183        Writable => 'string',
     184        Protected => 1,
     185        Notes => q{
     186            when writing, special values of "new" and "old" represent the digests of the
     187            IPTC from the edited and original files respectively, and are undefined if
     188            the IPTC does not exist in the respective file
     189        },
     190        # also note the 'new' feature requires that the IPTC comes before this tag is written
     191        ValueConv => 'unpack("H*", $val)',
     192        ValueConvInv => q{
     193            if (lc($val) eq 'new' or lc($val) eq 'old') {
     194                {
     195                    local $SIG{'__WARN__'} = sub { };
     196                    return lc($val) if eval 'require Digest::MD5';
     197                }
     198                warn "Digest::MD5 must be installed\n";
     199                return undef;
     200            }
     201            return pack('H*', $val) if $val =~ /^[0-9a-f]{32}$/i;
     202            warn "Value must be 'new', 'old' or 32 hexadecimal digits\n";
     203            return undef;
     204        }
     205    },
     206    0x0426 => { Unknown => 1, Name => 'PrintScale' }, #5
     207    0x0428 => { Unknown => 1, Name => 'PixelAspectRatio' }, #5
     208    0x0429 => { Unknown => 1, Name => 'LayerComps' }, #5
     209    0x042a => { Unknown => 1, Name => 'AlternateDuotoneColors' }, #5
     210    0x042b => { Unknown => 1, Name => 'AlternateSpotColors' }, #5
    178211    # 0x07d0-0x0bb6 Path information
    179     0x0bb7 => { Unknown => 1, Name => 'ClippingPathName' },
     212    0x0bb7 => {
     213        Name => 'ClippingPathName',
     214        # convert from a Pascal string (ignoring 6 bytes of unknown data after string)
     215        ValueConv => q{
     216            my $len = ord($val);
     217            $val = substr($val, 0, $len+1) if $len < length($val);
     218            return Image::ExifTool::Photoshop::ConvertPascalString($self,$val);
     219        },
     220    },
    180221    0x2710 => { Unknown => 1, Name => 'PrintFlagsInfo' },
    181222);
     
    267308    12 => {
    268309        Name => 'ColorMode',
     310        PrintConvColumns => 2,
    269311        PrintConv => {
    270312            0 => 'Bitmap',
     
    285327);
    286328
     329# define reference to IPTCDigest tagInfo hash for convenience
     330$iptcDigestInfo = $Image::ExifTool::Photoshop::Main{0x0425};
     331
     332
    287333#------------------------------------------------------------------------------
    288334# AutoLoad our writer routines when necessary
     
    297343# Inputs: 1) Pascal string data
    298344# Returns: Strings, concatenated with ', '
    299 sub ConvertPascalString($)
     345sub ConvertPascalString($$)
    300346{
    301     my $inStr = shift;
     347    my ($exifTool, $inStr) = @_;
    302348    my $outStr = '';
    303349    my $len = length($inStr);
     
    310356        $i += $n + 1;
    311357    }
    312     return $outStr;
     358    my $charset = $exifTool->Options('CharsetPhotoshop') || 'Latin';
     359    return $exifTool->Decode($outStr, $charset);
    313360}
    314361
     
    342389            $ttPtr = $tagTablePtr;
    343390        } elsif ($type =~ /^(PHUT|DCSR|AgHg)$/) {
    344             $ttPtr = Image::ExifTool::GetTagTable('Image::ExifTool::Photoshop::Unknown');
     391            $ttPtr = GetTagTable('Image::ExifTool::Photoshop::Unknown');
    345392        } else {
    346393            $type =~ s/([^\w])/sprintf("\\x%.2x",ord($1))/ge;
     
    406453
    407454    $raf->Read($data, 30) == 30 or return 0;
    408     $data =~ /^8BPS\0\x01/ or return 0;
     455    $data =~ /^8BPS\0([\x01\x02])/ or return 0;
    409456    SetByteOrder('MM');
    410     $exifTool->SetFileType();    # set the FileType tag
     457    $exifTool->SetFileType($1 eq "\x01" ? 'PSD' : 'PSB'); # set the FileType tag
    411458    my %dirInfo = (
    412459        DataPt => \$data,
    413460        DirStart => 0,
    414         DirName => 'PSD',
     461        DirName => 'Photoshop',
    415462    );
    416463    my $len = Get32u(\$data, 26);
     
    423470    } else {
    424471        # process the header
    425         $tagTablePtr = Image::ExifTool::GetTagTable('Image::ExifTool::Photoshop::Header');
     472        $tagTablePtr = GetTagTable('Image::ExifTool::Photoshop::Header');
    426473        $dirInfo{DirLen} = 30;
    427474        $exifTool->ProcessDirectory(\%dirInfo, $tagTablePtr);
     
    431478    $len = Get32u(\$data, 0);
    432479    $raf->Read($data, $len) == $len or $err = 1;
    433     $tagTablePtr = Image::ExifTool::GetTagTable('Image::ExifTool::Photoshop::Main');
     480    $tagTablePtr = GetTagTable('Image::ExifTool::Photoshop::Main');
    434481    $dirInfo{DirLen} = $len;
    435482    my $rtnVal = 1;
     
    520567=head1 AUTHOR
    521568
    522 Copyright 2003-2007, Phil Harvey (phil at owl.phy.queensu.ca)
     569Copyright 2003-2011, Phil Harvey (phil at owl.phy.queensu.ca)
    523570
    524571This library is free software; you can redistribute it and/or modify it
     
    534581
    535582=item L<http://www.fileformat.info/format/psd/egff.htm>
     583
     584=item L<http://libpsd.graphest.com/files/Photoshop%20File%20Formats.pdf>
    536585
    537586=back
Note: See TracChangeset for help on using the changeset viewer.