| 1 | #------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||
| 2 | # File: PSP.pm | ||||||||||||||||||||||||||||||||||||||||||
| 3 | # | ||||||||||||||||||||||||||||||||||||||||||
| 4 | # Description: Read Paint Shop Pro meta information | ||||||||||||||||||||||||||||||||||||||||||
| 5 | # | ||||||||||||||||||||||||||||||||||||||||||
| 6 | # Revisions: 2010/01/23 - P. Harvey Created | ||||||||||||||||||||||||||||||||||||||||||
| 7 | # | ||||||||||||||||||||||||||||||||||||||||||
| 8 | # References: 1) http://www.jasc.com/support/kb/articles/pspspec.asp | ||||||||||||||||||||||||||||||||||||||||||
| 9 | #------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||
| 11 | package Image::ExifTool::PSP; | ||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||
| 13 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | 1 | ▶ | use vars qw($VERSION); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | 1 | ▶ | use Image::ExifTool qw(:DataAccess :Utils); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | 1 | ▶ | use Image::ExifTool::Exif; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||
| 18 | 1 | $VERSION = '1.05'; | |||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||
| 20 | sub ProcessExtData($$$); | ||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||
| 22 | # PSP info | ||||||||||||||||||||||||||||||||||||||||||
| 23 | 1 | %Image::ExifTool::PSP::Main = ( | |||||||||||||||||||||||||||||||||||||||||
| 24 | GROUPS => { 2 => 'Image' }, | ||||||||||||||||||||||||||||||||||||||||||
| 25 | VARS => { ALPHA_FIRST => 1 }, | ||||||||||||||||||||||||||||||||||||||||||
| 26 | NOTES => q{ | ||||||||||||||||||||||||||||||||||||||||||
| 27 | Tags extracted from Paint Shop Pro images (PSP, PSPIMAGE, PSPFRAME, | ||||||||||||||||||||||||||||||||||||||||||
| 28 | PSPSHAPE, PSPTUBE and TUB extensions). | ||||||||||||||||||||||||||||||||||||||||||
| 29 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 30 | # FileVersions: | ||||||||||||||||||||||||||||||||||||||||||
| 31 | # 3.0 => PSP 5 | ||||||||||||||||||||||||||||||||||||||||||
| 32 | # 4.0 => PSP 6 | ||||||||||||||||||||||||||||||||||||||||||
| 33 | # 5.0 => PSP 7 | ||||||||||||||||||||||||||||||||||||||||||
| 34 | # 6.0 => PSP 8 | ||||||||||||||||||||||||||||||||||||||||||
| 35 | # 7.0 => PSP 9 | ||||||||||||||||||||||||||||||||||||||||||
| 36 | # ? => PSP X | ||||||||||||||||||||||||||||||||||||||||||
| 37 | # ? => PSP X1 (is this the same as X?) | ||||||||||||||||||||||||||||||||||||||||||
| 38 | # ? => PSP X2 | ||||||||||||||||||||||||||||||||||||||||||
| 39 | # 10.0 => PSP X3 (= PSP 13) | ||||||||||||||||||||||||||||||||||||||||||
| 40 | FileVersion => { PrintConv => '$val=~tr/ /./; $val' }, | ||||||||||||||||||||||||||||||||||||||||||
| 41 | 0 => [ | ||||||||||||||||||||||||||||||||||||||||||
| 42 | { | ||||||||||||||||||||||||||||||||||||||||||
| 43 | Condition => '$$self{PSPFileVersion} > 3', | ||||||||||||||||||||||||||||||||||||||||||
| 44 | Name => 'ImageInfo', | ||||||||||||||||||||||||||||||||||||||||||
| 45 | SubDirectory => { | ||||||||||||||||||||||||||||||||||||||||||
| 46 | TagTable => 'Image::ExifTool::PSP::Image', | ||||||||||||||||||||||||||||||||||||||||||
| 47 | Start => 4, | ||||||||||||||||||||||||||||||||||||||||||
| 48 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 49 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 50 | { | ||||||||||||||||||||||||||||||||||||||||||
| 51 | Name => 'ImageInfo', | ||||||||||||||||||||||||||||||||||||||||||
| 52 | SubDirectory => { | ||||||||||||||||||||||||||||||||||||||||||
| 53 | TagTable => 'Image::ExifTool::PSP::Image', | ||||||||||||||||||||||||||||||||||||||||||
| 54 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 55 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 56 | ], | ||||||||||||||||||||||||||||||||||||||||||
| 57 | 1 => { | ||||||||||||||||||||||||||||||||||||||||||
| 58 | Name => 'CreatorInfo', | ||||||||||||||||||||||||||||||||||||||||||
| 59 | SubDirectory => { TagTable => 'Image::ExifTool::PSP::Creator' }, | ||||||||||||||||||||||||||||||||||||||||||
| 60 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 61 | 10 => { | ||||||||||||||||||||||||||||||||||||||||||
| 62 | Name => 'ExtendedInfo', | ||||||||||||||||||||||||||||||||||||||||||
| 63 | SubDirectory => { TagTable => 'Image::ExifTool::PSP::Ext' }, | ||||||||||||||||||||||||||||||||||||||||||
| 64 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 65 | # this is inside the composite image bank block (16), which I don't want to parse... | ||||||||||||||||||||||||||||||||||||||||||
| 66 | #18 => { | ||||||||||||||||||||||||||||||||||||||||||
| 67 | # Name => 'PreviewImage', | ||||||||||||||||||||||||||||||||||||||||||
| 68 | # Groups => { 2 => 'Preview' }, | ||||||||||||||||||||||||||||||||||||||||||
| 69 | # RawConv => '$self->ValidateImage(\$val,$tag)', | ||||||||||||||||||||||||||||||||||||||||||
| 70 | #}, | ||||||||||||||||||||||||||||||||||||||||||
| 71 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||
| 73 | # the PSP image block | ||||||||||||||||||||||||||||||||||||||||||
| 74 | 1 | %Image::ExifTool::PSP::Image = ( | |||||||||||||||||||||||||||||||||||||||||
| 75 | PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData, | ||||||||||||||||||||||||||||||||||||||||||
| 76 | GROUPS => { 2 => 'Image' }, | ||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 => { Name => 'ImageWidth', Format => 'int32u' }, | ||||||||||||||||||||||||||||||||||||||||||
| 78 | 4 => { Name => 'ImageHeight', Format => 'int32u' }, | ||||||||||||||||||||||||||||||||||||||||||
| 79 | 8 => { Name => 'ImageResolution', Format => 'double' }, | ||||||||||||||||||||||||||||||||||||||||||
| 80 | 16 => { | ||||||||||||||||||||||||||||||||||||||||||
| 81 | Name => 'ResolutionUnit', | ||||||||||||||||||||||||||||||||||||||||||
| 82 | Format => 'int8u', | ||||||||||||||||||||||||||||||||||||||||||
| 83 | PrintConv => { | ||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 => 'None', | ||||||||||||||||||||||||||||||||||||||||||
| 85 | 1 => 'inches', | ||||||||||||||||||||||||||||||||||||||||||
| 86 | 2 => 'cm', | ||||||||||||||||||||||||||||||||||||||||||
| 87 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 88 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 89 | 17 => { | ||||||||||||||||||||||||||||||||||||||||||
| 90 | Name => 'Compression', | ||||||||||||||||||||||||||||||||||||||||||
| 91 | Format => 'int16u', | ||||||||||||||||||||||||||||||||||||||||||
| 92 | PrintConv => { | ||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 => 'None', | ||||||||||||||||||||||||||||||||||||||||||
| 94 | 1 => 'RLE', | ||||||||||||||||||||||||||||||||||||||||||
| 95 | 2 => 'LZ77', | ||||||||||||||||||||||||||||||||||||||||||
| 96 | 3 => 'JPEG', | ||||||||||||||||||||||||||||||||||||||||||
| 97 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 98 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 99 | 19 => { Name => 'BitsPerSample',Format => 'int16u' }, | ||||||||||||||||||||||||||||||||||||||||||
| 100 | 21 => { Name => 'Planes', Format => 'int16u' }, | ||||||||||||||||||||||||||||||||||||||||||
| 101 | 23 => { Name => 'NumColors', Format => 'int32u' }, | ||||||||||||||||||||||||||||||||||||||||||
| 102 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||
| 104 | # the PSP creator data block | ||||||||||||||||||||||||||||||||||||||||||
| 105 | 1 | %Image::ExifTool::PSP::Creator = ( | |||||||||||||||||||||||||||||||||||||||||
| 106 | PROCESS_PROC => \&ProcessExtData, | ||||||||||||||||||||||||||||||||||||||||||
| 107 | GROUPS => { 2 => 'Image' }, | ||||||||||||||||||||||||||||||||||||||||||
| 108 | PRIORITY => 0, # prefer EXIF if it exists | ||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 => 'Title', | ||||||||||||||||||||||||||||||||||||||||||
| 110 | 1 => { | ||||||||||||||||||||||||||||||||||||||||||
| 111 | Name => 'CreateDate', | ||||||||||||||||||||||||||||||||||||||||||
| 112 | Format => 'int32u', | ||||||||||||||||||||||||||||||||||||||||||
| 113 | Groups => { 2 => 'Time' }, | ||||||||||||||||||||||||||||||||||||||||||
| 114 | ValueConv => 'Image::ExifTool::ConvertUnixTime($val,1)', | ||||||||||||||||||||||||||||||||||||||||||
| 115 | PrintConv => '$self->ConvertDateTime($val)', | ||||||||||||||||||||||||||||||||||||||||||
| 116 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 117 | 2 => { | ||||||||||||||||||||||||||||||||||||||||||
| 118 | Name => 'ModifyDate', | ||||||||||||||||||||||||||||||||||||||||||
| 119 | Format => 'int32u', | ||||||||||||||||||||||||||||||||||||||||||
| 120 | Groups => { 2 => 'Time' }, | ||||||||||||||||||||||||||||||||||||||||||
| 121 | ValueConv => 'Image::ExifTool::ConvertUnixTime($val,1)', | ||||||||||||||||||||||||||||||||||||||||||
| 122 | PrintConv => '$self->ConvertDateTime($val)', | ||||||||||||||||||||||||||||||||||||||||||
| 123 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 124 | 3 => { | ||||||||||||||||||||||||||||||||||||||||||
| 125 | Name => 'Artist', | ||||||||||||||||||||||||||||||||||||||||||
| 126 | Groups => { 2 => 'Author' }, | ||||||||||||||||||||||||||||||||||||||||||
| 127 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 128 | 4 => { | ||||||||||||||||||||||||||||||||||||||||||
| 129 | Name => 'Copyright', | ||||||||||||||||||||||||||||||||||||||||||
| 130 | Groups => { 2 => 'Author' }, | ||||||||||||||||||||||||||||||||||||||||||
| 131 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 132 | 5 => 'Description', | ||||||||||||||||||||||||||||||||||||||||||
| 133 | 6 => { | ||||||||||||||||||||||||||||||||||||||||||
| 134 | Name => 'CreatorAppID', | ||||||||||||||||||||||||||||||||||||||||||
| 135 | Format => 'int32u', | ||||||||||||||||||||||||||||||||||||||||||
| 136 | PrintConv => { | ||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 => 'Unknown', | ||||||||||||||||||||||||||||||||||||||||||
| 138 | 1 => 'Paint Shop Pro', | ||||||||||||||||||||||||||||||||||||||||||
| 139 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 140 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 141 | 7 => { | ||||||||||||||||||||||||||||||||||||||||||
| 142 | Name => 'CreatorAppVersion', | ||||||||||||||||||||||||||||||||||||||||||
| 143 | Format => 'int8u', | ||||||||||||||||||||||||||||||||||||||||||
| 144 | Count => 4, | ||||||||||||||||||||||||||||||||||||||||||
| 145 | ValueConv => 'join(" ",reverse split " ", $val)', # low byte first | ||||||||||||||||||||||||||||||||||||||||||
| 146 | PrintConv => '$val=~tr/ /./; $val', | ||||||||||||||||||||||||||||||||||||||||||
| 147 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 148 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||
| 150 | # the PSP extended data block | ||||||||||||||||||||||||||||||||||||||||||
| 151 | 1 | %Image::ExifTool::PSP::Ext = ( | |||||||||||||||||||||||||||||||||||||||||
| 152 | PROCESS_PROC => \&ProcessExtData, | ||||||||||||||||||||||||||||||||||||||||||
| 153 | GROUPS => { 2 => 'Image' }, | ||||||||||||||||||||||||||||||||||||||||||
| 154 | 3 => { | ||||||||||||||||||||||||||||||||||||||||||
| 155 | Name => 'EXIFInfo', #(don't change this name, it is used in the code) | ||||||||||||||||||||||||||||||||||||||||||
| 156 | SubDirectory => { TagTable => 'Image::ExifTool::Exif::Main' }, | ||||||||||||||||||||||||||||||||||||||||||
| 157 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 158 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||
| 160 | #------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||
| 161 | # Extract information from the extended data block | ||||||||||||||||||||||||||||||||||||||||||
| 162 | # Inputs: 0) ExifTool object ref, 1) dirInfo ref, 2) tag table ref | ||||||||||||||||||||||||||||||||||||||||||
| 163 | # Returns: 1 on success | ||||||||||||||||||||||||||||||||||||||||||
| 164 | sub ProcessExtData($$$) | ||||||||||||||||||||||||||||||||||||||||||
| 165 | 2 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ProcessExtData: called CC=10 SCAR=24.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 166 | 2 | my ($et, $dirInfo, $tagTablePtr) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 167 | 2 | my $dataPt = $$dirInfo{DataPt}; | |||||||||||||||||||||||||||||||||||||||||
| 168 | 2 | my $dirLen = $$dirInfo{DirLen}; | |||||||||||||||||||||||||||||||||||||||||
| 169 | 2 | my $pos = 0; | |||||||||||||||||||||||||||||||||||||||||
| 170 | # loop through sub-blocks | ||||||||||||||||||||||||||||||||||||||||||
| 171 | 2 | ▶ | while ($pos + 10 < $dirLen) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 172 | 11 | ▶ | unless (substr($$dataPt, $pos, 4) eq "~FL\0") { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | $et->Warn('Lost synchronization while reading sub blocks'); | |||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||||||||||||||
| 176 | 11 | my $tag = Get16u($dataPt, $pos + 4); | |||||||||||||||||||||||||||||||||||||||||
| 177 | 11 | my $len = Get32u($dataPt, $pos + 6); | |||||||||||||||||||||||||||||||||||||||||
| 178 | 11 | $pos += 10 + $len; | |||||||||||||||||||||||||||||||||||||||||
| 179 | 11 | ▶ | if ($pos > $dirLen) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | $et->Warn("Truncated sub block ID=$tag len=$len"); | |||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||||||||||||||||
| 183 | 11 | ▶ | next unless $$tagTablePtr{$tag}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 184 | 9 | ▶ | my $tagInfo = $et->GetTagInfo($tagTablePtr, $tag) or next; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 185 | 9 | my $start = $pos - $len; | |||||||||||||||||||||||||||||||||||||||||
| 186 | 9 | ▶ | unless ($$tagInfo{Name} eq 'EXIFInfo') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 187 | $et->HandleTag($tagTablePtr, $tag, undef, | ||||||||||||||||||||||||||||||||||||||||||
| 188 | TagInfo => $tagInfo, | ||||||||||||||||||||||||||||||||||||||||||
| 189 | DataPt => $dataPt, | ||||||||||||||||||||||||||||||||||||||||||
| 190 | DataPos => $$dirInfo{DataPos}, | ||||||||||||||||||||||||||||||||||||||||||
| 191 | 8 | DataLen => length $$dataPt, | |||||||||||||||||||||||||||||||||||||||||
| 192 | Start => $start, | ||||||||||||||||||||||||||||||||||||||||||
| 193 | Size => $len, | ||||||||||||||||||||||||||||||||||||||||||
| 194 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 195 | 8 | next; | |||||||||||||||||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||||||||||||||||
| 197 | # validate EXIF block header and set byte order | ||||||||||||||||||||||||||||||||||||||||||
| 198 | 1 | ▶ | next unless $len > 14 and substr($$dataPt, $pos - $len, 6) eq "Exif\0\0"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$len > 14 and substr($$dataPt, $pos - $len, 6) eq "Exif\0\0"
MC/DC0%0/2
$len > 14 and substr($$dataPt, $pos - $len, 6) eq "Exif\0\0"
$len > 14
substr($$dataPt, $pos - $len, 6) eq "Exif\0\0"
Truth table33%1/3
A and B
A= $len > 14B= substr($$dataPt, $pos - $len, 6) eq "Exif\0\0"
| |||||||||||||||||||||||||||||||||||||||||||
| 199 | 1 | ▶ | next unless SetByteOrder(substr($$dataPt, $start + 6, 2)); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 200 | # This is REALLY annoying... They use a standard TIFF offset to point to | ||||||||||||||||||||||||||||||||||||||||||
| 201 | # the first IFD, but after that the offsets are relative to the start of | ||||||||||||||||||||||||||||||||||||||||||
| 202 | # the IFD instead of the TIFF base, which means that I must handle it as a | ||||||||||||||||||||||||||||||||||||||||||
| 203 | # special case. Dumb, dumb... | ||||||||||||||||||||||||||||||||||||||||||
| 204 | 1 | $start += 14; | |||||||||||||||||||||||||||||||||||||||||
| 205 | my %dirInfo = ( | ||||||||||||||||||||||||||||||||||||||||||
| 206 | DirName => 'EXIF', | ||||||||||||||||||||||||||||||||||||||||||
| 207 | Parent => 'PSP', | ||||||||||||||||||||||||||||||||||||||||||
| 208 | DataPt => $dataPt, | ||||||||||||||||||||||||||||||||||||||||||
| 209 | DataPos => -$start, # data position relative to Base | ||||||||||||||||||||||||||||||||||||||||||
| 210 | DataLen => length $$dataPt, | ||||||||||||||||||||||||||||||||||||||||||
| 211 | DirStart => $start, | ||||||||||||||||||||||||||||||||||||||||||
| 212 | Base => $start + $$dirInfo{DataPos}, # absolute base offset | ||||||||||||||||||||||||||||||||||||||||||
| 213 | 1 | Multi => 0, | |||||||||||||||||||||||||||||||||||||||||
| 214 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 215 | 1 | my $exifTable = GetTagTable($$tagInfo{SubDirectory}{TagTable}); | |||||||||||||||||||||||||||||||||||||||||
| 216 | 1 | Image::ExifTool::Exif::ProcessExif($et, \%dirInfo, $exifTable); | |||||||||||||||||||||||||||||||||||||||||
| 217 | 1 | SetByteOrder('II'); | |||||||||||||||||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||||||||||||||||
| 219 | 2 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||||||||||
| 222 | #------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||
| 223 | # Extract information from a PSP file | ||||||||||||||||||||||||||||||||||||||||||
| 224 | # Inputs: 0) ExifTool object reference, 1) dirInfo reference | ||||||||||||||||||||||||||||||||||||||||||
| 225 | # Returns: 1 on success, 0 if this wasn't a valid PSP file | ||||||||||||||||||||||||||||||||||||||||||
| 226 | sub ProcessPSP($$) | ||||||||||||||||||||||||||||||||||||||||||
| 227 | 1 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ProcessPSP: called CC=11 SCAR=25.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 228 | 1 | my ($et, $dirInfo) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 229 | 1 | my $raf = $$dirInfo{RAF}; | |||||||||||||||||||||||||||||||||||||||||
| 230 | 1 | my ($buff, $tag, $len, $err); | |||||||||||||||||||||||||||||||||||||||||
| 231 | 1 | ▶ | return 0 unless $raf->Read($buff, 32) == 32 and | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$raf->Read($buff, 32) == 32 and $buff eq "Paint Shop Pro Image File\n\32\0\0\0\0\0" and $raf->Read($buff, 4) == 4
$raf->Read($buff, 32) == 32 and $buff eq "Paint Shop Pro Image File\n\32\0\0\0\0\0"
MC/DC0%0/3
$raf->Read($buff, 32) == 32 and $buff eq "Paint Shop Pro Image File\n\32\0\0\0\0\0" and $raf->Read($buff, 4) == 4
$raf->Read($buff, 32) == 32
$buff eq "Paint Shop Pro Image File\n\32\0\0\0\0\0"
$raf->Read($buff, 4) == 4
Truth table25%1/4
A and B and C
A= $raf->Read($buff, 32) == 32B= $buff eq "Paint Shop Pro Image File\n\32\0\0\0\0\0"C= $raf->Read($buff, 4) == 4
| |||||||||||||||||||||||||||||||||||||||||||
| 232 | $buff eq "Paint Shop Pro Image File\x0a\x1a\0\0\0\0\0" and | ||||||||||||||||||||||||||||||||||||||||||
| 233 | $raf->Read($buff, 4) == 4; | ||||||||||||||||||||||||||||||||||||||||||
| 234 | 1 | $et->SetFileType(); | |||||||||||||||||||||||||||||||||||||||||
| 235 | 1 | SetByteOrder('II'); | |||||||||||||||||||||||||||||||||||||||||
| 236 | 1 | my $tagTablePtr = GetTagTable('Image::ExifTool::PSP::Main'); | |||||||||||||||||||||||||||||||||||||||||
| 237 | 1 | my @a = unpack('v*', $buff); | |||||||||||||||||||||||||||||||||||||||||
| 238 | # figure out block header length for this format PSP file | ||||||||||||||||||||||||||||||||||||||||||
| 239 | 1 | ▶ | my $hlen = $a[0] > 3 ? 10 : 14; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 240 | 1 | $$et{PSPFileVersion} = $a[0]; # save for use in Condition | |||||||||||||||||||||||||||||||||||||||||
| 241 | 1 | $et->HandleTag($tagTablePtr, FileVersion => "@a"); | |||||||||||||||||||||||||||||||||||||||||
| 242 | # loop through blocks in file | ||||||||||||||||||||||||||||||||||||||||||
| 243 | 1 | my $pos = 36; | |||||||||||||||||||||||||||||||||||||||||
| 244 | 1 | for (;;) { | |||||||||||||||||||||||||||||||||||||||||
| 245 | 6 | ▶ | last unless $raf->Read($buff, $hlen) == $hlen; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 246 | 5 | ▶ | unless ($buff =~ /^~BK\0/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | $et->Warn('Lost synchronization while reading main PSP blocks'); | |||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||
| 249 | } | ||||||||||||||||||||||||||||||||||||||||||
| 250 | 5 | $tag = Get16u(\$buff, 4); | |||||||||||||||||||||||||||||||||||||||||
| 251 | 5 | $len = Get32u(\$buff, $hlen - 4); | |||||||||||||||||||||||||||||||||||||||||
| 252 | 5 | $pos += $hlen + $len; | |||||||||||||||||||||||||||||||||||||||||
| 253 | 5 | ▶ | unless ($$tagTablePtr{$tag}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 254 | 2 | ▶ | $raf->Seek($len, 1) or $err=1, last; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 255 | 2 | next; | |||||||||||||||||||||||||||||||||||||||||
| 256 | } | ||||||||||||||||||||||||||||||||||||||||||
| 257 | 3 | ▶ | $raf->Read($buff, $len) == $len or $err=1, last; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 258 | 3 | $et->HandleTag($tagTablePtr, $tag, $buff, | |||||||||||||||||||||||||||||||||||||||||
| 259 | DataPt => \$buff, | ||||||||||||||||||||||||||||||||||||||||||
| 260 | DataPos => $pos - $len, | ||||||||||||||||||||||||||||||||||||||||||
| 261 | Size => $len, | ||||||||||||||||||||||||||||||||||||||||||
| 262 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 263 | } | ||||||||||||||||||||||||||||||||||||||||||
| 264 | 1 | ▶ | $err and $et->Warn("Truncated main block ID=$tag len=$len"); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 265 | 1 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 266 | } | ||||||||||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||||||||||
| 268 | 1 | 1; # end | |||||||||||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||||||||||||
| 270 | __END__ | ||||||||||||||||||||||||||||||||||||||||||