~berthold-daum/zora/trunk

« back to all changes in this revision

Viewing changes to com.bdaum.zoom.batch.unix/exiftool/lib/Image/ExifTool/Nikon.pm

  • Committer: bdaum
  • Date: 2015-12-26 10:21:51 UTC
  • Revision ID: berthold.daum@bdaum.de-20151226102151-44f1j5113167thb9
VersionĀ 2.4.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
58
58
use Image::ExifTool qw(:DataAccess :Utils);
59
59
use Image::ExifTool::Exif;
60
60
 
61
 
$VERSION = '3.06';
 
61
$VERSION = '3.12';
62
62
 
63
63
sub LensIDConv($$$);
64
64
sub ProcessNikonAVI($$$);
126
126
    '23 30 BE CA 3C 48 17 00' => 'Zoom-Nikkor 1200-1700mm f/5.6-8 P ED IF',
127
127
    '24 48 60 80 24 24 1A 02' => 'AF Zoom-Nikkor 80-200mm f/2.8D ED',
128
128
    '25 48 44 5C 24 24 1B 02' => 'AF Zoom-Nikkor 35-70mm f/2.8D',
 
129
    '25 48 44 5C 24 24 3A 02' => 'AF Zoom-Nikkor 35-70mm f/2.8D',
129
130
    '25 48 44 5C 24 24 52 02' => 'AF Zoom-Nikkor 35-70mm f/2.8D',
130
131
    '26 40 3C 5C 2C 34 1C 02' => 'AF Zoom-Nikkor 28-70mm f/3.5-4.5D',
131
132
    '27 48 8E 8E 24 24 1D 02' => 'AF-I Nikkor 300mm f/2.8D IF-ED',
189
190
    '4E 48 72 72 18 18 51 02' => 'AF DC-Nikkor 135mm f/2D',
190
191
    '4F 40 37 5C 2C 3C 53 06' => 'IX-Nikkor 24-70mm f/3.5-5.6',
191
192
    '50 48 56 7C 30 3C 54 06' => 'IX-Nikkor 60-180mm f/4-5.6',
 
193
    '52 54 44 44 18 18 00 00' => 'Zeiss Milvus 35mm f/2', #33
192
194
    '53 48 60 80 24 24 57 02' => 'AF Zoom-Nikkor 80-200mm f/2.8D ED',
193
195
    '53 48 60 80 24 24 60 02' => 'AF Zoom-Nikkor 80-200mm f/2.8D ED',
194
196
    '54 44 5C 7C 34 3C 58 02' => 'AF Zoom-Micro Nikkor 70-180mm f/4.5-5.6D ED',
195
197
    '54 44 5C 7C 34 3C 61 02' => 'AF Zoom-Micro Nikkor 70-180mm f/4.5-5.6D ED',
 
198
    '54 54 50 50 18 18 00 00' => 'Zeiss Milvus 50mm f/2 Makro', #33
196
199
    '56 48 5C 8E 30 3C 5A 02' => 'AF Zoom-Nikkor 70-300mm f/4-5.6D ED',
 
200
    '56 54 68 68 18 18 00 00' => 'Zeiss Milvus 100mm f/2 Makro', #33
197
201
    '59 48 98 98 24 24 5D 02' => 'AF-S Nikkor 400mm f/2.8D IF-ED',
198
202
    '59 48 98 98 24 24 F1 02' => 'AF-S Nikkor 400mm f/2.8D IF-ED + TC-14E',
199
203
    '59 48 98 98 24 24 E1 02' => 'AF-S Nikkor 400mm f/2.8D IF-ED + TC-17E',
274
278
    'A5 40 3C 8E 2C 3C A7 0E' => 'AF-S Nikkor 28-300mm f/3.5-5.6G ED VR',
275
279
    'A6 48 8E 8E 24 24 A8 0E' => 'AF-S VR Nikkor 300mm f/2.8G IF-ED II',
276
280
    'A7 4B 62 62 2C 2C A9 0E' => 'AF-S DX Micro Nikkor 85mm f/3.5G ED VR',
277
 
    'A7 3C 53 80 30 3C C2 0E' => 'AF-S DX Nikkor 55-200mm f/4-5.6G ED VR II', #33
278
281
    'A8 48 80 98 30 30 AA 0E' => 'AF-S VR Zoom-Nikkor 200-400mm f/4G IF-ED II', #http://u88.n24.queensu.ca/exiftool/forum/index.php/topic,3218.msg15495.html#msg15495
279
282
    'A9 54 80 80 18 18 AB 0E' => 'AF-S Nikkor 200mm f/2G ED VR II',
280
283
    'AA 3C 37 6E 30 30 AC 0E' => 'AF-S Nikkor 24-120mm f/4G ED VR',
295
298
    'A2 40 2D 53 2C 3C BD 0E' => 'AF-S DX VR Nikkor 18-55mm f/3.5-5.6G II',
296
299
    'A4 40 2D 8E 2C 40 BF 0E' => 'AF-S DX Nikkor 18-300mm f/3.5-6.3G ED VR',
297
300
    'A5 4C 44 44 14 14 C0 06' => 'AF-S Nikkor 35mm f/1.8G', #35
 
301
    'A7 3C 53 80 30 3C C2 0E' => 'AF-S DX Nikkor 55-200mm f/4-5.6G ED VR II', #33
298
302
    'A8 48 8E 8E 30 30 C3 4E' => 'AF-S Nikkor 300mm f/4E PF ED VR', #35
299
303
    'A8 48 8E 8E 30 30 C3 0E' => 'AF-S Nikkor 300mm f/4E PF ED VR', #30
300
304
    'A9 4C 31 31 14 14 C4 06' => 'AF-S Nikkor 20mm f/1.8G ED', #30
 
305
    'AA 48 37 5C 24 24 C5 4E' => 'AF-S Nikkor 24-70mm f/2.8E ED VR',
 
306
    'AD 48 28 60 24 30 C8 4E' => 'AF-S VR DX 16-80mm f/2.8-4.0E ED',
 
307
    'AE 3C 80 A0 3C 3C C9 4E' => 'AF-S Nikkor 200-500mm f/5.6E ED VR', #PH
 
308
    'AE 3C 80 A0 3C 3C C9 0E' => 'AF-S Nikkor 200-500mm f/5.6E ED VR',
 
309
    'AF 4C 37 37 14 14 CC 06' => 'AF-S Nikkor 24mm f/1.8G ED', #33
301
310
    '01 00 00 00 00 00 02 00' => 'TC-16A',
302
311
    '01 00 00 00 00 00 08 00' => 'TC-16A',
303
312
    '00 00 00 00 00 00 F1 0C' => 'TC-14E [II] or Sigma APO Tele Converter 1.4x EX DG or Kenko Teleplus PRO 300 DG 1.4x',
320
329
    'F8 54 3E 3E 0C 0C 4B 06' => 'Sigma 30mm F1.4 EX DC HSM', #JD
321
330
    '91 54 44 44 0C 0C 4B 06' => 'Sigma 35mm F1.4 DG HSM', #30
322
331
    'DE 54 50 50 0C 0C 4B 06' => 'Sigma 50mm F1.4 EX DG HSM',
 
332
    '88 54 50 50 0C 0C 4B 06' => 'Sigma 50mm F1.4 DG HSM | A',
323
333
    '02 48 50 50 24 24 02 00' => 'Sigma Macro 50mm F2.8', #http://u88.n24.queensu.ca/exiftool/forum/index.php/topic,4027.0.html
324
334
    '32 54 50 50 24 24 35 02' => 'Sigma Macro 50mm F2.8 EX DG',
325
335
    'E3 54 50 50 24 24 35 02' => 'Sigma Macro 50mm F2.8 EX DG', #http://u88.n24.queensu.ca/exiftool/forum/index.php/topic,3215.0.html
454
464
    'CF 38 6E 98 34 3C 4B 0E' => 'Sigma APO 120-400mm F4.5-5.6 DG OS HSM',
455
465
    '26 44 73 98 34 3C 1C 02' => 'Sigma 135-400mm F4.5-5.6 APO Aspherical',
456
466
    'CE 34 76 A0 38 40 4B 0E' => 'Sigma 150-500mm F5-6.3 DG OS APO HSM', #JD
 
467
    '81 34 76 A6 38 40 4B 0E' => 'Sigma 150-600mm F5-6.3 DG OS HSM | S', #Jaap Voets
 
468
    '82 34 76 A6 38 40 4B 0E' => 'Sigma 150-600mm F5-6.3 DG OS HSM | C',
457
469
    '26 40 7B A0 34 40 1C 02' => 'Sigma APO 170-500mm F5-6.3 Aspherical RF',
458
470
    'A7 49 80 A0 24 24 4B 06' => 'Sigma APO 200-500mm F2.8 EX DG',
459
471
    '48 3C 8E B0 3C 3C 4B 02' => 'Sigma APO 300-800mm F5.6 EX DG HSM',
500
512
    '10 3D 3C 60 2C 3C D2 02' => 'Tamron AF 28-80mm f/3.5-5.6 Aspherical (177D)',
501
513
    '45 3D 3C 60 2C 3C 48 02' => 'Tamron AF 28-80mm f/3.5-5.6 Aspherical (177D)',
502
514
    '00 48 3C 6A 24 24 00 02' => 'Tamron SP AF 28-105mm f/2.8 LD Aspherical IF (176D)',
 
515
    '4D 3E 3C 80 2E 3C 62 02' => 'Tamron AF 28-200mm F/3.8-5.6 XR Aspherical (IF) Macro (A03N)',
503
516
    '0B 3E 3D 7F 2F 3D 0E 00' => 'Tamron AF 28-200mm f/3.8-5.6 (71D)',
504
517
    '0B 3E 3D 7F 2F 3D 0E 02' => 'Tamron AF 28-200mm f/3.8-5.6D (171D)',
505
518
    '12 3D 3C 80 2E 3C DF 02' => 'Tamron AF 28-200mm f/3.8-5.6 AF Aspherical LD (IF) (271D)',
530
543
    '00 40 18 2B 2C 34 00 06' => 'Tokina AT-X 107 AF DX Fisheye (AF 10-17mm f/3.5-4.5)',
531
544
    '00 48 1C 29 24 24 00 06' => 'Tokina AT-X 116 PRO DX (AF 11-16mm f/2.8)',
532
545
    '7A 48 1C 29 24 24 7E 06' => 'Tokina AT-X 116 PRO DX II (AF 11-16mm f/2.8)',
 
546
    '7A 48 1C 30 24 24 7E 06' => 'Tokina AT-X 11-20 F2.8 PRO DX (AF 11-20mm f/2.8)',
533
547
    '00 3C 1F 37 30 30 00 06' => 'Tokina AT-X 124 AF PRO DX (AF 12-24mm f/4)',
534
548
    '7A 3C 1F 37 30 30 7E 06.2' => 'Tokina AT-X 124 AF PRO DX II (AF 12-24mm f/4)',
535
549
    '7A 3C 1F 3C 30 30 7E 06' => 'Tokina AT-X 12-28 PRO DX (AF 12-28mm F/4)',
536
550
    '00 48 29 3C 24 24 00 06' => 'Tokina AT-X 16-28 AF PRO FX (AF 16-28mm f/2.8)',
537
551
    '00 48 29 50 24 24 00 06' => 'Tokina AT-X 165 PRO DX (AF 16-50mm f/2.8)',
538
552
    '00 40 2A 72 2C 3C 00 06' => 'Tokina AT-X 16.5-135 DX (AF 16.5-135mm F3.5-5.6)',
 
553
    '00 3C 2B 44 30 30 00 06' => 'Tokina AT-X 17-35 F4 PRO FX (AF 17-35mm f/4)',
539
554
    '2F 40 30 44 2C 34 29 02.2' => 'Tokina AF 193 (AF 19-35mm f/3.5-4.5)',
540
555
    '2F 48 30 44 24 24 29 02.2' => 'Tokina AT-X 235 AF PRO (AF 20-35mm f/2.8)',
541
556
    '2F 40 30 44 2C 34 29 02.1' => 'Tokina AF 235 II (AF 20-35mm f/3.5-4.5)',
 
557
    '00 48 37 5C 24 24 00 06' => 'Tokina AT-X 24-70 F2.8 PRO FX (AF 24-70mm f/2.8)',
542
558
    '00 40 37 80 2C 3C 00 02' => 'Tokina AT-X 242 AF (AF 24-200mm f/3.5-5.6)',
543
559
    '25 48 3C 5C 24 24 1B 02.1' => 'Tokina AT-X 270 AF PRO II (AF 28-70mm f/2.6-2.8)',
544
560
    '25 48 3C 5C 24 24 1B 02.2' => 'Tokina AT-X 287 AF PRO SV (AF 28-70mm f/2.8)',
548
564
    '00 48 3C 60 24 24 00 02' => 'Tokina AT-X 280 AF PRO (AF 28-80mm f/2.8)',
549
565
    '25 44 44 8E 34 42 1B 02' => 'Tokina AF 353 (AF 35-300mm f/4.5-6.7)',
550
566
    '00 48 50 72 24 24 00 06' => 'Tokina AT-X 535 PRO DX (AF 50-135mm f/2.8)',
 
567
    '00 3C 5C 80 30 30 00 0E' => 'Tokina AT-X 70-200 F4 FX VCM-S (AF 70-200mm f/4)',
 
568
    '00 48 5C 80 30 30 00 0E' => 'Tokina AT-X 70-200 F4 FX VCM-S (AF 70-200mm f/4)',
551
569
    '12 44 5E 8E 34 3C 09 00' => 'Tokina AF 730 (AF 75-300mm F4.5-5.6)',
552
570
    '14 54 60 80 24 24 0B 00' => 'Tokina AT-X 828 AF (AF 80-200mm f/2.8)',
553
571
    '24 54 60 80 24 24 1A 02' => 'Tokina AT-X 828 AF PRO (AF 80-200mm f/2.8)',
565
583
    '12 38 69 97 35 42 09 02' => 'Promaster Spectrum 7 100-400mm F4.5-6.7',
566
584
#
567
585
    '00 40 31 31 2C 2C 00 00' => 'Voigtlander Color Skopar 20mm F3.5 SLII Aspherical',
 
586
    '00 48 3C 3C 24 24 00 00' => 'Voigtlander Color Skopar 28mm F2.8 SL II',
568
587
    '00 54 48 48 18 18 00 00' => 'Voigtlander Ultron 40mm F2 SLII Aspherical',
569
588
    '00 54 55 55 0C 0C 00 00' => 'Voigtlander Nokton 58mm F1.4 SLII',
570
589
    '00 40 64 64 2C 2C 00 00' => 'Voigtlander APO-Lanthar 90mm F3.5 SLII Close Focus',
572
591
    '00 40 2D 2D 2C 2C 00 00' => 'Carl Zeiss Distagon T* 3.5/18 ZF.2',
573
592
    '00 48 32 32 24 24 00 00' => 'Carl Zeiss Distagon T* 2.8/21 ZF.2',
574
593
    '00 54 3C 3C 18 18 00 00' => 'Carl Zeiss Distagon T* 2/28 ZF.2',
 
594
    '00 54 44 44 0C 0C 00 00' => 'Carl Zeiss Distagon T* 1.4/35 ZF.2',
575
595
    '00 54 44 44 18 18 00 00' => 'Carl Zeiss Distagon T* 2/35 ZF.2',
576
596
    '00 54 50 50 0C 0C 00 00' => 'Carl Zeiss Planar T* 1.4/50 ZF.2',
577
597
    '00 54 50 50 18 18 00 00' => 'Carl Zeiss Makro-Planar T* 2/50 ZF.2',
578
598
    '00 54 62 62 0C 0C 00 00' => 'Carl Zeiss Planar T* 1.4/85 ZF.2',
579
599
    '00 54 68 68 18 18 00 00' => 'Carl Zeiss Makro-Planar T* 2/100 ZF.2',
 
600
    '00 54 72 72 18 18 00 00' => 'Carl Zeiss Apo Sonnar T* 2/135 ZF.2',
580
601
    '00 54 53 53 0C 0C 00 00' => 'Zeiss Otus 1.4/55', #33
 
602
    '01 54 62 62 0C 0C 00 00' => 'Zeiss Otus 1.4/85',
 
603
    '52 54 44 44 18 18 00 00' => 'Zeiss Milvus 35mm f/2',
 
604
    '53 54 50 50 0C 0C 00 00' => 'Zeiss Milvus 50mm f/1.4', #33
 
605
    '54 54 50 50 18 18 00 00' => 'Zeiss Milvus 50mm f/2 Macro',
 
606
    '55 54 62 62 0C 0C 00 00' => 'Zeiss Milvus 85mm f/1.4', #33
 
607
    '56 54 68 68 18 18 00 00' => 'Zeiss Milvus 100mm f/2 Macro',
581
608
#
582
609
    '00 54 56 56 30 30 00 00' => 'Coastal Optical Systems 60mm 1:4 UV-VIS-IR Macro Apo',
583
610
#
600
627
    '00 00 48 48 53 53 00 01' => 'Loreo 40mm F11-22 3D Lens in a Cap 9005', #PH
601
628
    '00 47 10 10 24 24 00 00' => 'Fisheye Nikkor 8mm f/2.8 AiS',
602
629
    '00 47 3C 3C 24 24 00 00' => 'Nikkor 28mm f/2.8 AiS', #35
603
 
    '00 54 44 44 0C 0C 00 00' => 'Nikkor 35mm f/1.4 AiS',
 
630
  # '00 54 44 44 0C 0C 00 00' => 'Nikkor 35mm f/1.4 AiS', comment out in favour of Zeiss with same ID because this lens is rare (requires CPU upgrade)
604
631
    '00 57 50 50 14 14 00 00' => 'Nikkor 50mm f/1.8 AI', #35
605
632
    '00 48 50 50 18 18 00 00' => 'Nikkor H 50mm f/2',
606
633
    '00 48 68 68 24 24 00 00' => 'Series E 100mm f/2.8',
1382
1409
            SubDirectory => {
1383
1410
                TagTable => 'Image::ExifTool::Nikon::ShotInfoD810',
1384
1411
                DecryptStart => 4,
1385
 
                DecryptLen => 0x1984,
1386
 
                ByteOrder => 'BigEndian',
 
1412
                # initially only decrypt enough to extract CustomSettingsOffset
 
1413
                DecryptLen => 0x40,
 
1414
                # then decrypt through to the end of the custom settings
 
1415
                DecryptMore => 'Get32u(\$data, 0x40) + 53 + 4',
 
1416
                ByteOrder => 'LittleEndian',
1387
1417
            },
1388
1418
        },
1389
1419
        # 0217 - D3000
4538
4568
    WRITE_PROC => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
4539
4569
    CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
4540
4570
    VARS => { ID_LABEL => 'Index' },
4541
 
    DATAMEMBER => [ 4 ],
4542
 
    IS_SUBDIR => [ 0x18ab, 0x194b ],
 
4571
    DATAMEMBER => [ 0x40, 0x175e ],
 
4572
    IS_SUBDIR => [ 0x18ab ],
4543
4573
    WRITABLE => 1,
4544
4574
    FIRST_ENTRY => 0,
4545
4575
    GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
4551
4581
    },
4552
4582
    0x04 => {
4553
4583
        Name => 'FirmwareVersion',
4554
 
        DataMember => 'FirmwareVersion',
4555
4584
        Format => 'string[5]',
4556
4585
        Writable => 0,
4557
 
        RawConv => '$$self{FirmwareVersion} = $val',
4558
 
    },
4559
 
    0x16be => { # metering mode
4560
 
        Name => 'D810MeteringMode',
4561
 
        Condition => '$$self{FirmwareVersion} =~ /^1.00/',
4562
 
        Notes => 'firmware version 1.00',
4563
 
        Mask => 0x03,
4564
 
        PrintConv => {
4565
 
            0 => 'Matrix',
4566
 
            1 => 'Center',
4567
 
            2 => 'Spot',
4568
 
            3 => 'Highlight'
4569
 
        },
4570
 
    },
4571
 
    0x175e => { # metering mode
4572
 
        Name => 'D810MeteringMode',
4573
 
        Condition => '$$self{FirmwareVersion} !~ /^1.00/',
4574
 
        Notes => 'firmware version 1.01 and 1.02',
4575
 
        Mask => 0x03,
4576
 
        PrintConv => {
4577
 
            0 => 'Matrix',
4578
 
            1 => 'Center',
4579
 
            2 => 'Spot',
4580
 
            3 => 'Highlight'
4581
 
        },
4582
 
    },
4583
 
    0x18ab => { 
4584
 
        Name => 'CustomSettingsD810',
4585
 
        Condition => '$$self{FirmwareVersion} =~ /^1.00/',
4586
 
        Notes => 'firmware version 1.00',
4587
 
        Format => 'undef[53]',
4588
 
        SubDirectory => {
4589
 
            TagTable => 'Image::ExifTool::NikonCustom::SettingsD810',
4590
 
        },
4591
 
    },
4592
 
    0x194b => { 
4593
 
        Name => 'CustomSettingsD810',
4594
 
        Condition => '$$self{FirmwareVersion} !~ /^1.00/',
4595
 
        Notes => 'firmware version 1.01 and 1.02',
4596
 
        Format => 'undef[53]',
4597
 
        SubDirectory => {
4598
 
            TagTable => 'Image::ExifTool::NikonCustom::SettingsD810',
4599
 
        },
4600
 
    },
4601
 
    # note: DecryptLen currently set to 0x1984
 
4586
    },
 
4587
    # 0x0c - number of entries in offset table (= 0x21)
 
4588
    # 0x10 - int32u[val 0x0c]: offset table
 
4589
    0x40 => {
 
4590
        Name => 'CustomSettingsOffset', # (relative offset from start of ShotInfo data)
 
4591
        DataMember => 'CustomSettingsOffset',
 
4592
        Format => 'int32u',
 
4593
        Writable => 0,
 
4594
        RawConv => '$$self{CustomSettingsOffset} = $val',
 
4595
    },
 
4596
    0x175e => {
 
4597
        Name => 'D810MeteringMode',
 
4598
        Mask => 0x03,
 
4599
        PrintConv => {
 
4600
            0 => 'Matrix',
 
4601
            1 => 'Center',
 
4602
            2 => 'Spot',
 
4603
            3 => 'Highlight'
 
4604
        },
 
4605
        Hook => '$varSize += $$self{CustomSettingsOffset} - 0x18ab',
 
4606
    },
 
4607
    0x18ab => { # (actual offset adjusted by Hook above)
 
4608
        Name => 'CustomSettingsD810',
 
4609
        Notes => 'actual offset determined by CustomSettingsOffset',
 
4610
        Format => 'undef[53]',
 
4611
        SubDirectory => {
 
4612
            TagTable => 'Image::ExifTool::NikonCustom::SettingsD810',
 
4613
        },
 
4614
    },
 
4615
    # note: DecryptMore currently set to 53+4 bytes after CustomSettingsOffset
4602
4616
);
4603
4617
 
4604
4618
# shot information for the D4 firmware 1.00g (ref PH)
5816
5830
#
5817
5831
    0x1200000 => {
5818
5832
        Name => 'GPSVersionID',
5819
 
        Groups => { 2 => 'Location' },
 
5833
        Groups => { 1 => 'GPS', 2 => 'Location' },
5820
5834
        PrintConv => '$val =~ tr/ /./; $val',
5821
5835
    },
5822
5836
    0x1200001 => {
5823
5837
        Name => 'GPSLatitudeRef',
5824
 
        Groups => { 2 => 'Location' },
 
5838
        Groups => { 1 => 'GPS', 2 => 'Location' },
5825
5839
        PrintConv => {
5826
5840
            N => 'North',
5827
5841
            S => 'South',
5829
5843
    },
5830
5844
    0x1200002 => {
5831
5845
        Name => 'GPSLatitude',
5832
 
        Groups => { 2 => 'Location' },
 
5846
        Groups => { 1 => 'GPS', 2 => 'Location' },
5833
5847
        ValueConv => q{
5834
5848
            require Image::ExifTool::GPS;
5835
5849
            Image::ExifTool::GPS::ToDegrees($val);
5838
5852
    },
5839
5853
    0x1200003 => {
5840
5854
        Name => 'GPSLongitudeRef',
5841
 
        Groups => { 2 => 'Location' },
 
5855
        Groups => { 1 => 'GPS', 2 => 'Location' },
5842
5856
        PrintConv => {
5843
5857
            E => 'East',
5844
5858
            W => 'West',
5846
5860
    },
5847
5861
    0x1200004 => {
5848
5862
        Name => 'GPSLongitude',
5849
 
        Groups => { 2 => 'Location' },
 
5863
        Groups => { 1 => 'GPS', 2 => 'Location' },
5850
5864
        ValueConv => q{
5851
5865
            require Image::ExifTool::GPS;
5852
5866
            Image::ExifTool::GPS::ToDegrees($val);
5855
5869
    },
5856
5870
    0x1200005 => {
5857
5871
        Name => 'GPSAltitudeRef',
5858
 
        Groups => { 2 => 'Location' },
 
5872
        Groups => { 1 => 'GPS', 2 => 'Location' },
5859
5873
        PrintConv => {
5860
5874
            0 => 'Above Sea Level',
5861
5875
            1 => 'Below Sea Level',
5863
5877
    },
5864
5878
    0x1200006 => {
5865
5879
        Name => 'GPSAltitude',
5866
 
        Groups => { 2 => 'Location' },
 
5880
        Groups => { 1 => 'GPS', 2 => 'Location' },
5867
5881
        PrintConv => '$val =~ /^(inf|undef)$/ ? $val : "$val m"',
5868
5882
    },
5869
5883
    0x1200007 => {
5870
5884
        Name => 'GPSTimeStamp',
5871
 
        Groups => { 2 => 'Time' },
 
5885
        Groups => { 1 => 'GPS', 2 => 'Time' },
5872
5886
        ValueConv => q{
5873
5887
            require Image::ExifTool::GPS;
5874
5888
            Image::ExifTool::GPS::ConvertTimeStamp($val);
5877
5891
    },
5878
5892
    0x1200008 => {
5879
5893
        Name => 'GPSSatellites',
5880
 
        Groups => { 2 => 'Location' },
 
5894
        Groups => { 1 => 'GPS', 2 => 'Location' },
5881
5895
    },
5882
5896
    0x1200010 => {
5883
5897
        Name => 'GPSImgDirectionRef',
5884
 
        Groups => { 2 => 'Location' },
 
5898
        Groups => { 1 => 'GPS', 2 => 'Location' },
5885
5899
        PrintConv => {
5886
5900
            M => 'Magnetic North',
5887
5901
            T => 'True North',
5889
5903
    },
5890
5904
    0x1200011 => {
5891
5905
        Name => 'GPSImgDirection',
5892
 
        Groups => { 2 => 'Location' },
 
5906
        Groups => { 1 => 'GPS', 2 => 'Location' },
5893
5907
    },
5894
5908
    0x1200012 => {
5895
5909
        Name => 'GPSMapDatum',
5896
 
        Groups => { 2 => 'Location' },
 
5910
        Groups => { 1 => 'GPS', 2 => 'Location' },
5897
5911
    },
5898
5912
    0x120001d => {
5899
5913
        Name => 'GPSDateStamp',
5900
 
        Groups => { 2 => 'Time' },
 
5914
        Groups => { 1 => 'GPS', 2 => 'Time' },
5901
5915
        ValueConv => 'Image::ExifTool::Exif::ExifDate($val)',
5902
5916
    },
5903
5917
#
6339
6353
    my ($i, $dat);
6340
6354
 
6341
6355
    $start or $start = 0;
6342
 
    $len = length($$dataPt) - $start if not defined $len or $len > length($$dataPt) - $start;
 
6356
    my $maxLen = length($$dataPt) - $start;
 
6357
    $len = $maxLen if not defined $len or $len > $maxLen;
6343
6358
    return $$dataPt if $len <= 0;
6344
6359
    my $key = 0;
6345
6360
    for ($i=0; $i<4; ++$i) {
6436
6451
    }
6437
6452
    my $verbose = $$dirInfo{IsWriting} ? 0 : $et->Options('Verbose');
6438
6453
    my $tagInfo = $$dirInfo{TagInfo};
6439
 
    my $data = substr(${$$dirInfo{DataPt}}, $$dirInfo{DirStart}, $$dirInfo{DirLen});
 
6454
    my $dirStart = $$dirInfo{DirStart};
 
6455
    my $data = substr(${$$dirInfo{DataPt}}, $dirStart, $$dirInfo{DirLen});
6440
6456
 
6441
 
    my ($start, $len, $offset, $byteOrder, $recrypt, $newSerial, $newCount);
 
6457
    my ($start, $len, $more, $offset, $byteOrder, $recrypt, $newSerial, $newCount);
6442
6458
 
6443
6459
    # must re-encrypt when writing if serial number or shutter count changes
6444
6460
    if ($$dirInfo{IsWriting}) {
6456
6472
        # may decrypt only part of the information to save time
6457
6473
        if ($verbose < 3 and $et->Options('Unknown') < 2 and not $recrypt) {
6458
6474
            $len = $$tagInfo{SubDirectory}{DecryptLen};
 
6475
            $more = $$tagInfo{SubDirectory}{DecryptMore};
6459
6476
        }
6460
6477
        $offset = $$tagInfo{SubDirectory}{DirOffset};
6461
6478
        $byteOrder = $$tagInfo{SubDirectory}{ByteOrder};
6462
6479
    }
6463
6480
    $start or $start = 0;
6464
6481
    if (defined $offset) {
6465
 
        # offset, if specified, is releative to start of encrypted data
 
6482
        # offset, if specified, is relative to start of encrypted data
6466
6483
        $offset += $start;
6467
6484
    } else {
6468
6485
        $offset = 0;
6469
6486
    }
6470
6487
    my $maxLen = length($data) - $start;
6471
6488
    # decrypt all the data unless DecryptLen is given
6472
 
    $len = $maxLen unless $len and $len <= $maxLen;
 
6489
    unless ($len and $len < $maxLen) {
 
6490
        $len = $maxLen;
 
6491
        undef $more;    # (can't decrypt more than this)
 
6492
    }
6473
6493
 
6474
6494
    $data = Decrypt(\$data, $serial, $count, $start, $len);
6475
6495
 
 
6496
    # set appropriate byte ordering before evaluating DecryptMore
 
6497
    my $oldOrder = GetByteOrder();
 
6498
    SetByteOrder($byteOrder) if $byteOrder;
 
6499
 
 
6500
    if ($more) {
 
6501
        #### eval DecryptMore ($data)
 
6502
        my $moreLen = eval $more;
 
6503
        $moreLen = $maxLen if $moreLen > $maxLen;
 
6504
        # re-decrypt with new length
 
6505
        if ($len < $moreLen) {
 
6506
            $len = $moreLen;
 
6507
            $data = substr(${$$dirInfo{DataPt}}, $dirStart, $$dirInfo{DirLen});
 
6508
            $data = Decrypt(\$data, $serial, $count, $start, $len);
 
6509
        }
 
6510
    }
6476
6511
    if ($verbose > 2) {
6477
6512
        $et->VerboseDir("Decrypted $$tagInfo{Name}");
6478
6513
        $et->VerboseDump(\$data,
6479
6514
            Prefix  => $$et{INDENT} . '  ',
6480
 
            DataPos => $$dirInfo{DirStart} + $$dirInfo{DataPos} + ($$dirInfo{Base} || 0),
 
6515
            DataPos => $dirStart + $$dirInfo{DataPos} + ($$dirInfo{Base} || 0),
6481
6516
        );
6482
6517
    }
6483
6518
    # process the decrypted information
6486
6521
        DirStart => $offset,
6487
6522
        DirLen   => length($data) - $offset,
6488
6523
        DirName  => $$dirInfo{DirName},
6489
 
        DataPos  => $$dirInfo{DataPos} + $$dirInfo{DirStart},
 
6524
        DataPos  => $$dirInfo{DataPos} + $dirStart,
6490
6525
        Base     => $$dirInfo{Base},
6491
6526
    );
6492
6527
    my $rtnVal;
6493
 
    my $oldOrder = GetByteOrder();
6494
 
    SetByteOrder($byteOrder) if $byteOrder;
6495
6528
    if ($$dirInfo{IsWriting}) {
6496
6529
        my $changed = $$et{CHANGED};
6497
6530
        $rtnVal = $et->WriteBinaryData(\%subdirInfo, $tagTablePtr);
6627
6660
}
6628
6661
 
6629
6662
#------------------------------------------------------------------------------
6630
 
# Read/write Nikon Makernotes directory
 
6663
# Read/write Nikon MakerNotes directory
6631
6664
# Inputs: 0) ExifTool object ref, 1) dirInfo ref, 2) tag table ref
6632
6665
# Returns: 1 on success, otherwise returns 0 and sets a Warning when reading
6633
6666
#          or new directory when writing (IsWriting set in dirInfo)
6646
6679
    my $rtnVal;
6647
6680
    if ($$dirInfo{IsWriting}) {
6648
6681
        # get new decryptino keys if they are being changed
6649
 
        my $serial = $et->GetNewValues($Image::ExifTool::Nikon::Main{0x001d});
6650
 
        my $count = $et->GetNewValues($Image::ExifTool::Nikon::Main{0x00a7});
 
6682
        my $serial = $et->GetNewValue($Image::ExifTool::Nikon::Main{0x001d});
 
6683
        my $count = $et->GetNewValue($Image::ExifTool::Nikon::Main{0x00a7});
6651
6684
        $$et{NewNikonSerialKey} = SerialKey($et, $serial);
6652
6685
        $$et{NewNikonCountKey} = $count;
6653
6686
        $rtnVal = Image::ExifTool::Exif::WriteExif($et, $dirInfo, $tagTablePtr);