File Coverage

blib/lib/Image/ExifTool/Other.pm
Criterion Covered Total %
statement 23 23 100.0
branch 2 2 100.0
condition 2 3 66.6
subroutine 5 5 100.0
pod 0 1 0.0
total 32 34 94.1


line stmt bran cond sub pod time code
1             #------------------------------------------------------------------------------
2             # File: Other.pm
3             #
4             # Description: Read meta information from other uncommon formats
5             #
6             # Revisions: 2021/07/16 - P. Harvey Created
7             #
8             # References: 1) PFM - http://www.pauldebevec.com/Research/HDR/PFM/
9             #------------------------------------------------------------------------------
10              
11             package Image::ExifTool::Other;
12              
13 4     4   4734 use strict;
  4         14  
  4         154  
14 4     4   32 use vars qw($VERSION);
  4         8  
  4         163  
15 4     4   29 use Image::ExifTool qw(:DataAccess :Utils);
  4         9  
  4         813  
16 4     4   1479 use Image::ExifTool::Exif;
  4         74  
  4         1036  
17              
18             $VERSION = '1.00';
19              
20             # Other info
21             %Image::ExifTool::Other::PFM = (
22             GROUPS => { 0 => 'File', 1 => 'File', 2 => 'Image' },
23             VARS => { NO_ID => 1 },
24             NOTES => q{
25             Tags extracted from Portable FloatMap images. See
26             L for the specification.
27             },
28             ColorSpace => { PrintConv => { PF => 'RGB', 'Pf' => 'Monochrome'} },
29             ImageWidth => { },
30             ImageHeight => { },
31             ByteOrder => { PrintConv => '$val > 0 ? "Big-endian" : "Little-endian"' },
32             );
33              
34             #------------------------------------------------------------------------------
35             # Extract information from a Portable FloatMap image
36             # Inputs: 0) ExifTool object reference, 1) dirInfo reference
37             # Returns: 1 on success, 0 if this wasn't a valid PFM file
38             sub ProcessPFM2($$)
39             {
40 9     9 0 41 my ($et, $dirInfo) = @_;
41 9         44 my $raf = $$dirInfo{RAF};
42 9         25 my $buff;
43 9 100 66     57 return 0 unless $raf->Read($buff, 256) and $buff =~ /^(P[Ff])\x0a(\d+) (\d+)\x0a([-+0-9.]+)\x0a/;
44 1         9 $et->SetFileType('PFM', 'image/x-pfm');
45 1         3 my $tagTablePtr = GetTagTable('Image::ExifTool::Other::PFM');
46 1         11 $et->HandleTag($tagTablePtr, ColorSpace => $1);
47 1         6 $et->HandleTag($tagTablePtr, ImageWidth => $2);
48 1         3 $et->HandleTag($tagTablePtr, ImageHeight => $3);
49 1         4 $et->HandleTag($tagTablePtr, ByteOrder => $4);
50             # hack to set proper file description (extension is the same for Printer Font Metrics files)
51 1         14 $Image::ExifTool::static_vars{OverrideFileDescription}{PFM} = 'Portable FloatMap',
52             return 1;
53             }
54              
55             1; # end
56              
57             __END__