File Coverage

blib/lib/Image/ExifTool/Apple.pm
Criterion Covered Total %
statement 12 12 100.0
branch n/a
condition n/a
subroutine 4 4 100.0
pod n/a
total 16 16 100.0


line stmt bran cond sub pod time code
1             #------------------------------------------------------------------------------
2             # File: Apple.pm
3             #
4             # Description: Apple EXIF maker notes tags
5             #
6             # Revisions: 2013-09-13 - P. Harvey Created
7             #
8             # References: 1) http://www.photoinvestigator.co/blog/the-mystery-of-maker-apple-metadata/
9             #------------------------------------------------------------------------------
10              
11             package Image::ExifTool::Apple;
12              
13 3     3   3372 use strict;
  3         5  
  3         98  
14 3     3   15 use vars qw($VERSION);
  3         5  
  3         109  
15 3     3   1059 use Image::ExifTool::Exif;
  3         7  
  3         155  
16 3     3   1085 use Image::ExifTool::PLIST;
  3         6  
  3         544  
17              
18             $VERSION = '1.05';
19              
20             # Apple iPhone metadata (ref PH)
21             %Image::ExifTool::Apple::Main = (
22             WRITE_PROC => \&Image::ExifTool::Exif::WriteExif,
23             CHECK_PROC => \&Image::ExifTool::Exif::CheckExif,
24             WRITABLE => 1,
25             GROUPS => { 0 => 'MakerNotes', 2 => 'Image' },
26             NOTES => 'Tags extracted from the maker notes of iPhone images.',
27             # 0x0001 - int32s: seen 0,1,2,3,4,9
28             # 0x0002 - binary plist with a single data object of size 512 bytes (iPhone5s)
29             0x0003 => {
30             Name => 'RunTime', # (includes time plugged in, but not when suspended, ref 1)
31             SubDirectory => { TagTable => 'Image::ExifTool::Apple::RunTime' },
32             },
33             # 0x0004 - int32s: normally 1, but 0 for low-light images
34             # 0x0005 - int32s: seen values 113-247, and 100 for blank images
35             # 0x0006 - int32s: seen values 27-258, and 20 for blank images
36             # 0x0007 - int32s: seen 1
37             0x0008 => { #1
38             Name => 'AccelerationVector',
39             Groups => { 2 => 'Camera' },
40             Writable => 'rational64s',
41             Count => 3,
42             # Note: the directions are contrary to the Apple documentation (which have the
43             # signs of all axes reversed -- apparently the Apple geeks aren't very good
44             # with basic physics, and don't understand the concept of acceleration. See
45             # http://nscookbook.com/2013/03/ios-programming-recipe-19-using-core-motion-to-access-gyro-and-accelerometer/
46             # for one of the few correct descriptions of this). Note that this leads to
47             # a left-handed coordinate system for acceleration.
48             Notes => q{
49             XYZ coordinates of the acceleration vector in units of g. As viewed from
50             the front of the phone, positive X is toward the left side, positive Y is
51             toward the bottom, and positive Z points into the face of the phone
52             },
53             },
54             # 0x0009 - int32s: seen 19,275,531,4371
55             0x000a => {
56             Name => 'HDRImageType',
57             Writable => 'int32s',
58             PrintConv => {
59             # 2 => ? (iPad mini 2)
60             3 => 'HDR Image',
61             4 => 'Original Image',
62             },
63             },
64             0x000b => {
65             Name => 'BurstUUID',
66             Writable => 'string',
67             Notes => 'unique ID for all images in a burst',
68             },
69             # 0x000c - rational64s[2]: eg) "0.1640625 0.19921875"
70             # 0x000d - int32s: 0,1,6,20,24,32,40
71             # 0x000e - int32s: 0,1,4,12 (Orientation? 0=landscape? 4=portrait? ref 1)
72             # 0x000f - int32s: 2,3
73             # 0x0010 - int32s: 1
74             0x0011 => {
75             Name => 'MediaGroupUUID', #NealKrawetz private communication
76             # (changed in 12.19 from Name => 'ContentIdentifier', #forum8750)
77             Writable => 'string',
78             },
79             # 0x0014 - int32s: 1,2,3,4,5 (iPhone 6s, iOS 6.1)
80             0x0015 => {
81             Name => 'ImageUniqueID',
82             Writable => 'string',
83             },
84             # 0x0016 - string[29]: "AXZ6pMTOh2L+acSh4Kg630XCScoO\0"
85             # 0x0017 - int32s: 0,8192
86             # 0x0019 - int32s: 0,2,128
87             # 0x001a - string[6]: "q825s\0"
88             # 0x001f - int32s: 0
89             );
90              
91             # PLIST-format CMTime structure (ref PH)
92             # (CMTime ref https://developer.apple.com/library/ios/documentation/CoreMedia/Reference/CMTime/Reference/reference.html)
93             %Image::ExifTool::Apple::RunTime = (
94             PROCESS_PROC => \&Image::ExifTool::PLIST::ProcessBinaryPLIST,
95             GROUPS => { 0 => 'MakerNotes', 2 => 'Image' },
96             NOTES => q{
97             This PLIST-format information contains the elements of a CMTime structure
98             representing the amount of time the phone has been running since the last
99             boot, not including standby time.
100             },
101             timescale => { Name => 'RunTimeScale' }, # (seen 1000000000 --> ns)
102             epoch => { Name => 'RunTimeEpoch' }, # (seen 0)
103             value => { Name => 'RunTimeValue' }, # (should divide by RunTimeScale to get seconds)
104             flags => {
105             Name => 'RunTimeFlags',
106             PrintConv => { BITMASK => {
107             0 => 'Valid',
108             1 => 'Has been rounded',
109             2 => 'Positive infinity',
110             3 => 'Negative infinity',
111             4 => 'Indefinite',
112             }},
113             },
114             );
115              
116             # Apple composite tags
117             %Image::ExifTool::Apple::Composite = (
118             GROUPS => { 2 => 'Camera' },
119             RunTimeSincePowerUp => {
120             Require => {
121             0 => 'Apple:RunTimeValue',
122             1 => 'Apple:RunTimeScale',
123             },
124             ValueConv => '$val[1] ? $val[0] / $val[1] : undef',
125             PrintConv => 'ConvertDuration($val)',
126             },
127             );
128              
129             # add our composite tags
130             Image::ExifTool::AddCompositeTags('Image::ExifTool::Apple');
131              
132              
133             1; # end
134              
135             __END__