1 | #------------------------------------------------------------------------------
|
---|
2 | # File: SonyIDC.pm
|
---|
3 | #
|
---|
4 | # Description: Read/write Sony IDC information
|
---|
5 | #
|
---|
6 | # Revisions: 2010/01/05 - P. Harvey Created
|
---|
7 | #------------------------------------------------------------------------------
|
---|
8 |
|
---|
9 | package Image::ExifTool::SonyIDC;
|
---|
10 |
|
---|
11 | use strict;
|
---|
12 | use vars qw($VERSION);
|
---|
13 | use Image::ExifTool qw(:DataAccess :Utils);
|
---|
14 |
|
---|
15 | $VERSION = '1.02';
|
---|
16 |
|
---|
17 | # Sony IDC tags (ref PH)
|
---|
18 | %Image::ExifTool::SonyIDC::Main = (
|
---|
19 | WRITE_PROC => \&Image::ExifTool::Exif::WriteExif,
|
---|
20 | CHECK_PROC => \&Image::ExifTool::Exif::CheckExif,
|
---|
21 | GROUPS => { 0 => 'MakerNotes', 2 => 'Image' },
|
---|
22 | NOTES => 'Tags written by the Sony Image Data Converter utility in ARW images.',
|
---|
23 | SET_GROUP1 => 1,
|
---|
24 | 0x201 => {
|
---|
25 | Name => 'IDCPreviewStart',
|
---|
26 | IsOffset => 1,
|
---|
27 | OffsetPair => 0x202,
|
---|
28 | DataTag => 'IDCPreview',
|
---|
29 | Writable => 'int32u',
|
---|
30 | Protected => 2,
|
---|
31 | },
|
---|
32 | 0x202 => {
|
---|
33 | Name => 'IDCPreviewLength',
|
---|
34 | OffsetPair => 0x201,
|
---|
35 | DataTag => 'IDCPreview',
|
---|
36 | Writable => 'int32u',
|
---|
37 | Protected => 2,
|
---|
38 | },
|
---|
39 | 0x8000 => {
|
---|
40 | Name => 'IDCCreativeStyle',
|
---|
41 | Writable => 'int32u',
|
---|
42 | PrintConvColumns => 2,
|
---|
43 | PrintConv => {
|
---|
44 | 1 => 'Camera Setting',
|
---|
45 | 2 => 'Standard',
|
---|
46 | 3 => 'Real',
|
---|
47 | 4 => 'Vivid',
|
---|
48 | 5 => 'Adobe RGB',
|
---|
49 | 6 => 'A100 Standard', # shows up as '-' in IDC menu
|
---|
50 | 7 => 'Neutral',
|
---|
51 | 8 => 'Portrait',
|
---|
52 | 9 => 'Landscape',
|
---|
53 | 10 => 'Clear',
|
---|
54 | 11 => 'Deep',
|
---|
55 | 12 => 'Light',
|
---|
56 | 13 => 'Sunset',
|
---|
57 | 14 => 'Night View',
|
---|
58 | 15 => 'Autumn Leaves',
|
---|
59 | 16 => 'B&W',
|
---|
60 | 17 => 'Sepia',
|
---|
61 | },
|
---|
62 | },
|
---|
63 | 0x8001 => {
|
---|
64 | Name => 'CreativeStyleWasChanged',
|
---|
65 | Writable => 'int32u',
|
---|
66 | Notes => 'set if the creative style was ever changed',
|
---|
67 | # (even if it was changed back again later)
|
---|
68 | PrintConv => { 0 => 'No', 1 => 'Yes' },
|
---|
69 | },
|
---|
70 | 0x8002 => {
|
---|
71 | Name => 'PresetWhiteBalance',
|
---|
72 | Writable => 'int32u',
|
---|
73 | PrintConv => {
|
---|
74 | 1 => 'Camera Setting',
|
---|
75 | 2 => 'Color Temperature',
|
---|
76 | 3 => 'Specify Gray Point',
|
---|
77 | 4 => 'Daylight',
|
---|
78 | 5 => 'Cloudy',
|
---|
79 | 6 => 'Shade',
|
---|
80 | 7 => 'Cool White Fluorescent',
|
---|
81 | 8 => 'Day Light Fluorescent',
|
---|
82 | 9 => 'Day White Fluorescent',
|
---|
83 | 10 => 'Warm White Fluorescent',
|
---|
84 | 11 => 'Tungsten',
|
---|
85 | 12 => 'Flash',
|
---|
86 | 13 => 'Auto',
|
---|
87 | },
|
---|
88 | },
|
---|
89 | 0x8013 => { Name => 'ColorTemperatureAdj', Writable => 'int16u' },
|
---|
90 | 0x8014 => { Name => 'PresetWhiteBalanceAdj',Writable => 'int32s' },
|
---|
91 | 0x8015 => { Name => 'ColorCorrection', Writable => 'int32s' },
|
---|
92 | 0x8016 => { Name => 'SaturationAdj', Writable => 'int32s' },
|
---|
93 | 0x8017 => { Name => 'ContrastAdj', Writable => 'int32s' },
|
---|
94 | 0x8018 => { Name => 'BrightnessAdj', Writable => 'int32s' },
|
---|
95 | 0x8019 => { Name => 'HueAdj', Writable => 'int32s' },
|
---|
96 | 0x801a => { Name => 'SharpnessAdj', Writable => 'int32s' },
|
---|
97 | 0x801b => { Name => 'SharpnessOvershoot', Writable => 'int32s' },
|
---|
98 | 0x801c => { Name => 'SharpnessUndershoot', Writable => 'int32s' },
|
---|
99 | 0x801d => { Name => 'SharpnessThreshold', Writable => 'int32s' },
|
---|
100 | 0x801e => {
|
---|
101 | Name => 'NoiseReductionMode',
|
---|
102 | Writable => 'int16u',
|
---|
103 | PrintConv => {
|
---|
104 | 0 => 'Off',
|
---|
105 | 1 => 'On',
|
---|
106 | },
|
---|
107 | },
|
---|
108 | 0x8021 => {
|
---|
109 | Name => 'GrayPoint',
|
---|
110 | Writable => 'int16u',
|
---|
111 | Count => 4,
|
---|
112 | },
|
---|
113 | 0x8022 => {
|
---|
114 | Name => 'D-RangeOptimizerMode',
|
---|
115 | Writable => 'int16u',
|
---|
116 | PrintConv => {
|
---|
117 | 0 => 'Off',
|
---|
118 | 1 => 'Auto',
|
---|
119 | 2 => 'Manual',
|
---|
120 | },
|
---|
121 | },
|
---|
122 | 0x8023 => { Name => 'D-RangeOptimizerValue', Writable => 'int32s' },
|
---|
123 | 0x8024 => { Name => 'D-RangeOptimizerHighlight',Writable => 'int32s' },
|
---|
124 | 0x8026 => {
|
---|
125 | Name => 'HighlightColorDistortReduct',
|
---|
126 | Writable => 'int16u',
|
---|
127 | PrintConv => {
|
---|
128 | 0 => 'Standard',
|
---|
129 | 1 => 'Advanced',
|
---|
130 | },
|
---|
131 | },
|
---|
132 | 0x8027 => {
|
---|
133 | Name => 'NoiseReductionValue',
|
---|
134 | Writable => 'int32s',
|
---|
135 | ValueConv => '($val + 100) / 2',
|
---|
136 | ValueConvInv => '$val * 2 - 100',
|
---|
137 | },
|
---|
138 | 0x8028 => {
|
---|
139 | Name => 'EdgeNoiseReduction',
|
---|
140 | Writable => 'int32s',
|
---|
141 | ValueConv => '($val + 100) / 2',
|
---|
142 | ValueConvInv => '$val * 2 - 100',
|
---|
143 | },
|
---|
144 | 0x8029 => {
|
---|
145 | Name => 'ColorNoiseReduction',
|
---|
146 | Writable => 'int32s',
|
---|
147 | ValueConv => '($val + 100) / 2',
|
---|
148 | ValueConvInv => '$val * 2 - 100',
|
---|
149 | },
|
---|
150 | 0x802d => { Name => 'D-RangeOptimizerShadow', Writable => 'int32s' },
|
---|
151 | 0x8030 => { Name => 'PeripheralIllumCentralRadius', Writable => 'int32s' },
|
---|
152 | 0x8031 => { Name => 'PeripheralIllumCentralValue', Writable => 'int32s' },
|
---|
153 | 0x8032 => { Name => 'PeripheralIllumPeriphValue', Writable => 'int32s' },
|
---|
154 | 0x9000 => {
|
---|
155 | Name => 'ToneCurveBrightnessX',
|
---|
156 | Writable => 'int16u',
|
---|
157 | Count => -1,
|
---|
158 | },
|
---|
159 | 0x9001 => {
|
---|
160 | Name => 'ToneCurveRedX',
|
---|
161 | Writable => 'int16u',
|
---|
162 | Count => -1,
|
---|
163 | },
|
---|
164 | 0x9002 => {
|
---|
165 | Name => 'ToneCurveGreenX',
|
---|
166 | Writable => 'int16u',
|
---|
167 | Count => -1,
|
---|
168 | },
|
---|
169 | 0x9003 => {
|
---|
170 | Name => 'ToneCurveBlueX',
|
---|
171 | Writable => 'int16u',
|
---|
172 | Count => -1,
|
---|
173 | },
|
---|
174 | 0x9004 => {
|
---|
175 | Name => 'ToneCurveBrightnessY',
|
---|
176 | Writable => 'int16u',
|
---|
177 | Count => -1,
|
---|
178 | },
|
---|
179 | 0x9005 => {
|
---|
180 | Name => 'ToneCurveRedY',
|
---|
181 | Writable => 'int16u',
|
---|
182 | Count => -1,
|
---|
183 | },
|
---|
184 | 0x9006 => {
|
---|
185 | Name => 'ToneCurveGreenY',
|
---|
186 | Writable => 'int16u',
|
---|
187 | Count => -1,
|
---|
188 | },
|
---|
189 | 0x9007 => {
|
---|
190 | Name => 'ToneCurveBlueY',
|
---|
191 | Writable => 'int16u',
|
---|
192 | Count => -1,
|
---|
193 | },
|
---|
194 | 0xd000 => { Name => 'CurrentVersion', Writable => 'int32u' },
|
---|
195 | 0xd001 => {
|
---|
196 | Name => 'VersionIFD',
|
---|
197 | Groups => { 1 => 'Version0' },
|
---|
198 | Flags => 'SubIFD',
|
---|
199 | Notes => 'there is one VersionIFD for each entry in the "Version Stack"',
|
---|
200 | SubDirectory => {
|
---|
201 | DirName => 'Version0',
|
---|
202 | TagTable => 'Image::ExifTool::SonyIDC::Main',
|
---|
203 | Start => '$val',
|
---|
204 | Base => '$start',
|
---|
205 | MaxSubdirs => 20, # (IDC v3.0 writes max. 10)
|
---|
206 | RelativeBase => 1, # needed to write SubIFD with relative offsets
|
---|
207 | },
|
---|
208 | },
|
---|
209 | 0xd100 => {
|
---|
210 | Name => 'VersionCreateDate',
|
---|
211 | Writable => 'string',
|
---|
212 | Groups => { 2 => 'Time' },
|
---|
213 | Notes => 'date/time when this entry was created in the "Version Stack"',
|
---|
214 | Shift => 'Time',
|
---|
215 | PrintConv => '$self->ConvertDateTime($val)',
|
---|
216 | PrintConvInv => '$self->InverseDateTime($val,0)',
|
---|
217 | },
|
---|
218 | 0xd101 => {
|
---|
219 | Name => 'VersionModifyDate',
|
---|
220 | Writable => 'string',
|
---|
221 | Groups => { 2 => 'Time' },
|
---|
222 | Shift => 'Time',
|
---|
223 | PrintConv => '$self->ConvertDateTime($val)',
|
---|
224 | PrintConvInv => '$self->InverseDateTime($val,0)',
|
---|
225 | },
|
---|
226 | );
|
---|
227 |
|
---|
228 | # extract IDC preview images as composite tags
|
---|
229 | %Image::ExifTool::SonyIDC::Composite = (
|
---|
230 | GROUPS => { 2 => 'Image' },
|
---|
231 | IDCPreviewImage => {
|
---|
232 | Require => {
|
---|
233 | 0 => 'IDCPreviewStart',
|
---|
234 | 1 => 'IDCPreviewLength',
|
---|
235 | },
|
---|
236 | # extract all preview images (not just one)
|
---|
237 | RawConv => q{
|
---|
238 | require Image::ExifTool::SonyIDC;
|
---|
239 | Image::ExifTool::SonyIDC::ExtractPreviews($self);
|
---|
240 | },
|
---|
241 | },
|
---|
242 | );
|
---|
243 |
|
---|
244 | # add our composite tags
|
---|
245 | Image::ExifTool::AddCompositeTags('Image::ExifTool::SonyIDC');
|
---|
246 |
|
---|
247 | # set "Permanent" flag for all tags
|
---|
248 | {
|
---|
249 | my $key;
|
---|
250 | foreach $key (TagTableKeys(\%Image::ExifTool::SonyIDC::Main)) {
|
---|
251 | $Image::ExifTool::SonyIDC::Main{$key}{Permanent} = 1;
|
---|
252 | }
|
---|
253 | }
|
---|
254 |
|
---|
255 | #------------------------------------------------------------------------------
|
---|
256 | # Extract all IDC preview images
|
---|
257 | # Inputs: 0) ExifTool object ref
|
---|
258 | # Returns: data for "IDCPreviewImage" tag (which I have never seen),
|
---|
259 | # or undef if there was no preview in the SonyIDC IFD
|
---|
260 | sub ExtractPreviews($)
|
---|
261 | {
|
---|
262 | my $exifTool = shift;
|
---|
263 | my $i = 1;
|
---|
264 | my $xtra = ' (1)';
|
---|
265 | my $preview;
|
---|
266 | # loop through all available IDC preview images in the order they were found
|
---|
267 | for (;;) {
|
---|
268 | my $key = "IDCPreviewStart$xtra";
|
---|
269 | unless (defined $$exifTool{VALUE}{$key}) {
|
---|
270 | last unless $xtra;
|
---|
271 | $xtra = ''; # do the last tag extracted last
|
---|
272 | next;
|
---|
273 | }
|
---|
274 | # run through IDC preview images in the same order they were extracted
|
---|
275 | my $off = $exifTool->GetValue($key) or last;
|
---|
276 | my $len = $exifTool->GetValue("IDCPreviewLength$xtra") or last;
|
---|
277 | # get stack version from number in group 1 name
|
---|
278 | my $grp1 = $exifTool->GetGroup($key, 1);
|
---|
279 | if ($grp1 =~ /(\d+)$/) {
|
---|
280 | my $tag = "IDCPreviewImage$1";
|
---|
281 | unless ($Image::ExifTool::Extra{$tag}) {
|
---|
282 | Image::ExifTool::AddTagToTable(\%Image::ExifTool::Extra, $tag, {
|
---|
283 | Name => $tag,
|
---|
284 | Groups => { 0 => 'Composite', 1 => 'Composite', 2 => 'Image'},
|
---|
285 | });
|
---|
286 | }
|
---|
287 | my $val = Image::ExifTool::Exif::ExtractImage($exifTool, $off, $len, $tag);
|
---|
288 | $exifTool->FoundTag($tag, $val);
|
---|
289 | } else {
|
---|
290 | $preview = Image::ExifTool::Exif::ExtractImage($exifTool, $off, $len, 'IDCPreviewImage');
|
---|
291 | }
|
---|
292 | # step to next set of tags unless we are done
|
---|
293 | last unless $xtra;
|
---|
294 | ++$i;
|
---|
295 | $xtra = " ($i)";
|
---|
296 | }
|
---|
297 | return $preview;
|
---|
298 | }
|
---|
299 |
|
---|
300 | 1; # end
|
---|
301 |
|
---|
302 | __END__
|
---|
303 |
|
---|
304 | =head1 NAME
|
---|
305 |
|
---|
306 | Image::ExifTool::SonyIDC - Read/write Sony IDC information
|
---|
307 |
|
---|
308 | =head1 SYNOPSIS
|
---|
309 |
|
---|
310 | This module is used by Image::ExifTool
|
---|
311 |
|
---|
312 | =head1 DESCRIPTION
|
---|
313 |
|
---|
314 | This module contains definitions required by Image::ExifTool to read and
|
---|
315 | write Sony Image Data Converter verson 3.0 metadata in ARW images.
|
---|
316 |
|
---|
317 | =head1 AUTHOR
|
---|
318 |
|
---|
319 | Copyright 2003-2011, Phil Harvey (phil at owl.phy.queensu.ca)
|
---|
320 |
|
---|
321 | This library is free software; you can redistribute it and/or modify it
|
---|
322 | under the same terms as Perl itself.
|
---|
323 |
|
---|
324 | =head1 SEE ALSO
|
---|
325 |
|
---|
326 | L<Image::ExifTool::TagNames/SonyIDC Tags>,
|
---|
327 | L<Image::ExifTool(3pm)|Image::ExifTool>
|
---|
328 |
|
---|
329 | =cut
|
---|
330 |
|
---|