File Coverage

blib/lib/Image/ExifTool/FujiFilm.pm
Criterion Covered Total %
statement 114 155 73.5
branch 40 86 46.5
condition 18 54 33.3
subroutine 7 8 87.5
pod 0 4 0.0
total 179 307 58.3


line stmt bran cond sub pod time code
1             #------------------------------------------------------------------------------
2             # File: FujiFilm.pm
3             #
4             # Description: Read/write FujiFilm maker notes and RAF images
5             #
6             # Revisions: 11/25/2003 - P. Harvey Created
7             # 11/14/2007 - PH Added ability to write RAF images
8             #
9             # References: 1) http://park2.wakwak.com/~tsuruzoh/Computer/Digicams/exif-e.html
10             # 2) http://homepage3.nifty.com/kamisaka/makernote/makernote_fuji.htm (2007/09/11)
11             # 3) Michael Meissner private communication
12             # 4) Paul Samuelson private communication (S5)
13             # 5) http://www.cybercom.net/~dcoffin/dcraw/
14             # 6) http://forums.dpreview.com/forums/readflat.asp?forum=1012&thread=31350384
15             # and http://forum.photome.de/viewtopic.php?f=2&t=353&p=742#p740
16             # 7) Kai Lappalainen private communication
17             # 8) https://exiftool.org/forum/index.php/topic,5223.0.html
18             # 9) Zilvinas Brobliauskas private communication
19             # 10) Albert Shan private communication
20             # 11) https://exiftool.org/forum/index.php/topic,8377.0.html
21             # 12) https://exiftool.org/forum/index.php/topic,9607.0.html
22             # 13) https://exiftool.org/forum/index.php/topic=10481.0.html
23             # IB) Iliah Borg private communication (LibRaw)
24             # JD) Jens Duttke private communication
25             #------------------------------------------------------------------------------
26              
27             package Image::ExifTool::FujiFilm;
28              
29 19     19   4715 use strict;
  19         59  
  19         818  
30 19     19   120 use vars qw($VERSION);
  19         65  
  19         913  
31 19     19   134 use Image::ExifTool qw(:DataAccess :Utils);
  19         50  
  19         4759  
32 19     19   1537 use Image::ExifTool::Exif;
  19         56  
  19         82959  
33              
34             $VERSION = '1.84';
35              
36             sub ProcessFujiDir($$$);
37             sub ProcessFaceRec($$$);
38              
39             # the following RAF version numbers have been tested for writing:
40             # (as of ExifTool 11.70, this lookup is no longer used if the version number is numerical)
41             my %testedRAF = (
42             '0100' => 'E550, E900, F770, S5600, S6000fd, S6500fd, HS10/HS11, HS30, S200EXR, X100, XF1, X-Pro1, X-S1, XQ2 Ver1.00, X-T100, GFX 50R, XF10',
43             '0101' => 'X-E1, X20 Ver1.01, X-T3',
44             '0102' => 'S100FS, X10 Ver1.02',
45             '0103' => 'IS Pro Ver1.03',
46             '0104' => 'S5Pro Ver1.04',
47             '0106' => 'S5Pro Ver1.06',
48             '0111' => 'S5Pro Ver1.11',
49             '0114' => 'S9600 Ver1.00',
50             '0132' => 'X-T2 Ver1.32',
51             '0144' => 'X100T Ver1.44',
52             '0159' => 'S2Pro Ver1.00',
53             '0200' => 'X10 Ver2.00',
54             '0201' => 'X-H1 Ver2.01',
55             '0212' => 'S3Pro Ver2.12',
56             '0216' => 'S3Pro Ver2.16', # (NC)
57             '0218' => 'S3Pro Ver2.18',
58             '0240' => 'X-E1 Ver2.40',
59             '0264' => 'F700 Ver2.00',
60             '0266' => 'S9500 Ver1.01',
61             '0261' => 'X-E1 Ver2.61',
62             '0269' => 'S9500 Ver1.02',
63             '0271' => 'S3Pro Ver2.71', # UV/IR model?
64             '0300' => 'X-E2',
65             # 0400 - expect to see this for X-T1
66             '0540' => 'X-T1 Ver5.40',
67             '0712' => 'S5000 Ver3.00',
68             '0716' => 'S5000 Ver3.00', # (yes, 2 RAF versions with the same Software version)
69             '0Dgi' => 'X-A10 Ver1.01 and X-A3 Ver1.02', # (yes, non-digits in the firmware number)
70             );
71              
72             my %faceCategories = (
73             Format => 'int8u',
74             PrintConv => { BITMASK => {
75             1 => 'Partner',
76             2 => 'Family',
77             3 => 'Friend',
78             }},
79             );
80              
81             # FujiFilm MakerNotes tags
82             %Image::ExifTool::FujiFilm::Main = (
83             WRITE_PROC => \&Image::ExifTool::Exif::WriteExif,
84             CHECK_PROC => \&Image::ExifTool::Exif::CheckExif,
85             WRITABLE => 1,
86             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
87             0x0 => {
88             Name => 'Version',
89             Writable => 'undef',
90             },
91             0x0010 => { #PH/IB
92             Name => 'InternalSerialNumber',
93             Writable => 'string',
94             Notes => q{
95             this number is unique for most models, and contains the camera model ID and
96             the date of manufacture
97             },
98             # eg) "FPX20017035 592D31313034060427796060110384"
99             # "FPX 20495643 592D313335310701318AD010110047" (F40fd)
100             # HHHHHHHHHHHHyymmdd
101             # HHHHHHHHHHHH = camera body number in hex
102             # yymmdd = date of manufacture
103             PrintConv => q{
104             if ($val =~ /^(.*?\s*)([0-9a-fA-F]*)(\d{2})(\d{2})(\d{2})(.{12})\s*\0*$/s
105             and $4 >= 1 and $4 <= 12 and $5 >= 1 and $5 <= 31)
106             {
107             my $yr = $3 + ($3 < 70 ? 2000 : 1900);
108             my $sn = pack 'H*', $2;
109             return "$1$sn $yr:$4:$5 $6";
110             } else {
111             # handle a couple of models which use a slightly different format
112             $val =~ s/\b(592D(3[0-9])+)/pack("H*",$1).' '/e;
113             }
114             return $val;
115             },
116             # (this inverse conversion doesn't work in all cases, so it is best to write
117             # the ValueConv value if an authentic internal serial number is required)
118             PrintConvInv => '$_=$val; s/(\S+) (19|20)(\d{2}):(\d{2}):(\d{2}) /unpack("H*",$1)."$3$4$5"/e; $_',
119             },
120             0x1000 => {
121             Name => 'Quality',
122             Writable => 'string',
123             },
124             0x1001 => {
125             Name => 'Sharpness',
126             Flags => 'PrintHex',
127             Writable => 'int16u',
128             PrintConv => {
129             0x00 => '-4 (softest)', #10
130             0x01 => '-3 (very soft)',
131             0x02 => '-2 (soft)',
132             0x03 => '0 (normal)',
133             0x04 => '+2 (hard)',
134             0x05 => '+3 (very hard)',
135             0x06 => '+4 (hardest)',
136             0x82 => '-1 (medium soft)', #2
137             0x84 => '+1 (medium hard)', #2
138             0x8000 => 'Film Simulation', #2
139             0xffff => 'n/a', #2
140             },
141             },
142             0x1002 => {
143             Name => 'WhiteBalance',
144             Flags => 'PrintHex',
145             Writable => 'int16u',
146             PrintConv => {
147             0x0 => 'Auto',
148             0x1 => 'Auto (white priority)', #forum10890
149             0x2 => 'Auto (ambiance priority)', #forum10890
150             0x100 => 'Daylight',
151             0x200 => 'Cloudy',
152             0x300 => 'Daylight Fluorescent',
153             0x301 => 'Day White Fluorescent',
154             0x302 => 'White Fluorescent',
155             0x303 => 'Warm White Fluorescent', #2/PH (S5)
156             0x304 => 'Living Room Warm White Fluorescent', #2/PH (S5)
157             0x400 => 'Incandescent',
158             0x500 => 'Flash', #4
159             0x600 => 'Underwater', #forum6109
160             0xf00 => 'Custom',
161             0xf01 => 'Custom2', #2
162             0xf02 => 'Custom3', #2
163             0xf03 => 'Custom4', #2
164             0xf04 => 'Custom5', #2
165             # 0xfe0 => 'Gray Point?', #2
166             0xff0 => 'Kelvin', #4
167             },
168             },
169             0x1003 => {
170             Name => 'Saturation',
171             Flags => 'PrintHex',
172             Writable => 'int16u',
173             PrintConv => {
174             0x0 => '0 (normal)', # # ("Color 0", ref 8)
175             0x080 => '+1 (medium high)', #2 ("Color +1", ref 8)
176             0x100 => '+2 (high)', # ("Color +2", ref 8)
177             0x0c0 => '+3 (very high)',
178             0x0e0 => '+4 (highest)',
179             0x180 => '-1 (medium low)', #2 ("Color -1", ref 8)
180             0x200 => 'Low',
181             0x300 => 'None (B&W)', #2
182             0x301 => 'B&W Red Filter', #PH/8
183             0x302 => 'B&W Yellow Filter', #PH (X100)
184             0x303 => 'B&W Green Filter', #PH/8
185             0x310 => 'B&W Sepia', #PH (X100)
186             0x400 => '-2 (low)', #8 ("Color -2")
187             0x4c0 => '-3 (very low)',
188             0x4e0 => '-4 (lowest)',
189             0x500 => 'Acros', #PH (X-Pro2)
190             0x501 => 'Acros Red Filter', #PH (X-Pro2)
191             0x502 => 'Acros Yellow Filter', #PH (X-Pro2)
192             0x503 => 'Acros Green Filter', #PH (X-Pro2)
193             0x8000 => 'Film Simulation', #2
194             },
195             },
196             0x1004 => {
197             Name => 'Contrast',
198             Flags => 'PrintHex',
199             Writable => 'int16u',
200             PrintConv => {
201             0x0 => 'Normal',
202             0x080 => 'Medium High', #2
203             0x100 => 'High',
204             0x180 => 'Medium Low', #2
205             0x200 => 'Low',
206             0x8000 => 'Film Simulation', #2
207             },
208             },
209             0x1005 => { #4
210             Name => 'ColorTemperature',
211             Writable => 'int16u',
212             },
213             0x1006 => { #JD
214             Name => 'Contrast',
215             Flags => 'PrintHex',
216             Writable => 'int16u',
217             PrintConv => {
218             0x0 => 'Normal',
219             0x100 => 'High',
220             0x300 => 'Low',
221             },
222             },
223             0x100a => { #2
224             Name => 'WhiteBalanceFineTune',
225             Writable => 'int32s',
226             Count => 2,
227             PrintConv => 'sprintf("Red %+d, Blue %+d", split(" ", $val))',
228             PrintConvInv => 'my @v=($val=~/-?\d+/g);"@v"',
229             },
230             0x100b => { #2
231             Name => 'NoiseReduction',
232             Flags => 'PrintHex',
233             Writable => 'int16u',
234             RawConv => '$val == 0x100 ? undef : $val',
235             PrintConv => {
236             0x40 => 'Low',
237             0x80 => 'Normal',
238             0x100 => 'n/a', #PH (NC) (all X100 samples)
239             },
240             },
241             0x100e => { #PH (X100)
242             Name => 'NoiseReduction',
243             Flags => 'PrintHex',
244             Writable => 'int16u',
245             PrintConv => {
246             0x000 => '0 (normal)', # ("NR 0, ref 8)
247             0x100 => '+2 (strong)', # ("NR+2, ref 8)
248             0x180 => '+1 (medium strong)', #8 ("NR+1")
249             0x1c0 => '+3 (very strong)',
250             0x1e0 => '+4 (strongest)',
251             0x200 => '-2 (weak)', # ("NR-2, ref 8)
252             0x280 => '-1 (medium weak)', #8 ("NR-1")
253             0x2c0 => '-3 (very weak)', #10 (-3)
254             0x2e0 => '-4 (weakest)', #10 (-4)
255             },
256             },
257             0x100f => { #PR158
258             Name => 'Clarity',
259             Writable => 'int32s', #PH
260             PrintConv => {
261             -5000 => '-5',
262             -4000 => '-4',
263             -3000 => '-3',
264             -2000 => '-2',
265             -1000 => '-1',
266             0 => '0',
267             1000 => '1',
268             2000 => '2',
269             3000 => '3',
270             4000 => '4',
271             5000 => '5',
272             },
273             },
274             0x1010 => {
275             Name => 'FujiFlashMode',
276             Writable => 'int16u',
277             PrintHex => 1,
278             PrintConv => {
279             0 => 'Auto',
280             1 => 'On',
281             2 => 'Off',
282             3 => 'Red-eye reduction',
283             4 => 'External', #JD
284             16 => 'Commander',
285             0x8000 => 'Not Attached', #10 (X-T2) (or external flash off)
286             0x8120 => 'TTL', #10 (X-T2)
287             0x8320 => 'TTL Auto - Did not fire',
288             0x9840 => 'Manual', #10 (X-T2)
289             0x9860 => 'Flash Commander', #13
290             0x9880 => 'Multi-flash', #10 (X-T2)
291             0xa920 => '1st Curtain (front)', #10 (EF-X500 flash)
292             0xaa20 => 'TTL Slow - 1st Curtain (front)', #13
293             0xab20 => 'TTL Auto - 1st Curtain (front)', #13
294             0xad20 => 'TTL - Red-eye Flash - 1st Curtain (front)', #13
295             0xae20 => 'TTL Slow - Red-eye Flash - 1st Curtain (front)', #13
296             0xaf20 => 'TTL Auto - Red-eye Flash - 1st Curtain (front)', #13
297             0xc920 => '2nd Curtain (rear)', #10
298             0xca20 => 'TTL Slow - 2nd Curtain (rear)', #13
299             0xcb20 => 'TTL Auto - 2nd Curtain (rear)', #13
300             0xcd20 => 'TTL - Red-eye Flash - 2nd Curtain (rear)', #13
301             0xce20 => 'TTL Slow - Red-eye Flash - 2nd Curtain (rear)', #13
302             0xcf20 => 'TTL Auto - Red-eye Flash - 2nd Curtain (rear)', #13
303             0xe920 => 'High Speed Sync (HSS)', #10
304             },
305             },
306             0x1011 => {
307             Name => 'FlashExposureComp', #JD
308             Writable => 'rational64s',
309             },
310             0x1020 => {
311             Name => 'Macro',
312             Writable => 'int16u',
313             PrintConv => {
314             0 => 'Off',
315             1 => 'On',
316             },
317             },
318             0x1021 => {
319             Name => 'FocusMode',
320             Writable => 'int16u',
321             PrintConv => {
322             0 => 'Auto',
323             1 => 'Manual',
324             65535 => 'Movie', #forum10766
325             },
326             },
327             0x1022 => { #8/forum6579
328             Name => 'AFMode',
329             Writable => 'int16u',
330             Notes => '"No" for manual and some AF-multi focus modes',
331             PrintConv => {
332             0 => 'No',
333             1 => 'Single Point',
334             256 => 'Zone',
335             512 => 'Wide/Tracking',
336             },
337             },
338             0x102b => {
339             Name => 'PrioritySettings',
340             SubDirectory => { TagTable => 'Image::ExifTool::FujiFilm::PrioritySettings' },
341             },
342             0x102d => {
343             Name => 'FocusSettings',
344             SubDirectory => { TagTable => 'Image::ExifTool::FujiFilm::FocusSettings' },
345             },
346             0x102e => {
347             Name => 'AFCSettings',
348             SubDirectory => { TagTable => 'Image::ExifTool::FujiFilm::AFCSettings' },
349             },
350             0x1023 => { #2
351             Name => 'FocusPixel',
352             Writable => 'int16u',
353             Count => 2,
354             },
355             0x1030 => {
356             Name => 'SlowSync',
357             Writable => 'int16u',
358             PrintConv => {
359             0 => 'Off',
360             1 => 'On',
361             },
362             },
363             0x1031 => {
364             Name => 'PictureMode',
365             Flags => 'PrintHex',
366             Writable => 'int16u',
367             PrintConv => {
368             0x0 => 'Auto', # (or 'SR+' if SceneRecognition present, ref 11)
369             0x1 => 'Portrait',
370             0x2 => 'Landscape',
371             0x3 => 'Macro', #JD
372             0x4 => 'Sports',
373             0x5 => 'Night Scene',
374             0x6 => 'Program AE',
375             0x7 => 'Natural Light', #3
376             0x8 => 'Anti-blur', #3
377             0x9 => 'Beach & Snow', #JD
378             0xa => 'Sunset', #3
379             0xb => 'Museum', #3
380             0xc => 'Party', #3
381             0xd => 'Flower', #3
382             0xe => 'Text', #3
383             0xf => 'Natural Light & Flash', #3
384             0x10 => 'Beach', #3
385             0x11 => 'Snow', #3
386             0x12 => 'Fireworks', #3
387             0x13 => 'Underwater', #3
388             0x14 => 'Portrait with Skin Correction', #7
389             0x16 => 'Panorama', #PH (X100)
390             0x17 => 'Night (tripod)', #7
391             0x18 => 'Pro Low-light', #7
392             0x19 => 'Pro Focus', #7
393             0x1a => 'Portrait 2', #PH (NC, T500, maybe "Smile & Shoot"?)
394             0x1b => 'Dog Face Detection', #7
395             0x1c => 'Cat Face Detection', #7
396             0x30 => 'HDR', #forum10799
397             0x40 => 'Advanced Filter',
398             0x100 => 'Aperture-priority AE',
399             0x200 => 'Shutter speed priority AE',
400             0x300 => 'Manual',
401             },
402             },
403             0x1032 => { #8
404             Name => 'ExposureCount',
405             Writable => 'int16u',
406             Notes => 'number of exposures used for this image',
407             },
408             0x1033 => { #6
409             Name => 'EXRAuto',
410             Writable => 'int16u',
411             PrintConv => {
412             0 => 'Auto',
413             1 => 'Manual',
414             },
415             },
416             0x1034 => { #6
417             Name => 'EXRMode',
418             Writable => 'int16u',
419             PrintHex => 1,
420             PrintConv => {
421             0x100 => 'HR (High Resolution)',
422             0x200 => 'SN (Signal to Noise priority)',
423             0x300 => 'DR (Dynamic Range priority)',
424             },
425             },
426             0x1040 => { #8
427             Name => 'ShadowTone',
428             Writable => 'int32s',
429             PrintConv => {
430             -64 => '+4 (hardest)',
431             -48 => '+3 (very hard)',
432             -32 => '+2 (hard)',
433             -16 => '+1 (medium hard)',
434             0 => '0 (normal)',
435             16 => '-1 (medium soft)',
436             32 => '-2 (soft)',
437             },
438             },
439             0x1041 => { #8
440             Name => 'HighlightTone',
441             Writable => 'int32s',
442             PrintConv => {
443             -64 => '+4 (hardest)',
444             -48 => '+3 (very hard)',
445             -32 => '+2 (hard)',
446             -16 => '+1 (medium hard)',
447             0 => '0 (normal)',
448             16 => '-1 (medium soft)',
449             32 => '-2 (soft)',
450             },
451             },
452             0x1044 => { #forum7668
453             Name => 'DigitalZoom',
454             Writable => 'int32u',
455             ValueConv => '$val / 8',
456             ValueConvInv => '$val * 8',
457             },
458             0x1045 => { #12
459             Name => 'LensModulationOptimizer',
460             Writable => 'int32u',
461             PrintConv => { 0 => 'Off', 1 => 'On' },
462             },
463             0x1047 => { #12
464             Name => 'GrainEffectRoughness',
465             Writable => 'int32s',
466             PrintConv => {
467             0 => 'Off',
468             32 => 'Weak',
469             64 => 'Strong',
470             },
471             },
472             0x1048 => { #12
473             Name => 'ColorChromeEffect',
474             Writable => 'int32s',
475             PrintConv => {
476             0 => 'Off',
477             32 => 'Weak',
478             64 => 'Strong',
479             },
480             },
481             0x1049 => { #12
482             Name => 'BWAdjustment',
483             Notes => 'positive values are warm, negative values are cool',
484             Format => 'int8s',
485             PrintConv => '$val > 0 ? "+$val" : $val',
486             PrintConvInv => '$val + 0',
487             },
488             # 0x104b - BWAdjustment for Green->Magenta (forum10800)
489             0x104c => { #PR158
490             Name => "GrainEffectSize",
491             Writable => 'int16u', #PH
492             PrintConv => {
493             0 => 'Off',
494             16 => 'Small',
495             32 => 'Large',
496             },
497             },
498             0x104d => { #forum9634
499             Name => 'CropMode',
500             Writable => 'int16u',
501             PrintConv => { # (perhaps this is a bit mask?)
502             0 => 'n/a',
503             1 => 'Full-frame on GFX', #IB
504             2 => 'Sports Finder Mode', # (mechanical shutter)
505             4 => 'Electronic Shutter 1.25x Crop', # (continuous high)
506             },
507             },
508             0x1050 => { #forum6109
509             Name => 'ShutterType',
510             Writable => 'int16u',
511             PrintConv => {
512             0 => 'Mechanical',
513             1 => 'Electronic',
514             2 => 'Electronic (long shutter speed)', #12
515             3 => 'Electronic Front Curtain', #10
516             },
517             },
518             # 0x1100 - This may not work well for newer cameras (ref forum12682)
519             0x1100 => [{
520             Name => 'AutoBracketing',
521             Condition => '$$self{Model} eq "X-T3"',
522             Notes => 'X-T3 only',
523             Writable => 'int16u',
524             PrintConv => {
525             0 => 'Off',
526             1 => 'On',
527             2 => 'Pre-shot', #12 (Electronic Shutter and Continuous High drive mode only)
528             },
529             },{
530             Name => 'AutoBracketing',
531             Notes => 'other models',
532             Writable => 'int16u',
533             PrintConv => {
534             0 => 'Off',
535             1 => 'On',
536             2 => 'No flash & flash', #3
537             6 => 'Pixel Shift', #IB (GFX100S)
538             },
539             }],
540             0x1101 => {
541             Name => 'SequenceNumber',
542             Writable => 'int16u',
543             },
544             0x1103 => {
545             Name => 'DriveSettings',
546             SubDirectory => { TagTable => 'Image::ExifTool::FujiFilm::DriveSettings' },
547             },
548             0x1105 => { Name => 'PixelShiftShots', Writable => 'int16u' }, #IB
549             0x1106 => { Name => 'PixelShiftOffset', Writable => 'rational64s', Count => 2 }, #IB
550             # (0x1150-0x1152 exist only for Pro Low-light and Pro Focus PictureModes)
551             # 0x1150 - Pro Low-light - val=1; Pro Focus - val=2 (ref 7); HDR - val=128 (forum10799)
552             # 0x1151 - Pro Low-light - val=4 (number of pictures taken?); Pro Focus - val=2,3 (ref 7); HDR - val=3 (forum10799)
553             # 0x1152 - Pro Low-light - val=1,3,4 (stacked pictures used?); Pro Focus - val=1,2 (ref 7); HDR - val=3 (forum10799)
554             0x1153 => { #forum7668
555             Name => 'PanoramaAngle',
556             Writable => 'int16u',
557             },
558             0x1154 => { #forum7668
559             Name => 'PanoramaDirection',
560             Writable => 'int16u',
561             PrintConv => {
562             1 => 'Right',
563             2 => 'Up',
564             3 => 'Left',
565             4 => 'Down',
566             },
567             },
568             0x1201 => { #forum6109
569             Name => 'AdvancedFilter',
570             Writable => 'int32u',
571             PrintHex => 1,
572             PrintConv => {
573             0x10000 => 'Pop Color',
574             0x20000 => 'Hi Key',
575             0x30000 => 'Toy Camera',
576             0x40000 => 'Miniature',
577             0x50000 => 'Dynamic Tone',
578             0x60001 => 'Partial Color Red',
579             0x60002 => 'Partial Color Yellow',
580             0x60003 => 'Partial Color Green',
581             0x60004 => 'Partial Color Blue',
582             0x60005 => 'Partial Color Orange',
583             0x60006 => 'Partial Color Purple',
584             0x70000 => 'Soft Focus',
585             0x90000 => 'Low Key',
586             },
587             },
588             0x1210 => { #2
589             Name => 'ColorMode',
590             Writable => 'int16u',
591             PrintHex => 1,
592             PrintConv => {
593             0x00 => 'Standard',
594             0x10 => 'Chrome',
595             0x30 => 'B & W',
596             },
597             },
598             0x1300 => {
599             Name => 'BlurWarning',
600             Writable => 'int16u',
601             PrintConv => {
602             0 => 'None',
603             1 => 'Blur Warning',
604             },
605             },
606             0x1301 => {
607             Name => 'FocusWarning',
608             Writable => 'int16u',
609             PrintConv => {
610             0 => 'Good',
611             1 => 'Out of focus',
612             },
613             },
614             0x1302 => {
615             Name => 'ExposureWarning',
616             Writable => 'int16u',
617             PrintConv => {
618             0 => 'Good',
619             1 => 'Bad exposure',
620             },
621             },
622             0x1304 => { #PH
623             Name => 'GEImageSize',
624             Condition => '$$self{Make} =~ /^GENERAL IMAGING/',
625             Writable => 'string',
626             Notes => 'GE models only',
627             },
628             0x1400 => { #2
629             Name => 'DynamicRange',
630             Writable => 'int16u',
631             PrintConv => {
632             1 => 'Standard',
633             3 => 'Wide',
634             # the S5Pro has 100%(STD),130%,170%,230%(W1),300%,400%(W2) - PH
635             },
636             },
637             0x1401 => { #2 (this doesn't seem to work for the X100 - PH)
638             Name => 'FilmMode',
639             Writable => 'int16u',
640             PrintHex => 1,
641             PrintConv => {
642             0x000 => 'F0/Standard (Provia)', # X-Pro2 "Provia/Standard"
643             0x100 => 'F1/Studio Portrait',
644             0x110 => 'F1a/Studio Portrait Enhanced Saturation',
645             0x120 => 'F1b/Studio Portrait Smooth Skin Tone (Astia)', # X-Pro2 "Astia/Soft"
646             0x130 => 'F1c/Studio Portrait Increased Sharpness',
647             0x200 => 'F2/Fujichrome (Velvia)', # X-Pro2 "Velvia/Vivid"
648             0x300 => 'F3/Studio Portrait Ex',
649             0x400 => 'F4/Velvia',
650             0x500 => 'Pro Neg. Std', #PH (X-Pro1)
651             0x501 => 'Pro Neg. Hi', #PH (X-Pro1)
652             0x600 => 'Classic Chrome', #forum6109
653             0x700 => 'Eterna', #12
654             0x800 => 'Classic Negative', #forum10536
655             0x900 => 'Bleach Bypass', #forum10890
656             0xa00 => 'Nostalgic Neg', #forum12085
657             },
658             },
659             0x1402 => { #2
660             Name => 'DynamicRangeSetting',
661             Writable => 'int16u',
662             PrintHex => 1,
663             PrintConv => {
664             0x000 => 'Auto',
665             0x001 => 'Manual', #(ref http://forum.photome.de/viewtopic.php?f=2&t=353)
666             0x100 => 'Standard (100%)',
667             0x200 => 'Wide1 (230%)',
668             0x201 => 'Wide2 (400%)',
669             0x8000 => 'Film Simulation',
670             },
671             },
672             0x1403 => { #2 (only valid for manual DR, ref 6)
673             Name => 'DevelopmentDynamicRange',
674             Writable => 'int16u',
675             # (shows 200, 400 or 800 for HDR200,HDR400,HDR800, ref forum10799)
676             },
677             0x1404 => { #2
678             Name => 'MinFocalLength',
679             Writable => 'rational64s',
680             },
681             0x1405 => { #2
682             Name => 'MaxFocalLength',
683             Writable => 'rational64s',
684             },
685             0x1406 => { #2
686             Name => 'MaxApertureAtMinFocal',
687             Writable => 'rational64s',
688             },
689             0x1407 => { #2
690             Name => 'MaxApertureAtMaxFocal',
691             Writable => 'rational64s',
692             },
693             # 0x1408 - values: '0100', 'S100', 'VQ10'
694             # 0x1409 - values: same as 0x1408
695             # 0x140a - values: 0, 1, 3, 5, 7 (bit 2=red-eye detection, ref 11/13)
696             0x140b => { #6
697             Name => 'AutoDynamicRange',
698             Writable => 'int16u',
699             PrintConv => '"$val%"',
700             PrintConvInv => '$val=~s/\s*\%$//; $val',
701             },
702             0x104e => { #forum10800 (X-Pro3)
703             Name => 'ColorChromeFXBlue',
704             Writable => 'int32s',
705             PrintConv => {
706             0 => 'Off',
707             32 => 'Weak', # (NC)
708             64 => 'Strong',
709             },
710             },
711             0x1422 => { #8
712             Name => 'ImageStabilization',
713             Writable => 'int16u',
714             Count => 3,
715             PrintConv => [{
716             0 => 'None',
717             1 => 'Optical', #PH
718             2 => 'Sensor-shift', #PH (now IBIS/OIS, ref forum13708)
719             3 => 'OIS Lens', #forum9815 (optical+sensor?)
720             258 => 'IBIS/OIS + DIS', #forum13708 (digital on top of IBIS/OIS)
721             512 => 'Digital', #PH
722             },{
723             0 => 'Off',
724             1 => 'On (mode 1, continuous)',
725             2 => 'On (mode 2, shooting only)',
726             }],
727             },
728             0x1425 => { # if present and 0x1031 PictureMode is zero, then PictureMode is SR+, not Auto (ref 11)
729             Name => 'SceneRecognition',
730             Writable => 'int16u',
731             PrintHex => 1,
732             PrintConv => {
733             0 => 'Unrecognized',
734             0x100 => 'Portrait Image',
735             0x103 => 'Night Portrait', #forum10651
736             0x105 => 'Backlit Portrait', #forum10651
737             0x200 => 'Landscape Image',
738             0x300 => 'Night Scene',
739             0x400 => 'Macro',
740             },
741             },
742             0x1431 => { #forum6109
743             Name => 'Rating',
744             Groups => { 2 => 'Image' },
745             Writable => 'int32u',
746             Priority => 0,
747             },
748             0x1436 => { #8
749             Name => 'ImageGeneration',
750             Writable => 'int16u',
751             PrintConv => {
752             0 => 'Original Image',
753             1 => 'Re-developed from RAW',
754             },
755             },
756             0x1438 => { #forum6579 (X-T1 firmware version 3)
757             Name => 'ImageCount',
758             Notes => 'may reset to 0 when new firmware is installed',
759             Writable => 'int16u',
760             ValueConv => '$val & 0x7fff',
761             ValueConvInv => '$val | 0x8000',
762             },
763             0x1443 => { #12 (X-T3)
764             Name => 'DRangePriority',
765             Writable => 'int16u',
766             PrintConv => { 0 => 'Auto', 1 => 'Fixed' },
767             },
768             0x1444 => { #12 (X-T3, only exists if DRangePriority is 'Auto')
769             Name => 'DRangePriorityAuto',
770             Writable => 'int16u',
771             PrintConv => {
772             1 => 'Weak',
773             2 => 'Strong',
774             3 => 'Plus', #forum10799
775             },
776             },
777             0x1445 => { #12 (X-T3, only exists if DRangePriority is 'Fixed')
778             Name => 'DRangePriorityFixed',
779             Writable => 'int16u',
780             PrintConv => { 1 => 'Weak', 2 => 'Strong' },
781             },
782             0x1446 => { #12
783             Name => 'FlickerReduction',
784             Writable => 'int32u',
785             # seen values: Off=0x0000, On=0x2100,0x3100
786             PrintConv => q{
787             my $on = ((($val >> 8) & 0x0f) == 1) ? 'On' : 'Off';
788             return sprintf('%s (0x%.4x)', $on, $val);
789             },
790             PrintConvInv => '$val=~/(0x[0-9a-f]+)/i; hex $1',
791             },
792             0x1447 => { Name => 'FujiModel', Writable => 'string' },
793             0x1448 => { Name => 'FujiModel2', Writable => 'string' },
794             0x3803 => { #forum10037
795             Name => 'VideoRecordingMode',
796             Groups => { 2 => 'Video' },
797             Writable => 'int32u',
798             PrintHex => 1,
799             PrintConv => {
800             0x00 => 'Normal',
801             0x10 => 'F-log',
802             0x20 => 'HLG',
803             },
804             },
805             0x3804 => { #forum10037
806             Name => 'PeripheralLighting',
807             Groups => { 2 => 'Video' },
808             Writable => 'int16u',
809             PrintConv => { 0 => 'Off', 1 => 'On' },
810             },
811             # 0x3805 - int16u: seen 1
812             0x3806 => { #forum10037
813             Name => 'VideoCompression',
814             Groups => { 2 => 'Video' },
815             Writable => 'int16u',
816             PrintConv => {
817             1 => 'Log GOP',
818             2 => 'All Intra',
819             },
820             },
821             # 0x3810 - int32u: related to video codec (ref forum10037)
822             0x3820 => { #PH (HS20EXR MOV)
823             Name => 'FrameRate',
824             Writable => 'int16u',
825             Groups => { 2 => 'Video' },
826             },
827             0x3821 => { #PH (HS20EXR MOV)
828             Name => 'FrameWidth',
829             Writable => 'int16u',
830             Groups => { 2 => 'Video' },
831             },
832             0x3822 => { #PH (HS20EXR MOV)
833             Name => 'FrameHeight',
834             Writable => 'int16u',
835             Groups => { 2 => 'Video' },
836             },
837             0x3824 => { #forum10480 (X series)
838             Name => 'FullHDHighSpeedRec',
839             Writable => 'int32u',
840             Groups => { 2 => 'Video' },
841             PrintConv => { 1 => 'Off', 2 => 'On' },
842             },
843             0x4005 => { #forum9634
844             Name => 'FaceElementSelected', # (could be face or eye)
845             Writable => 'int16u',
846             Count => 4,
847             },
848             0x4100 => { #PH
849             Name => 'FacesDetected',
850             Writable => 'int16u',
851             },
852             0x4103 => { #PH
853             Name => 'FacePositions',
854             Writable => 'int16u',
855             Count => -1,
856             Notes => q{
857             left, top, right and bottom coordinates in full-sized image for each face
858             detected
859             },
860             },
861             0x4200 => { #11
862             Name => 'NumFaceElements',
863             Writable => 'int16u',
864             },
865             0x4201 => { #11
866             Name => 'FaceElementTypes',
867             Writable => 'int8u',
868             Count => -1,
869             PrintConv => [{
870             1 => 'Face',
871             2 => 'Left Eye',
872             3 => 'Right Eye',
873             7 => 'Body',
874             8 => 'Head',
875             11 => 'Bike',
876             12 => 'Body of Car',
877             13 => 'Front of Car',
878             14 => 'Animal Body',
879             15 => 'Animal Head',
880             16 => 'Animal Face',
881             17 => 'Animal Left Eye',
882             18 => 'Animal Right Eye',
883             19 => 'Bird Body',
884             20 => 'Bird Head',
885             21 => 'Bird Left Eye',
886             22 => 'Bird Right Eye',
887             23 => 'Aircraft Body',
888             25 => 'Aircraft Cockpit',
889             26 => 'Train Front',
890             27 => 'Train Cockpit',
891             },'REPEAT'],
892             },
893             # 0x4202 int8u[-1] - number of cooredinates in each rectangle? (ref 11)
894             0x4203 => { #11
895             Name => 'FaceElementPositions',
896             Writable => 'int16u',
897             Count => -1,
898             Notes => q{
899             left, top, right and bottom coordinates in full-sized image for each face
900             element
901             },
902             },
903             # 0x4101-0x4105 - exist only if face detection active
904             # 0x4104 - also related to face detection (same number of entries as FacePositions)
905             # 0x4200 - same as 0x4100?
906             # 0x4203 - same as 0x4103
907             # 0x4204 - same as 0x4104
908             0x4282 => { #PH
909             Name => 'FaceRecInfo',
910             SubDirectory => { TagTable => 'Image::ExifTool::FujiFilm::FaceRecInfo' },
911             },
912             0x8000 => { #2
913             Name => 'FileSource',
914             Writable => 'string',
915             },
916             0x8002 => { #2
917             Name => 'OrderNumber',
918             Writable => 'int32u',
919             },
920             0x8003 => { #2
921             Name => 'FrameNumber',
922             Writable => 'int16u',
923             },
924             0xb211 => { #PH
925             Name => 'Parallax',
926             # (value set in camera is -0.5 times this value in MPImage2... why?)
927             Writable => 'rational64s',
928             Notes => 'only found in MPImage2 of .MPO images',
929             },
930             # 0xb212 - also found in MPIMage2 images - PH
931             );
932              
933             # Focus Priority settings, tag 0x102b (X-T3, ref forum 9607)
934             %Image::ExifTool::FujiFilm::PrioritySettings = (
935             PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
936             WRITE_PROC => \&Image::ExifTool::WriteBinaryData,
937             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
938             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
939             FORMAT => 'int16u',
940             WRITABLE => 1,
941             0.1 => {
942             Name => 'AF-SPriority',
943             Mask => 0x000f,
944             PrintConv => {
945             1 => 'Release',
946             2 => 'Focus',
947             },
948             },
949             0.2 => {
950             Name => 'AF-CPriority',
951             Mask => 0x00f0,
952             PrintConv => {
953             1 => 'Release',
954             2 => 'Focus',
955             },
956             },
957             );
958              
959             # Focus settings, tag 0x102d (X-T3, ref forum 9607)
960             %Image::ExifTool::FujiFilm::FocusSettings = (
961             PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
962             WRITE_PROC => \&Image::ExifTool::WriteBinaryData,
963             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
964             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
965             FORMAT => 'int32u',
966             WRITABLE => 1,
967             0.1 => {
968             Name => 'FocusMode2',
969             Mask => 0x0000000f,
970             PrintConv => {
971             0x0 => 'AF-M',
972             0x1 => 'AF-S',
973             0x2 => 'AF-C',
974             },
975             },
976             0.2 => {
977             Name => 'PreAF',
978             Mask => 0x00f0,
979             PrintConv => {
980             0 => 'Off',
981             1 => 'On',
982             },
983             },
984             0.3 => {
985             Name => 'AFAreaMode',
986             Mask => 0x0f00,
987             PrintConv => {
988             0 => 'Single Point',
989             1 => 'Zone',
990             2 => 'Wide/Tracking',
991             },
992             },
993             0.4 => {
994             Name => 'AFAreaPointSize',
995             Mask => 0xf000,
996             PrintConv => {
997             0 => 'n/a',
998             OTHER => sub { return $_[0] },
999             },
1000             },
1001             0.5 => {
1002             Name => 'AFAreaZoneSize',
1003             Mask => 0xf0000,
1004             PrintConv => {
1005             0 => 'n/a',
1006             OTHER => sub {
1007             my ($val, $inv) = @_;
1008             return "$val x $val" unless $inv;
1009             $val =~ s/ ?x.*//;
1010             return $val;
1011             },
1012             },
1013             },
1014             );
1015              
1016             # AF-C settings, tag 0x102e (ref forum 9607)
1017             %Image::ExifTool::FujiFilm::AFCSettings = (
1018             PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
1019             WRITE_PROC => \&Image::ExifTool::WriteBinaryData,
1020             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
1021             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
1022             FORMAT => 'int32u',
1023             WRITABLE => 1,
1024             0 => {
1025             Name => 'AF-CSetting',
1026             PrintHex => 3,
1027             PrintSort => 1, # sort PrintConv by value
1028             # decode in-camera preset values (X-T3)
1029             PrintConv => {
1030             0x102 => 'Set 1 (multi-purpose)', # (2,0,Auto)
1031             0x203 => 'Set 2 (ignore obstacles)', # (3,0,Center)
1032             0x122 => 'Set 3 (accelerating subject)', # (2,2,Auto)
1033             0x010 => 'Set 4 (suddenly appearing subject)', # (0,1,Front)
1034             0x123 => 'Set 5 (erratic motion)', # (3,2,Auto)
1035             OTHER => sub {
1036             my ($val, $inv) = @_;
1037             return $val =~ /(0x\w+)/ ? hex $1 : undef if $inv;
1038             return sprintf 'Set 6 (custom 0x%.3x)', $val;
1039             },
1040             },
1041             },
1042             0.1 => {
1043             Name => 'AF-CTrackingSensitivity',
1044             Mask => 0x000f, # (values 0-4)
1045             },
1046             0.2 => {
1047             Name => 'AF-CSpeedTrackingSensitivity',
1048             Mask => 0x00f0,
1049             # (values 0-2)
1050             },
1051             0.3 => {
1052             Name => 'AF-CZoneAreaSwitching',
1053             Mask => 0x0f00,
1054             PrintConv => {
1055             0 => 'Front',
1056             1 => 'Auto',
1057             2 => 'Center',
1058             },
1059             },
1060             );
1061              
1062             # DriveMode settings, tag 0x1103 (X-T3, ref forum 9607)
1063             %Image::ExifTool::FujiFilm::DriveSettings = (
1064             PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
1065             WRITE_PROC => \&Image::ExifTool::WriteBinaryData,
1066             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
1067             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
1068             FORMAT => 'int32u',
1069             WRITABLE => 1,
1070             0.1 => {
1071             Name => 'DriveMode',
1072             Mask => 0x000000ff,
1073             PrintConv => {
1074             0 => 'Single',
1075             1 => 'Continuous Low', # not used by X-H2S? (see forum13777)
1076             2 => 'Continuous High',
1077             },
1078             },
1079             0.2 => {
1080             Name => 'DriveSpeed',
1081             Mask => 0xff000000,
1082             PrintConv => {
1083             0 => 'n/a',
1084             OTHER => sub {
1085             my ($val, $inv) = @_;
1086             return "$val fps" unless $inv;
1087             $val =~ s/ ?fps$//;
1088             return $val;
1089             },
1090             },
1091             },
1092             );
1093              
1094             # Face recognition information from FinePix F550EXR (ref PH)
1095             %Image::ExifTool::FujiFilm::FaceRecInfo = (
1096             PROCESS_PROC => \&ProcessFaceRec,
1097             GROUPS => { 0 => 'MakerNotes', 2 => 'Image' },
1098             VARS => { NO_ID => 1 },
1099             NOTES => 'Face recognition information.',
1100             Face1Name => { },
1101             Face2Name => { },
1102             Face3Name => { },
1103             Face4Name => { },
1104             Face5Name => { },
1105             Face6Name => { },
1106             Face7Name => { },
1107             Face8Name => { },
1108             Face1Category => { %faceCategories },
1109             Face2Category => { %faceCategories },
1110             Face3Category => { %faceCategories },
1111             Face4Category => { %faceCategories },
1112             Face5Category => { %faceCategories },
1113             Face6Category => { %faceCategories },
1114             Face7Category => { %faceCategories },
1115             Face8Category => { %faceCategories },
1116             Face1Birthday => { },
1117             Face2Birthday => { },
1118             Face3Birthday => { },
1119             Face4Birthday => { },
1120             Face5Birthday => { },
1121             Face6Birthday => { },
1122             Face7Birthday => { },
1123             Face8Birthday => { },
1124             );
1125              
1126             # tags in RAF images (ref 5)
1127             %Image::ExifTool::FujiFilm::RAF = (
1128             PROCESS_PROC => \&ProcessFujiDir,
1129             GROUPS => { 0 => 'RAF', 1 => 'RAF', 2 => 'Image' },
1130             PRIORITY => 0, # so the first RAF directory takes precedence
1131             NOTES => q{
1132             FujiFilm RAF images contain meta information stored in a proprietary
1133             FujiFilm RAF format, as well as EXIF information stored inside an embedded
1134             JPEG preview image. The table below lists tags currently decoded from the
1135             RAF-format information.
1136             },
1137             0x100 => {
1138             Name => 'RawImageFullSize',
1139             Format => 'int16u',
1140             Groups => { 1 => 'RAF2' }, # (so RAF2 shows up in family 1 list)
1141             Count => 2,
1142             Notes => 'including borders',
1143             ValueConv => 'my @v=reverse split(" ",$val);"@v"', # reverse to show width first
1144             PrintConv => '$val=~tr/ /x/; $val',
1145             },
1146             0x110 => {
1147             Name => 'RawImageCropTopLeft',
1148             Format => 'int16u',
1149             Count => 2,
1150             Notes => 'top margin first, then left margin',
1151             },
1152             0x111 => {
1153             Name => 'RawImageCroppedSize',
1154             Format => 'int16u',
1155             Count => 2,
1156             Notes => 'including borders',
1157             ValueConv => 'my @v=reverse split(" ",$val);"@v"', # reverse to show width first
1158             PrintConv => '$val=~tr/ /x/; $val',
1159             },
1160             0x115 => {
1161             Name => 'RawImageAspectRatio',
1162             Format => 'int16u',
1163             Count => 2,
1164             ValueConv => 'my @v=reverse split(" ",$val);"@v"', # reverse to show width first
1165             PrintConv => '$val=~tr/ /:/; $val',
1166             },
1167             0x121 => [
1168             {
1169             Name => 'RawImageSize',
1170             Condition => '$$self{Model} eq "FinePixS2Pro"',
1171             Format => 'int16u',
1172             Count => 2,
1173             ValueConv => q{
1174             my @v=split(" ",$val);
1175             $v[0]*=2, $v[1]/=2;
1176             return "@v";
1177             },
1178             PrintConv => '$val=~tr/ /x/; $val',
1179             },
1180             {
1181             Name => 'RawImageSize',
1182             Format => 'int16u',
1183             Count => 2,
1184             # values are height then width, adjusted for the layout
1185             ValueConv => q{
1186             my @v=reverse split(" ",$val);
1187             $$self{FujiLayout} and $v[0]/=2, $v[1]*=2;
1188             return "@v";
1189             },
1190             PrintConv => '$val=~tr/ /x/; $val',
1191             },
1192             ],
1193             0x130 => {
1194             Name => 'FujiLayout',
1195             Format => 'int8u',
1196             RawConv => q{
1197             my ($v) = split ' ', $val;
1198             $$self{FujiLayout} = $v & 0x80 ? 1 : 0;
1199             return $val;
1200             },
1201             },
1202             0x131 => { #5
1203             Name => 'XTransLayout',
1204             Description => 'X-Trans Layout',
1205             Format => 'int8u',
1206             Count => 36,
1207             PrintConv => '$val =~ tr/012 /RGB/d; join " ", $val =~ /....../g',
1208             },
1209             0x2000 => { #IB
1210             Name => 'WB_GRGBLevelsAuto',
1211             Format => 'int16u',
1212             Count => 4, # (ignore the duplicate values)
1213             },
1214             0x2100 => { #IB
1215             Name => 'WB_GRGBLevelsDaylight',
1216             Format => 'int16u',
1217             Count => 4,
1218             },
1219             0x2200 => { #IB
1220             Name => 'WB_GRGBLevelsCloudy',
1221             Format => 'int16u',
1222             Count => 4,
1223             },
1224             0x2300 => { #IB
1225             Name => 'WB_GRGBLevelsDaylightFluor',
1226             Format => 'int16u',
1227             Count => 4,
1228             },
1229             0x2301 => { #IB
1230             Name => 'WB_GRGBLevelsDayWhiteFluor',
1231             Format => 'int16u',
1232             Count => 4,
1233             },
1234             0x2302 => { #IB
1235             Name => 'WB_GRGBLevelsWhiteFluorescent',
1236             Format => 'int16u',
1237             Count => 4,
1238             },
1239             0x2310 => { #IB
1240             Name => 'WB_GRGBLevelsWarmWhiteFluor',
1241             Format => 'int16u',
1242             Count => 4,
1243             },
1244             0x2311 => { #IB
1245             Name => 'WB_GRGBLevelsLivingRoomWarmWhiteFluor',
1246             Format => 'int16u',
1247             Count => 4,
1248             },
1249             0x2400 => { #IB
1250             Name => 'WB_GRGBLevelsTungsten',
1251             Format => 'int16u',
1252             Count => 4,
1253             },
1254             # 0x2f00 => WB_GRGBLevelsCustom: int32u count, then count * (int16u GRGBGRGB), ref IB
1255             0x2ff0 => {
1256             Name => 'WB_GRGBLevels',
1257             Format => 'int16u',
1258             Count => 4,
1259             },
1260             0x9200 => { #Frank Markesteijn
1261             Name => 'RelativeExposure',
1262             Format => 'rational32s',
1263             ValueConv => 'log($val) / log(2)',
1264             ValueConvInv => 'exp($val * log(2))',
1265             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
1266             PrintConvInv => '$val',
1267             },
1268             # 0x9200 - relative exposure? (ref Frank Markesteijn)
1269             0x9650 => { #Frank Markesteijn
1270             Name => 'RawExposureBias',
1271             Format => 'rational32s',
1272             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
1273             PrintConvInv => '$val',
1274             },
1275             0xc000 => {
1276             Name => 'RAFData',
1277             SubDirectory => {
1278             TagTable => 'Image::ExifTool::FujiFilm::RAFData',
1279             ByteOrder => 'Little-endian',
1280             }
1281             },
1282             );
1283              
1284             %Image::ExifTool::FujiFilm::RAFData = (
1285             PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
1286             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
1287             DATAMEMBER => [ 0, 4, 8 ],
1288             FIRST_ENTRY => 0,
1289             # (FujiFilm image dimensions are REALLY confusing)
1290             # --> this needs some cleaning up
1291             # [Note to self: See email from Iliah Borg for more information about WB settings in this data]
1292             0 => {
1293             Name => 'RawImageWidth',
1294             Format => 'int32u',
1295             DataMember => 'FujiWidth',
1296             RawConv => '$val < 10000 ? $$self{FujiWidth} = $val : undef', #5
1297             ValueConv => '$$self{FujiLayout} ? ($val / 2) : $val',
1298             },
1299             4 => [
1300             {
1301             Name => 'RawImageWidth',
1302             Condition => 'not $$self{FujiWidth}',
1303             Format => 'int32u',
1304             DataMember => 'FujiWidth',
1305             RawConv => '$val < 10000 ? $$self{FujiWidth} = $val : undef', #PH
1306             ValueConv => '$$self{FujiLayout} ? ($val / 2) : $val',
1307             },
1308             {
1309             Name => 'RawImageHeight',
1310             Format => 'int32u',
1311             DataMember => 'FujiHeight',
1312             RawConv => '$$self{FujiHeight} = $val',
1313             ValueConv => '$$self{FujiLayout} ? ($val * 2) : $val',
1314             },
1315             ],
1316             8 => [
1317             {
1318             Name => 'RawImageWidth',
1319             Condition => 'not $$self{FujiWidth}',
1320             Format => 'int32u',
1321             DataMember => 'FujiWidth',
1322             RawConv => '$val < 10000 ? $$self{FujiWidth} = $val : undef', #PH
1323             ValueConv => '$$self{FujiLayout} ? ($val / 2) : $val',
1324             },
1325             {
1326             Name => 'RawImageHeight',
1327             Condition => 'not $$self{FujiHeight}',
1328             Format => 'int32u',
1329             DataMember => 'FujiHeight',
1330             RawConv => '$$self{FujiHeight} = $val',
1331             ValueConv => '$$self{FujiLayout} ? ($val * 2) : $val',
1332             },
1333             ],
1334             12 => {
1335             Name => 'RawImageHeight',
1336             Condition => 'not $$self{FujiHeight}',
1337             Format => 'int32u',
1338             ValueConv => '$$self{FujiLayout} ? ($val * 2) : $val',
1339             },
1340             );
1341              
1342             # TIFF IFD-format information stored in FujiFilm RAF images (ref 5)
1343             %Image::ExifTool::FujiFilm::IFD = (
1344             PROCESS_PROC => \&Image::ExifTool::Exif::ProcessExif,
1345             GROUPS => { 0 => 'RAF', 1 => 'FujiIFD', 2 => 'Image' },
1346             NOTES => 'Tags found in the FujiIFD information of RAF images from some models.',
1347             0xf000 => {
1348             Name => 'FujiIFD',
1349             Groups => { 1 => 'FujiIFD' },
1350             Flags => 'SubIFD',
1351             SubDirectory => {
1352             TagTable => 'Image::ExifTool::FujiFilm::IFD',
1353             DirName => 'FujiSubIFD',
1354             Start => '$val',
1355             },
1356             },
1357             0xf001 => 'RawImageFullWidth',
1358             0xf002 => 'RawImageFullHeight',
1359             0xf003 => 'BitsPerSample',
1360             # 0xf004 - values: 4
1361             # 0xf005 - values: 1374, 1668
1362             # 0xf006 - some sort of flag indicating packed format?
1363             0xf007 => {
1364             Name => 'StripOffsets',
1365             IsOffset => 1,
1366             OffsetPair => 0xf008, # point to associated byte counts
1367             },
1368             0xf008 => {
1369             Name => 'StripByteCounts',
1370             OffsetPair => 0xf007, # point to associated offsets
1371             },
1372             # 0xf009 - values: 0, 3
1373             0xf00a => 'BlackLevel', #IB
1374             0xf00b => 'GeometricDistortionParams', #9 (rational64s[23, 35 or 43])
1375             0xf00c => 'WB_GRBLevelsStandard', #IB (GRBXGRBX; X=17 is standard illuminant A, X=21 is D65)
1376             0xf00d => 'WB_GRBLevelsAuto', #IB
1377             0xf00e => 'WB_GRBLevels',
1378             0xf00f => 'ChromaticAberrationParams', # (rational64s[23])
1379             0xf010 => 'VignettingParams', #9 (rational64s[31 or 64])
1380             );
1381              
1382             # information found in FFMV atom of MOV videos
1383             %Image::ExifTool::FujiFilm::FFMV = (
1384             PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
1385             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
1386             FIRST_ENTRY => 0,
1387             NOTES => 'Information found in the FFMV atom of MOV videos.',
1388             0 => {
1389             Name => 'MovieStreamName',
1390             Format => 'string[34]',
1391             },
1392             );
1393              
1394             # tags in FujiFilm QuickTime videos (ref PH)
1395             # (similar information in Kodak,Minolta,Nikon,Olympus,Pentax and Sanyo videos)
1396             %Image::ExifTool::FujiFilm::MOV = (
1397             PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
1398             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
1399             FIRST_ENTRY => 0,
1400             NOTES => 'This information is found in MOV videos from some FujiFilm cameras.',
1401             0x00 => {
1402             Name => 'Make',
1403             Format => 'string[24]',
1404             },
1405             0x18 => {
1406             Name => 'Model',
1407             Description => 'Camera Model Name',
1408             Format => 'string[16]',
1409             },
1410             0x2e => { # (NC)
1411             Name => 'ExposureTime',
1412             Format => 'int32u',
1413             ValueConv => '$val ? 1 / $val : 0',
1414             PrintConv => 'Image::ExifTool::Exif::PrintExposureTime($val)',
1415             },
1416             0x32 => {
1417             Name => 'FNumber',
1418             Format => 'rational64u',
1419             PrintConv => 'sprintf("%.1f",$val)',
1420             },
1421             0x3a => { # (NC)
1422             Name => 'ExposureCompensation',
1423             Format => 'rational64s',
1424             PrintConv => '$val ? sprintf("%+.1f", $val) : 0',
1425             },
1426             );
1427              
1428             #------------------------------------------------------------------------------
1429             # decode information from FujiFilm face recognition information
1430             # Inputs: 0) ExifTool object reference, 1) dirInfo reference, 2) tag table ref
1431             # Returns: 1
1432             sub ProcessFaceRec($$$)
1433             {
1434 0     0 0 0 my ($et, $dirInfo, $tagTablePtr) = @_;
1435 0         0 my $dataPt = $$dirInfo{DataPt};
1436 0   0     0 my $dataPos = $$dirInfo{DataPos} + ($$dirInfo{Base} || 0);
1437 0         0 my $dirStart = $$dirInfo{DirStart};
1438 0         0 my $dirLen = $$dirInfo{DirLen};
1439 0         0 my $pos = $dirStart;
1440 0         0 my $end = $dirStart + $dirLen;
1441 0         0 my ($i, $n, $p, $val);
1442 0         0 $et->VerboseDir('FaceRecInfo');
1443 0         0 for ($i=1; ; ++$i) {
1444 0 0       0 last if $pos + 8 > $end;
1445 0         0 my $off = Get32u($dataPt, $pos) + $dirStart;
1446 0         0 my $len = Get32u($dataPt, $pos + 4);
1447 0 0 0     0 last if $len==0 or $off>$end or $off+$len>$end or $len < 62;
      0        
      0        
1448             # values observed for each offset (always zero if not listed):
1449             # 0=5; 3=1; 4=4; 6=1; 10-13=numbers(constant for a given registered face)
1450             # 15=16; 16=3; 18=1; 22=nameLen; 26=1; 27=16; 28=7; 30-33=nameLen(int32u)
1451             # 34-37=nameOffset(int32u); 38=32; 39=16; 40=4; 42=1; 46=0,2,4,8(category)
1452             # 50=33; 51=16; 52=7; 54-57=dateLen(int32u); 58-61=dateOffset(int32u)
1453 0         0 $n = Get32u($dataPt, $off + 30);
1454 0         0 $p = Get32u($dataPt, $off + 34) + $dirStart;
1455 0 0 0     0 last if $p < $dirStart or $p + $n > $end;
1456 0         0 $val = substr($$dataPt, $p, $n);
1457 0         0 $et->HandleTag($tagTablePtr, "Face${i}Name", $val,
1458             DataPt => $dataPt,
1459             DataPos => $dataPos,
1460             Start => $p,
1461             Size => $n,
1462             );
1463 0         0 $n = Get32u($dataPt, $off + 54);
1464 0         0 $p = Get32u($dataPt, $off + 58) + $dirStart;
1465 0 0 0     0 last if $p < $dirStart or $p + $n > $end;
1466 0         0 $val = substr($$dataPt, $p, $n);
1467 0         0 $val =~ s/(\d{4})(\d{2})(\d{2})/$1:$2:$2/;
1468 0         0 $et->HandleTag($tagTablePtr, "Face${i}Birthday", $val,
1469             DataPt => $dataPt,
1470             DataPos => $dataPos,
1471             Start => $p,
1472             Size => $n,
1473             );
1474 0         0 $et->HandleTag($tagTablePtr, "Face${i}Category", undef,
1475             DataPt => $dataPt,
1476             DataPos => $dataPos,
1477             Start => $off + 46,
1478             Size => 1,
1479             );
1480 0         0 $pos += 8;
1481             }
1482 0         0 return 1;
1483             }
1484              
1485             #------------------------------------------------------------------------------
1486             # get information from FujiFilm RAF directory
1487             # Inputs: 0) ExifTool object reference, 1) dirInfo reference, 2) tag table ref
1488             # Returns: 1 if this was a valid FujiFilm directory
1489             sub ProcessFujiDir($$$)
1490             {
1491 6     6 0 18 my ($et, $dirInfo, $tagTablePtr) = @_;
1492 6         15 my $raf = $$dirInfo{RAF};
1493 6         14 my $offset = $$dirInfo{DirStart};
1494 6 50       26 $raf->Seek($offset, 0) or return 0;
1495 6         37 my ($buff, $index);
1496 6 50       27 $raf->Read($buff, 4) or return 0;
1497 6         38 my $entries = unpack 'N', $buff;
1498 6 50       21 $entries < 256 or return 0;
1499 6 50       31 $et->Options('Verbose') and $et->VerboseDir('Fuji', $entries);
1500 6         28 SetByteOrder('MM');
1501 6         27 my $pos = $offset + 4;
1502 6         31 for ($index=0; $index<$entries; ++$index) {
1503 792 50       2048 $raf->Read($buff,4) or return 0;
1504 792         1171 $pos += 4;
1505 792         1885 my ($tag, $len) = unpack 'nn', $buff;
1506 792         1271 my ($val, $vbuf);
1507 792 50       1710 $raf->Read($vbuf, $len) or return 0;
1508 792         1854 my $tagInfo = $et->GetTagInfo($tagTablePtr, $tag);
1509 792 100 66     2198 if ($tagInfo and $$tagInfo{Format}) {
    100          
1510 102         324 $val = ReadValue(\$vbuf, 0, $$tagInfo{Format}, $$tagInfo{Count}, $len);
1511 102 50       249 next unless defined $val;
1512             } elsif ($len == 4) {
1513             # interpret unknown 4-byte values as int32u
1514 234         545 $val = Get32u(\$vbuf, 0);
1515             } else {
1516             # treat other unknown values as binary data
1517 456         794 $val = \$vbuf;
1518             }
1519 792         2307 $et->HandleTag($tagTablePtr, $tag, $val,
1520             Index => $index,
1521             DataPt => \$vbuf,
1522             DataPos => $pos,
1523             Size => $len,
1524             TagInfo => $tagInfo,
1525             );
1526 792         1926 $pos += $len;
1527             }
1528 6         24 return 1;
1529             }
1530              
1531             #------------------------------------------------------------------------------
1532             # write information to FujiFilm RAW file (RAF)
1533             # Inputs: 0) ExifTool object reference, 1) dirInfo reference
1534             # Returns: 1 on success, 0 if this wasn't a valid RAF file, or -1 on write error
1535             sub WriteRAF($$)
1536             {
1537 2     2 0 9 my ($et, $dirInfo) = @_;
1538 2         8 my $raf = $$dirInfo{RAF};
1539 2         6 my ($hdr, $jpeg, $outJpeg, $offset, $err, $buff);
1540              
1541 2 50       9 $raf->Read($hdr,0x94) == 0x94 or return 0;
1542 2 50       15 $hdr =~ /^FUJIFILM/ or return 0;
1543 2         21 my $ver = substr($hdr, 0x3c, 4);
1544 2 0 33     16 $ver =~ /^\d{4}$/ or $testedRAF{$ver} or return 0;
1545              
1546             # get the position and size of embedded JPEG
1547 2         15 my ($jpos, $jlen) = unpack('x84NN', $hdr);
1548             # check to be sure the JPEG starts in the expected location
1549 2 50 33     22 if ($jpos > 0x94 or $jpos < 0x68 or $jpos & 0x03) {
      33        
1550 0         0 $et->Error("Unsupported or corrupted RAF image (version $ver)");
1551 0         0 return 1;
1552             }
1553             # check to make sure this version of RAF has been tested
1554             #(removed in ExifTool 11.70)
1555             #unless ($testedRAF{$ver}) {
1556             # $et->Warn("RAF version $ver not yet tested", 1);
1557             #}
1558             # read the embedded JPEG
1559 2 50 33     22 unless ($raf->Seek($jpos, 0) and $raf->Read($jpeg, $jlen) == $jlen) {
1560 0         0 $et->Error('Error reading RAF meta information');
1561 0         0 return 1;
1562             }
1563             # use same write directories as JPEG
1564 2         14 $et->InitWriteDirs('JPEG');
1565             # rewrite the embedded JPEG in memory
1566 2         15 my %jpegInfo = (
1567             Parent => 'RAF',
1568             RAF => new File::RandomAccess(\$jpeg),
1569             OutFile => \$outJpeg,
1570             );
1571 2         8 $$et{FILE_TYPE} = 'JPEG';
1572 2         13 my $success = $et->WriteJPEG(\%jpegInfo);
1573 2         8 $$et{FILE_TYPE} = 'RAF';
1574 2 50 33     13 unless ($success and $outJpeg) {
1575 0         0 $et->Error("Invalid RAF format");
1576 0         0 return 1;
1577             }
1578 2 50       10 return -1 if $success < 0;
1579              
1580             # rewrite the RAF image
1581 2         9 SetByteOrder('MM');
1582 2         11 my $jpegLen = length $outJpeg;
1583             # pad JPEG to an even 4 bytes (ALWAYS use padding as Fuji does)
1584 2         9 my $pad = "\0" x (4 - ($jpegLen % 4));
1585             # update JPEG size in header (size without padding)
1586 2         11 Set32u(length($outJpeg), \$hdr, 0x58);
1587             # get pointer to start of the next RAF block
1588 2         11 my $nextPtr = Get32u(\$hdr, 0x5c);
1589             # determine the length of padding at the end of the original JPEG
1590 2         13 my $oldPadLen = $nextPtr - ($jpos + $jlen);
1591 2 50       9 if ($oldPadLen) {
1592 2 50 33     22 if ($oldPadLen > 1000000 or $oldPadLen < 0 or
      33        
      33        
1593             not $raf->Seek($jpos+$jlen, 0) or
1594             $raf->Read($buff, $oldPadLen) != $oldPadLen)
1595             {
1596 0         0 $et->Error('Bad RAF pointer at 0x5c');
1597 0         0 return 1;
1598             }
1599             # make sure padding is only zero bytes (can be >100k for HS10)
1600             # (have seen non-null padding in X-Pro1)
1601 2 50       15 if ($buff =~ /[^\0]/) {
1602 0 0       0 return 1 if $et->Error('Non-null bytes found in padding', 2);
1603             }
1604             }
1605             # calculate offset difference due to change in JPEG size
1606 2         10 my $ptrDiff = length($outJpeg) + length($pad) - ($jlen + $oldPadLen);
1607             # update necessary pointers in header
1608 2         10 foreach $offset (0x5c, 0x64, 0x78, 0x80) {
1609 8 50       20 last if $offset >= $jpos; # some versions have a short header
1610 8         22 my $oldPtr = Get32u(\$hdr, $offset);
1611 8 50       21 next unless $oldPtr; # don't update if pointer is zero
1612 8         20 Set32u($oldPtr + $ptrDiff, \$hdr, $offset);
1613             }
1614             # write the new header
1615 2         12 my $outfile = $$dirInfo{OutFile};
1616 2 50       12 Write($outfile, substr($hdr, 0, $jpos)) or $err = 1;
1617             # write the updated JPEG plus padding
1618 2 50       14 Write($outfile, $outJpeg, $pad) or $err = 1;
1619             # copy over the rest of the RAF image
1620 2 50       14 unless ($raf->Seek($nextPtr, 0)) {
1621 0         0 $et->Error('Error reading RAF image');
1622 0         0 return 1;
1623             }
1624 2         12 while ($raf->Read($buff, 65536)) {
1625 2 50       19 Write($outfile, $buff) or $err = 1, last;
1626             }
1627 2 50       24 return $err ? -1 : 1;
1628             }
1629              
1630             #------------------------------------------------------------------------------
1631             # get information from FujiFilm RAW file (RAF)
1632             # Inputs: 0) ExifTool object reference, 1) dirInfo reference
1633             # Returns: 1 if this was a valid RAF file
1634             sub ProcessRAF($$)
1635             {
1636 3     3 0 11 my ($et, $dirInfo) = @_;
1637 3         8 my ($buff, $jpeg, $warn, $offset);
1638              
1639 3         11 my $raf = $$dirInfo{RAF};
1640 3 50       13 $raf->Read($buff,0x5c) == 0x5c or return 0;
1641 3 50       22 $buff =~ /^FUJIFILM/ or return 0;
1642 3         18 my ($jpos, $jlen) = unpack('x84NN', $buff);
1643 3 50       16 $jpos & 0x8000 and return 0;
1644 3 50       15 $raf->Seek($jpos, 0) or return 0;
1645 3 50       16 $raf->Read($jpeg, $jlen) == $jlen or return 0;
1646              
1647 3         24 $et->SetFileType();
1648 3         25 $et->FoundTag('RAFVersion', substr($buff, 0x3c, 4));
1649              
1650             # extract information from embedded JPEG
1651 3         19 my %dirInfo = (
1652             Parent => 'RAF',
1653             RAF => new File::RandomAccess(\$jpeg),
1654             );
1655 3         10 $$et{BASE} += $jpos;
1656 3         23 my $rtnVal = $et->ProcessJPEG(\%dirInfo);
1657 3         24 $$et{BASE} -= $jpos;
1658 3 50       27 $et->FoundTag('PreviewImage', \$jpeg) if $rtnVal;
1659              
1660             # extract information from Fuji RAF and TIFF directories
1661 3         20 my ($rafNum, $ifdNum) = ('','');
1662 3         17 foreach $offset (0x5c, 0x64, 0x78, 0x80) {
1663 12 50       39 last if $offset >= $jpos;
1664 12 50 33     62 unless ($raf->Seek($offset, 0) and $raf->Read($buff, 4)) {
1665 0         0 $warn = 1;
1666 0         0 last;
1667             }
1668 12         61 my $start = unpack('N',$buff);
1669 12 50       35 next unless $start;
1670 12 100 100     56 if ($offset == 0x64 or $offset == 0x80) {
1671             # parse FujiIFD directory
1672 6         35 %dirInfo = (
1673             RAF => $raf,
1674             Base => $start,
1675             );
1676 6         24 $$et{SET_GROUP1} = "FujiIFD$ifdNum";
1677 6         23 my $tagTablePtr = GetTagTable('Image::ExifTool::FujiFilm::IFD');
1678             # this is TIFF-format data only for some models, so no warning if it fails
1679 6         43 $et->ProcessTIFF(\%dirInfo, $tagTablePtr, \&Image::ExifTool::ProcessTIFF);
1680 6         12 delete $$et{SET_GROUP1};
1681 6   100     40 $ifdNum = ($ifdNum || 1) + 1;
1682             } else {
1683             # parse RAF directory
1684 6         42 %dirInfo = (
1685             RAF => $raf,
1686             DirStart => $start,
1687             );
1688 6         28 $$et{SET_GROUP1} = "RAF$rafNum";
1689 6         43 my $tagTablePtr = GetTagTable('Image::ExifTool::FujiFilm::RAF');
1690 6 50       30 $et->ProcessDirectory(\%dirInfo, $tagTablePtr) or $warn = 1;
1691 6         30 delete $$et{SET_GROUP1};
1692 6   100     45 $rafNum = ($rafNum || 1) + 1;
1693             }
1694             }
1695 3 50       17 $warn and $et->Warn('Possibly corrupt RAF information');
1696              
1697 3         14 return $rtnVal;
1698             }
1699              
1700             1; # end
1701              
1702             __END__