line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
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
|
|
|
1
|
|
4322
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
33
|
|
15
|
1
|
|
|
1
|
|
6
|
use vars qw($VERSION); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
39
|
|
16
|
1
|
|
|
1
|
|
6
|
use Image::ExifTool qw(:DataAccess :Utils); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
791
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
$VERSION = '1.02'; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# Radiance tags |
21
|
|
|
|
|
|
|
%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 and |
28
|
|
|
|
|
|
|
L 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
|
|
|
|
|
|
|
{ |
65
|
1
|
|
|
1
|
0
|
12
|
my ($et, $dirInfo) = @_; |
66
|
1
|
|
|
|
|
7
|
my $raf = $$dirInfo{RAF}; |
67
|
1
|
|
|
|
|
2
|
my $buff; |
68
|
1
|
|
|
|
|
7
|
local $/ = "\x0a"; # set newline character for reading |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
# verify this is a valid RIFF file |
71
|
1
|
50
|
33
|
|
|
7
|
return 0 unless $raf->ReadLine($buff) and $buff =~ /^#\?(RADIANCE|RGBE)\x0a/s; |
72
|
1
|
|
|
|
|
9
|
$et->SetFileType(); |
73
|
1
|
|
|
|
|
4
|
my $tagTablePtr = GetTagTable('Image::ExifTool::Radiance::Main'); |
74
|
|
|
|
|
|
|
|
75
|
1
|
|
|
|
|
5
|
while ($raf->ReadLine($buff)) { |
76
|
9
|
|
|
|
|
16
|
chomp $buff; |
77
|
9
|
100
|
66
|
|
|
34
|
last unless length($buff) > 0 and length($buff) < 4096; |
78
|
8
|
50
|
|
|
|
18
|
if ($buff =~ s/^#\s*//) { |
79
|
0
|
0
|
|
|
|
0
|
$et->HandleTag($tagTablePtr, '_comment', $buff) if length $buff; |
80
|
0
|
|
|
|
|
0
|
next; |
81
|
|
|
|
|
|
|
} |
82
|
8
|
100
|
|
|
|
63
|
unless ($buff =~ /^(.*)?\s*=\s*(.*)/) { |
83
|
4
|
50
|
|
|
|
22
|
$et->HandleTag($tagTablePtr, '_command', $buff) if length $buff; |
84
|
4
|
|
|
|
|
13
|
next; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
# use lower-case tag names to avoid conflicts with reserved tag table entries |
87
|
4
|
|
|
|
|
20
|
my ($tag, $val) = (lc $1, $2); |
88
|
4
|
|
|
|
|
11
|
my $tagInfo = $et->GetTagInfo($tagTablePtr, $tag); |
89
|
4
|
50
|
|
|
|
10
|
unless ($tagInfo) { |
90
|
0
|
|
|
|
|
0
|
my $name = $tag; |
91
|
0
|
|
|
|
|
0
|
$name =~ tr/-_a-zA-Z0-9//dc; |
92
|
0
|
0
|
|
|
|
0
|
next unless length($name) > 1; |
93
|
0
|
|
|
|
|
0
|
$name = ucfirst $name; |
94
|
0
|
|
|
|
|
0
|
$tagInfo = { Name => $name }; |
95
|
0
|
|
|
|
|
0
|
AddTagToTable($tagTablePtr, $tag, $tagInfo); |
96
|
|
|
|
|
|
|
} |
97
|
4
|
|
|
|
|
10
|
$et->FoundTag($tagInfo, $val); |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
# get image dimensions |
100
|
1
|
50
|
33
|
|
|
6
|
if ($raf->ReadLine($buff) and $buff =~ /([-+][XY])\s*(\d+)\s*([-+][XY])\s*(\d+)/) { |
101
|
1
|
|
|
|
|
19
|
$et->HandleTag($tagTablePtr, '_orient', "$1 $3"); |
102
|
1
|
|
|
|
|
4
|
$et->FoundTag('ImageHeight', $2); |
103
|
1
|
|
|
|
|
9
|
$et->FoundTag('ImageWidth', $4); |
104
|
|
|
|
|
|
|
} |
105
|
1
|
|
|
|
|
6
|
return 1; |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
1; # end |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
__END__ |