source: extensions/edit_gmaps/admin/include/Makernotes/fujifilm.php @ 9412

Last change on this file since 9412 was 9412, checked in by cljosse, 13 years ago
File size: 12.0 KB
Line 
1<?php
2
3/******************************************************************************
4*
5* Filename:     fujifilm.php
6*
7* Description:  Fujifilm Makernote Parser
8*               Provides functions to decode an Fujifilm EXIF makernote and to interpret
9*               the resulting array into html.
10*               This Makernote format is also used by one Nikon Camera
11*
12*               Fujifilm Makernote Format:
13*
14*               Field           Size            Description
15*               ----------------------------------------------------------------
16*               Header          8 Bytes         "FUJIFILM"
17*               IFD Offset      4 Bytes         Intel Byte aligned offset to IFD from start of Makernote
18*               IFD Data        Variable        NON-Standard IFD Data using Fujifilm Tags
19*                                               Offsets are relative to start of makernote
20*                                               Byte alignment is always Intel
21*               ----------------------------------------------------------------
22*
23*
24* Author:      Evan Hunter
25*
26* Date:         30/7/2004
27*
28* Project:      JPEG Metadata
29*
30* Revision:     1.00
31*
32* URL:          http://electronics.ozhiker.com
33*
34* Copyright:    Copyright " . $auteur . " 2004
35*               This file may be used freely for non-commercial purposes.For
36*               commercial uses please contact the author: evan@ozhiker.com
37*
38******************************************************************************/
39
40
41
42// Add the parser and interpreter functions to the list of Makernote parsers and interpreters.
43
44$GLOBALS['Makernote_Function_Array']['Read_Makernote_Tag'][] = "get_Fujifilm_Makernote";
45$GLOBALS['Makernote_Function_Array']['get_Makernote_Text_Value'][] = "get_Fujifilm_Text_Value";
46$GLOBALS['Makernote_Function_Array']['Interpret_Makernote_to_HTML'][] = "get_Fujifilm_Makernote_Html";
47
48
49
50
51
52
53/******************************************************************************
54*
55* Function:     get_Fujifilm_Makernote
56*
57* Description:  Decodes the Makernote tag and returns the new tag with the decoded
58*               information attached. Returns false if this is not a makernote
59*               that can be processed with this script
60*
61* Parameters:   Makernote_Tag - the element of an EXIF array containing the
62*                               makernote, as returned from get_EXIF_JPEG
63*               EXIF_Array - the entire EXIF array containing the
64*                            makernote, as returned from get_EXIF_JPEG, in
65*                            case more information is required for decoding
66*               filehnd - an open file handle for the file containing the
67*                         makernote - does not have to be positioned at the
68*                         start of the makernote
69*               Make_Field - The contents of the EXIF Make field, to aid
70*                            determining whether this script can decode
71*                            the makernote
72*
73*
74* Returns:      Makernote_Tag - the Makernote_Tag from the parameters, but
75*                               modified to contain the decoded information
76*               FALSE - If this script could not decode the makernote, or if
77*                       an error occured in decoding
78*
79******************************************************************************/
80
81function get_Fujifilm_Makernote( $Makernote_Tag, $EXIF_Array, $filehnd, $Make_Field )
82{
83
84        // Check if the Make Field contains the word Fuji or Nikon (One Nikon camera uses this format Makernote)
85        if ( ( stristr( $Make_Field, "Fuji" ) === FALSE ) &&
86             ( stristr( $Make_Field, "Nikon" ) === FALSE ) )
87        {
88                // Couldn't find Fuji or Nikon in the maker name - abort
89                return FALSE;
90        }
91       
92        // Check if the header exists at the start of the Makernote
93        if ( substr( $Makernote_Tag['Data'], 0, 8 ) != "FUJIFILM" )
94        {
95                // This isn't a Fuji Makernote, abort
96                return FALSE;
97        }
98
99        // The 4 bytes after the header are the offset to the Fujifilm IFD
100        // Get the offset of the IFD
101        $ifd_offset = hexdec( bin2hex( strrev( substr( $Makernote_Tag['Data'], 8, 4 ) ) ) );
102
103        // Seek to the start of the IFD
104        fseek($filehnd, $Makernote_Tag['Tiff Offset'] + $Makernote_Tag['Offset'] + $ifd_offset );
105
106        // Fuji Makernotes are always Intel Byte Aligned
107        $Makernote_Tag['ByteAlign'] = "II";
108       
109        // Read the IFD(s) into an array
110        $Makernote_Tag['Decoded Data'] = read_Multiple_IFDs( $filehnd, $Makernote_Tag['Tiff Offset'] + $Makernote_Tag['Offset'], $Makernote_Tag['ByteAlign'], "Fujifilm" );
111
112        // Save some information into the Tag element to aid interpretation
113        $Makernote_Tag['Decoded'] = TRUE;
114        $Makernote_Tag['Makernote Type'] = "Fujifilm";
115        $Makernote_Tag['Makernote Tags'] = "Fujifilm";
116
117
118        // Return the new tag
119        return $Makernote_Tag;
120
121}
122
123/******************************************************************************
124* End of Function:     get_Fujifilm_Makernote
125******************************************************************************/
126
127
128
129
130
131
132
133
134
135/******************************************************************************
136*
137* Function:     get_Fujifilm_Text_Value
138*
139* Description:  Provides a text value for any tag marked as special for makernotes
140*               that this script can decode. Returns false if this is not a makernote
141*               that can be processed with this script
142*
143* Parameters:   Exif_Tag - the element of an the Makernote array containing the
144*                          tag in question, as returned from get_Fujifilm_Makernote
145*               Tag_Definitions_Name - The name of the Tag Definitions group
146*                                      within the global array IFD_Tag_Definitions
147*
148*
149* Returns:      output - the text value for the tag
150*               FALSE - If this script could not decode the makernote, or if
151*                       an error occured in decoding
152*
153******************************************************************************/
154
155function get_Fujifilm_Text_Value( $Exif_Tag, $Tag_Definitions_Name )
156{
157        // Check that this tag uses the Fujifilm tag Definitions, otherwise it can't be decoded here
158        if ( $Tag_Definitions_Name == "Fujifilm" )
159        {
160                // No special Tags at this time
161                return FALSE;
162        }
163       
164        return FALSE;
165}
166
167/******************************************************************************
168* End of Function:     get_Fujifilm_Text_Value
169******************************************************************************/
170
171
172
173
174
175
176
177
178
179
180/******************************************************************************
181*
182* Function:     get_Fujifilm_Makernote_Html
183*
184* Description:  Attempts to interpret a makernote into html. Returns false if
185*               it is not a makernote that can be processed with this script
186*
187* Parameters:   Makernote_Tag - the element of an EXIF array containing the
188*                               makernote, as returned from get_EXIF_JPEG
189*               filename - the name of the JPEG file being processed ( used
190*                          by scripts which display embedded thumbnails)
191*
192*
193* Returns:      output - the html representing the makernote
194*               FALSE - If this script could not interpret the makernote, or if
195*                       an error occured in decoding
196*
197******************************************************************************/
198
199function get_Fujifilm_Makernote_Html( $Makernote_tag, $filename )
200{
201        // Check that this tag uses the Fujifilm tags, otherwise it can't be interpreted here
202        if ( $Makernote_tag['Makernote Type'] != "Fujifilm" )
203        {
204                // Not Fujifilm tags - can't interpret with this function
205                return FALSE;
206        }
207       
208        // Interpret the IFD normally
209        return interpret_IFD( $Makernote_tag['Decoded Data'][0], $filename );
210
211}
212
213/******************************************************************************
214* End of Function:     get_Fujifilm_Makernote_Html
215******************************************************************************/
216
217
218
219
220
221
222
223
224
225
226
227
228
229/******************************************************************************
230* Global Variable:      IFD_Tag_Definitions, Fujifilm
231*
232* Contents:     This global variable provides definitions of the known Fujifilm
233*               Makernote tags, indexed by their tag number.
234*
235******************************************************************************/
236
237$GLOBALS[ "IFD_Tag_Definitions" ]["Fujifilm"] = array(
238
2390 => array(     'Name' => "Version",
240                'Type' => "String" ),
241
2424096 => array(  'Name' => "Quality",
243                'Type' => "String" ),
244
2454097 => array(  'Name' => "Sharpness",
246                'Type' => "Lookup",
247                1 => "Softest",
248                2 => "Soft",
249                3 => "Normal",
250                4 => "Hard",
251                5 => "Hardest" ),
252
2534098 => array(  'Name' => "White Balance",
254                'Type' => "Lookup",
255                0 => "Auto",
256                256 => "Daylight",
257                512 => "Cloudy",
258                768 => "DaylightColour-fluorescence",
259                769 => "DaywhiteColour-fluorescence",
260                770 => "White-fluorescence",
261                1024 => "Incandenscense",
262                3840 => "Custom white balance" ),
263
2644099 => array(  'Name' => "Colour Saturation",
265                'Type' => "Lookup",
266                0 => "Normal",
267                256 => "High",
268                512 => "Low" ),
269
2704100 => array(  'Name' => "Tone (Contrast)",
271                'Type' => "Lookup",
272                0 => "Normal",
273                256 => "High",
274                512 => "Low" ),
275
2764112 => array(  'Name' => "Flash Mode",
277                'Type' => "Lookup",
278                0 => "Auto",
279                1 => "On",
280                2 => "Off",
281                3 => "Red-eye Reduction" ),
282
2834113 => array(  'Name' => "Flash Strength",
284                'Type' => "Numeric",
285                'Units' => "EV" ),
286
2874128 => array(  'Name' => "Macro",
288                'Type' => "Lookup",
289                0 => "Off",
290                1 => "On" ),
291
2924129 => array(  'Name' => "Focus Mode",
293                'Type' => "Lookup",
294                0 => "Auto Focus",
295                1 => "Manual Focus" ),
296
2974144 => array(  'Name' => "Slow Sync",
298                'Type' => "Lookup",
299                0 => "Off",
300                1 => "On" ),
301
3024145 => array(  'Name' => "Picture Mode",
303                'Type' => "Lookup",
304                0 => "Auto",
305                1 => "Portrait Scene",
306                2 => "Landscape Scene",
307                4 => "Sports Scene",
308                5 => "Night Scene",
309                6 => "Program AE",
310                256 => "Aperture priority AE",
311                512 => "Shutter priority AE",
312                768 => "Manual Exposure" ),
313
3144352 => array(  'Name' => "Continuous taking or auto bracketing mode",
315                'Type' => "Lookup",
316                0 => "Off",
317                1 => "On" ),
318
3194864 => array(  'Name' => "Blur Warning",
320                'Type' => "Lookup",
321                0 => "No Blur Warning",
322                1 => "Blur Warning" ),
323
3244865 => array(  'Name' => "Focus warning",
325                'Type' => "Lookup",
326                0 => "Auto Focus Good",
327                1 => "Out of Focus" ),
328
3294866 => array(  'Name' => "Auto Exposure Warning",
330                'Type' => "Lookup",
331                0 => "Auto Exposure Good",
332                1 => "Over exposure (>1/1000s,F11)" )
333
334);
335
336/******************************************************************************
337* End of Global Variable:     IFD_Tag_Definitions, Fujifilm
338******************************************************************************/
339
340
341
342
343
344?>
Note: See TracBrowser for help on using the repository browser.