Image/ExifTool/Radiance.pm

filter: Statementstmt 81.4% 35 / 43 Branchbran 50.0% 10 / 20 Conditioncond 44.4% 4 / 9 MC/DCmcdc 16.6% 1 / 6 Subroutinesub 100% 4 / 4 Podpod 0.0% 0 / 1 totaltotal 65.0% 54 / 83 CC 14 SCAR 30.3
CC
14
Cov
68%
ProcessHDR
25.0
BEGIN
1.0
BEGIN
1.0
CRAP 20.8
« Image/ExifTool/BZZ.pm ↑ Summary Image/ExifTool/DSF.pm »
1 #------------------------------------------------------------------------------
2 # File: Radiance.pm
3 #
4 # Description: Read Radiance RGBE HDR meta information
5 #
6 # Revisions: 2011/12/10 - P. Harvey Created
7 #
8 # References: 1) http://www.graphics.cornell.edu/online/formats/rgbe/
9 # 2) http://radsite.lbl.gov/radiance/refer/filefmts.pdf
10 #------------------------------------------------------------------------------
11  
12 package Image::ExifTool::Radiance;
13  
14 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 1 ▶use vars qw($VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
16 1 ▶use Image::ExifTool qw(:DataAccess :Utils);
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 1 $VERSION = '1.02';
19  
20 # Radiance tags
21 1 %Image::ExifTool::Radiance::Main = (
22 GROUPS => { 2 => 'Image' },
23 NOTES => q{
24 Information extracted from Radiance RGBE HDR images. Tag ID's are all
25 uppercase as stored in the file, but converted to lowercase by when
26 extracting to avoid conflicts with internal ExifTool variables. See
27 L<http://radsite.lbl.gov/radiance/refer/filefmts.pdf> and
28 L<http://www.graphics.cornell.edu/online/formats/rgbe/> for the
29 specification.
30 },
31 _orient => {
32 Name => 'Orientation',
33 PrintConv => {
34 '-Y +X' => 'Horizontal (normal)',
35 '-Y -X' => 'Mirror horizontal',
36 '+Y -X' => 'Rotate 180',
37 '+Y +X' => 'Mirror vertical',
38 '+X -Y' => 'Mirror horizontal and rotate 270 CW',
39 '+X +Y' => 'Rotate 90 CW',
40 '-X +Y' => 'Mirror horizontal and rotate 90 CW',
41 '-X -Y' => 'Rotate 270 CW',
42 },
43 },
44 _command => 'Command',
45 _comment => 'Comment',
46 software => 'Software',
47 view => 'View',
48 'format' => 'Format', # <-- this is the one that caused the conflict when uppercase
49 exposure => {
50 Name => 'Exposure',
51 Notes => 'divide pixel values by this to get watts/steradian/meter^2',
52 },
53 gamma => 'Gamma',
54 colorcorr => 'ColorCorrection',
55 pixaspect => 'PixelAspectRatio',
56 primaries => 'ColorPrimaries',
57 );
58  
59 #------------------------------------------------------------------------------
60 # Extract information from a Radiance HDR file
61 # Inputs: 0) ExifTool object reference, 1) DirInfo reference
62 # Returns: 1 on success, 0 if this wasn't a valid RGBE image
63 sub ProcessHDR($$)
64 1 ▶{
Subroutine ProcessHDR: called CC=14 SCAR=32.2
Pod undocumented
65 1 my ($et, $dirInfo) = @_;
66 1 my $raf = $$dirInfo{RAF};
67 1 my $buff;
68 1 local $/ = "\x0a"; # set newline character for reading
69  
70 # verify this is a valid RIFF file
71 1 ▶ return 0 unless $raf->ReadLine($buff) and $buff =~ /^#\?(RADIANCE|RGBE)\x0a/s;
Branch: 1 branch
BranchTrueFalseTotal
unless $raf->ReadLine($buff) and $buff =~ /^#\?(RADIANCE|RGBE)\x0a/s 0 1 1
Condition33%1/3
$raf->ReadLine($buff) and $buff =~ /^#\?(RADIANCE|RGBE)\x0a/s
!ll&&!rl&&r
001
MC/DC0%0/2
$raf->ReadLine($buff) and $buff =~ /^#\?(RADIANCE|RGBE)\x0a/s
$raf->ReadLine($buff) $buff =~ /^#\?(RADIANCE|RGBE)\x0a/s
Truth table33%1/3
A and B
A= $raf->ReadLine($buff)B= $buff =~ /^#\?(RADIANCE|RGBE)\x0a/s
ABresult
0X0
100
111
72 1 $et->SetFileType();
73 1 my $tagTablePtr = GetTagTable('Image::ExifTool::Radiance::Main');
74  
75 1 ▶ while ($raf->ReadLine($buff)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($raf->ReadLine($buff)) 9 0 9
76 9 chomp $buff;
77 9 ▶ last unless length($buff) > 0 and length($buff) < 4096;
Branch: 1 branch
BranchTrueFalseTotal
unless length $buff > 0 and length $buff < 4096 1 8 9
Condition66%2/3
length $buff > 0 and length $buff < 4096
!ll&&!rl&&r
108
MC/DC50%1/2
length $buff > 0 and length $buff < 4096
length $buff > 0 length $buff < 4096
Truth table66%2/3
A and B
A= length $buff > 0B= length $buff < 4096
ABresult
0X0
100
111
78 8 ▶ if ($buff =~ s/^#\s*//) {
Branch: 1 branch
BranchTrueFalseTotal
if ($buff =~ s/^#\s*//) 0 8 8
79 0 ▶ $et->HandleTag($tagTablePtr, '_comment', $buff) if length $buff;
Branch: 1 branch
BranchTrueFalseTotal
if length $buff 0 0 0
80 0 next;
81 }
82 8 ▶ unless ($buff =~ /^(.*)?\s*=\s*(.*)/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($buff =~ /^(.*)?\s*=\s*(.*)/) 4 4 8
83 4 ▶ $et->HandleTag($tagTablePtr, '_command', $buff) if length $buff;
Branch: 1 branch
BranchTrueFalseTotal
if length $buff 4 0 4
84 4 next;
85 }
86 # use lower-case tag names to avoid conflicts with reserved tag table entries
87 4 my ($tag, $val) = (lc $1, $2);
88 4 my $tagInfo = $et->GetTagInfo($tagTablePtr, $tag);
89 4 ▶ unless ($tagInfo) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($tagInfo) 0 4 4
90 0 my $name = $tag;
91 0 $name =~ tr/-_a-zA-Z0-9//dc;
92 0 ▶ next unless length($name) > 1;
Branch: 1 branch
BranchTrueFalseTotal
unless length $name > 1 0 0 0
93 0 $name = ucfirst $name;
94 0 $tagInfo = { Name => $name };
95 0 AddTagToTable($tagTablePtr, $tag, $tagInfo);
96 }
97 4 $et->FoundTag($tagInfo, $val);
98 }
99 # get image dimensions
100 1 ▶ if ($raf->ReadLine($buff) and $buff =~ /([-+][XY])\s*(\d+)\s*([-+][XY])\s*(\d+)/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($raf->ReadLine($buff) and $buff =~ /([-+][XY])\s*(\d+)\s*([-+][XY])\s*(\d+)/) 1 0 1
Condition33%1/3
$raf->ReadLine($buff) and $buff =~ /([-+][XY])\s*(\d+)\s*([-+][XY])\s*(\d+)/
!ll&&!rl&&r
001
MC/DC0%0/2
$raf->ReadLine($buff) and $buff =~ /([-+][XY])\s*(\d+)\s*([-+][XY])\s*(\d+)/
$raf->ReadLine($buff) $buff =~ /([-+][XY])\s*(\d+)\s*([-+][XY])\s*(\d+)/
Truth table33%1/3
A and B
A= $raf->ReadLine($buff)B= $buff =~ /([-+][XY])\s*(\d+)\s*([-+][XY])\s*(\d+)/
ABresult
0X0
100
111
101 1 $et->HandleTag($tagTablePtr, '_orient', "$1 $3");
102 1 $et->FoundTag('ImageHeight', $2);
103 1 $et->FoundTag('ImageWidth', $4);
104 }
105 1 return 1;
106 }
107  
108 1 1; # end
109  
110 __END__
« Image/ExifTool/BZZ.pm ↑ Summary Image/ExifTool/DSF.pm »