- Timestamp:
- 2011-06-01T12:33:42+12:00 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone2/perllib/cpan/Image/ExifTool/Photoshop.pm
r16842 r24107 4 4 # Description: Read/write Photoshop IRB meta information 5 5 # 6 # Revisions: 02/06/ 04 - P. Harvey Created7 # 02/25/ 04 - P. Harvey Added hack for problem with old photoshops8 # 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 enough10 # information to write PrintConv routines for them to11 # display something useful12 # 07/08/ 05 - P. Harvey Added support for reading PSD files13 # 01/07/ 06 - P. Harvey Added PSD write support14 # 11/04/ 06 - P. Harvey Added handling of resource name6 # 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 15 15 # 16 16 # References: 1) http://www.fine-view.com/jp/lab/doc/ps6ffspecsv2.pdf … … 18 18 # 3) Matt Mueller private communication (tests with PS CS2) 19 19 # 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 20 22 #------------------------------------------------------------------------------ 21 23 … … 23 25 24 26 use strict; 25 use vars qw($VERSION $AUTOLOAD );26 use Image::ExifTool qw(:DataAccess );27 28 $VERSION = '1. 32';27 use vars qw($VERSION $AUTOLOAD $iptcDigestInfo); 28 use Image::ExifTool qw(:DataAccess :Utils); 29 30 $VERSION = '1.41'; 29 31 30 32 sub ProcessPhotoshop($$$); … … 56 58 0x03e8 => { Unknown => 1, Name => 'Photoshop2Info' }, 57 59 0x03e9 => { Unknown => 1, Name => 'MacintoshPrintInfo' }, 58 0x03ea => { Unknown => 1, Name => 'XMLData' }, #PH60 0x03ea => { Unknown => 1, Name => 'XMLData', Binary => 1 }, #PH 59 61 0x03eb => { Unknown => 1, Name => 'Photoshop2ColorTable' }, 60 62 0x03ed => { … … 66 68 0x03ee => { 67 69 Name => 'AlphaChannelsNames', 68 PrintConv => 'Image::ExifTool::Photoshop::ConvertPascalString($val)',70 ValueConv => 'Image::ExifTool::Photoshop::ConvertPascalString($self,$val)', 69 71 }, 70 72 0x03ef => { Unknown => 1, Name => 'DisplayInfo' }, … … 107 109 Name => 'PhotoshopBGRThumbnail', 108 110 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)', 110 112 }, 111 113 0x040a => { … … 127 129 0x040c => { 128 130 Name => 'PhotoshopThumbnail', 129 ValueConv => 'my $img=substr($val,0x1c);$self->ValidateImage(\$img,$tag)',131 RawConv => 'my $img=substr($val,0x1c);$self->ValidateImage(\$img,$tag)', 130 132 }, 131 133 0x040d => { … … 146 148 0x0412 => { Unknown => 1, Name => 'EffectsVisible' }, 147 149 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' }, 149 151 0x0415 => { Unknown => 1, Name => 'UnicodeAlphaNames' }, 150 152 0x0416 => { Unknown => 1, Name => 'IndexedColourTableCount' }, … … 170 172 }, 171 173 }, 174 0x0423 => { Unknown => 1, Name => 'ExifInfo2', Binary => 1 }, #5 172 175 0x0424 => { 173 176 Name => 'XMP', … … 176 179 }, 177 180 }, 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 178 211 # 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 }, 180 221 0x2710 => { Unknown => 1, Name => 'PrintFlagsInfo' }, 181 222 ); … … 267 308 12 => { 268 309 Name => 'ColorMode', 310 PrintConvColumns => 2, 269 311 PrintConv => { 270 312 0 => 'Bitmap', … … 285 327 ); 286 328 329 # define reference to IPTCDigest tagInfo hash for convenience 330 $iptcDigestInfo = $Image::ExifTool::Photoshop::Main{0x0425}; 331 332 287 333 #------------------------------------------------------------------------------ 288 334 # AutoLoad our writer routines when necessary … … 297 343 # Inputs: 1) Pascal string data 298 344 # Returns: Strings, concatenated with ', ' 299 sub ConvertPascalString($ )345 sub ConvertPascalString($$) 300 346 { 301 my $inStr = shift;347 my ($exifTool, $inStr) = @_; 302 348 my $outStr = ''; 303 349 my $len = length($inStr); … … 310 356 $i += $n + 1; 311 357 } 312 return $outStr; 358 my $charset = $exifTool->Options('CharsetPhotoshop') || 'Latin'; 359 return $exifTool->Decode($outStr, $charset); 313 360 } 314 361 … … 342 389 $ttPtr = $tagTablePtr; 343 390 } elsif ($type =~ /^(PHUT|DCSR|AgHg)$/) { 344 $ttPtr = Image::ExifTool::GetTagTable('Image::ExifTool::Photoshop::Unknown');391 $ttPtr = GetTagTable('Image::ExifTool::Photoshop::Unknown'); 345 392 } else { 346 393 $type =~ s/([^\w])/sprintf("\\x%.2x",ord($1))/ge; … … 406 453 407 454 $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; 409 456 SetByteOrder('MM'); 410 $exifTool->SetFileType( );# set the FileType tag457 $exifTool->SetFileType($1 eq "\x01" ? 'PSD' : 'PSB'); # set the FileType tag 411 458 my %dirInfo = ( 412 459 DataPt => \$data, 413 460 DirStart => 0, 414 DirName => 'P SD',461 DirName => 'Photoshop', 415 462 ); 416 463 my $len = Get32u(\$data, 26); … … 423 470 } else { 424 471 # process the header 425 $tagTablePtr = Image::ExifTool::GetTagTable('Image::ExifTool::Photoshop::Header');472 $tagTablePtr = GetTagTable('Image::ExifTool::Photoshop::Header'); 426 473 $dirInfo{DirLen} = 30; 427 474 $exifTool->ProcessDirectory(\%dirInfo, $tagTablePtr); … … 431 478 $len = Get32u(\$data, 0); 432 479 $raf->Read($data, $len) == $len or $err = 1; 433 $tagTablePtr = Image::ExifTool::GetTagTable('Image::ExifTool::Photoshop::Main');480 $tagTablePtr = GetTagTable('Image::ExifTool::Photoshop::Main'); 434 481 $dirInfo{DirLen} = $len; 435 482 my $rtnVal = 1; … … 520 567 =head1 AUTHOR 521 568 522 Copyright 2003-20 07, Phil Harvey (phil at owl.phy.queensu.ca)569 Copyright 2003-2011, Phil Harvey (phil at owl.phy.queensu.ca) 523 570 524 571 This library is free software; you can redistribute it and/or modify it … … 534 581 535 582 =item L<http://www.fileformat.info/format/psd/egff.htm> 583 584 =item L<http://libpsd.graphest.com/files/Photoshop%20File%20Formats.pdf> 536 585 537 586 =back
Note:
See TracChangeset
for help on using the changeset viewer.