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

Last change on this file since 9412 was 9412, checked in by cljosse, 13 years ago
File size: 17.7 KB
Line 
1<?php
2
3/******************************************************************************
4*
5* Filename:     olympus.php
6*
7* Description:  Olympus Makernote Parser
8*               Provides functions to decode an Olympus EXIF makernote and to interpret
9*               the resulting array into html.
10*
11*               Olympus Makernote Format:
12*
13*               Field           Size            Description
14*               ----------------------------------------------------------------
15*               Header          7 Bytes         "OLYMP\x00\x01" or "OLYMP\x00\x02"
16*               Unknown         1 Bytes         Unknown
17*               IFD Data        Variable        Standard IFD Data using Olympus Tags
18*               ----------------------------------------------------------------
19*
20*
21* Author:      Evan Hunter
22*
23* Date:         30/7/2004
24*
25* Project:      JPEG Metadata
26*
27* Revision:     1.11
28*
29* Changes:      1.00 -> 1.11 : changed get_Olympus_Makernote_Html to allow thumbnail links to work when
30*                              toolkit is portable across directories
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_Olympus_Makernote";
45$GLOBALS['Makernote_Function_Array']['get_Makernote_Text_Value'][] = "get_Olympus_Text_Value";
46$GLOBALS['Makernote_Function_Array']['Interpret_Makernote_to_HTML'][] = "get_Olympus_Makernote_Html";
47
48
49
50
51include_once dirname(__FILE__) .'/../pjmt_utils.php';          // Change: as of version 1.11 - added to allow directory portability
52
53
54
55
56/******************************************************************************
57*
58* Function:     get_Olympus_Makernote
59*
60* Description:  Decodes the Makernote tag and returns the new tag with the decoded
61*               information attached. Returns false if this is not a makernote
62*               that can be processed with this script
63*
64* Parameters:   Makernote_Tag - the element of an EXIF array containing the
65*                               makernote, as returned from get_EXIF_JPEG
66*               EXIF_Array - the entire EXIF array containing the
67*                            makernote, as returned from get_EXIF_JPEG, in
68*                            case more information is required for decoding
69*               filehnd - an open file handle for the file containing the
70*                         makernote - does not have to be positioned at the
71*                         start of the makernote
72*               Make_Field - The contents of the EXIF Make field, to aid
73*                            determining whether this script can decode
74*                            the makernote
75*
76*
77* Returns:      Makernote_Tag - the Makernote_Tag from the parameters, but
78*                               modified to contain the decoded information
79*               FALSE - If this script could not decode the makernote, or if
80*                       an error occured in decoding
81*
82******************************************************************************/
83
84function get_Olympus_Makernote( $Makernote_Tag, $EXIF_Array, $filehnd, $Make_Field )
85{
86
87        // Check if the Make Field contains the word Olympus
88        if ( stristr( $Make_Field, "Olympus" ) === FALSE )
89        {
90                return FALSE;
91        }
92
93        // Check if the header exists at the start of the Makernote
94        if ( ( substr( $Makernote_Tag['Data'], 0, 7 ) != "OLYMP\x00\x01" ) &&
95             ( substr( $Makernote_Tag['Data'], 0, 7 ) != "OLYMP\x00\x02" ) )
96        {
97                // This isn't a Olympus Makernote, abort
98                return FALSE ;
99        }
100
101
102
103        // Seek to the start of the IFD
104        fseek($filehnd, $Makernote_Tag['Tiff Offset'] + $Makernote_Tag['Offset'] + 8 );
105
106        // Read the IFD(s) into an array
107        $Makernote_Tag['Decoded Data'] = read_Multiple_IFDs( $filehnd, $Makernote_Tag['Tiff Offset'], $Makernote_Tag['ByteAlign'], "Olympus" );
108
109        // Save some information into the Tag element to aid interpretation
110        $Makernote_Tag['Decoded'] = TRUE;
111        $Makernote_Tag['Makernote Type'] = "Olympus";
112        $Makernote_Tag['Makernote Tags'] = "Olympus";
113
114
115        // Return the new tag
116        return $Makernote_Tag;
117}
118
119/******************************************************************************
120* End of Function:     get_Olympus_Makernote
121******************************************************************************/
122
123
124
125
126
127
128
129/******************************************************************************
130*
131* Function:     get_Olympus_Text_Value
132*
133* Description:  Provides a text value for any tag marked as special for makernotes
134*               that this script can decode. Returns false if this is not a makernote
135*               that can be processed with this script
136*
137* Parameters:   Exif_Tag - the element of an the Makernote array containing the
138*                          tag in question, as returned from get_Olympus_Makernote
139*               Tag_Definitions_Name - The name of the Tag Definitions group
140*                                      within the global array IFD_Tag_Definitions
141*
142*
143* Returns:      output - the text value for the tag
144*               FALSE - If this script could not decode the makernote, or if
145*                       an error occured in decoding
146*
147******************************************************************************/
148
149function get_Olympus_Text_Value( $Exif_Tag, $Tag_Definitions_Name )
150{
151        // Check that this tag uses the Olympus tags, otherwise it can't be decoded here
152        if ( $Tag_Definitions_Name !== "Olympus" )
153        {
154                // Not an Olympus tag - can't decode it
155                return FALSE;
156        }
157
158
159        // Process the tag acording to it's tag number, to produce a text value
160        if ( $Exif_Tag['Tag Number'] == 0x200 )
161        {
162                // Special Mode Tag
163
164                // Add info from the first value to the output string
165                switch ( $Exif_Tag['Data'][0] )
166                {
167                        case 0: $outputstr = "Normal\n";
168                                break;
169                        case 2: $outputstr = "Fast\n";
170                                break;
171                        case 3: $outputstr = "Panorama\n";
172                                break;
173                        default: $outputstr = "Unknown Mode ( " . $Exif_Tag['Data'][0] . " )\n";
174                                        break;
175                }
176
177                // Add info from the second value to the output string
178                $outputstr .= "Sequence Number: " . $Exif_Tag['Data'][1] . "\n";
179
180                // Add info from the third value to the output string
181                switch ( $Exif_Tag['Data'][2] )
182                {
183                        case 0: // Do nothing
184                                break;
185                        case 1: $outputstr .= "Panorama Direction: Left to Right\n";
186                                break;
187                        case 2: $outputstr .= "Panorama Direction: Right to Left\n";
188                                break;
189                        case 3: $outputstr .= "Panorama Direction: Bottom to Top\n";
190                                break;
191                        case 4: $outputstr .= "Panorama Direction: Top to Bottom\n";
192                                break;
193                        default: $outputstr .= "Unknown Panorama Direction\n";
194                                        break;
195                }
196
197                // Return the output string
198                return $outputstr;
199        }
200        else
201        {
202                // Unknown special tag - can't process it here
203                return FALSE;
204        }
205
206        // Unknown special tag - can't process it here
207        return FALSE;
208
209}
210
211/******************************************************************************
212* End of Function:     get_Olympus_Text_Value
213******************************************************************************/
214
215
216
217
218/******************************************************************************
219*
220* Function:     get_Olympus_Makernote_Html
221*
222* Description:  Attempts to interpret a makernote into html. Returns false if
223*               it is not a makernote that can be processed with this script
224*
225* Parameters:   Makernote_Tag - the element of an EXIF array containing the
226*                               makernote, as returned from get_EXIF_JPEG
227*               filename - the name of the JPEG file being processed ( used
228*                          by scripts which display embedded thumbnails)
229*
230*
231* Returns:      output - the html representing the makernote
232*               FALSE - If this script could not interpret the makernote, or if
233*                       an error occured in decoding
234*
235******************************************************************************/
236
237function get_Olympus_Makernote_Html( $Makernote_tag, $filename )
238{
239
240        // Check that this tag uses the Olympus tags, otherwise it can't be interpreted here
241        if ( $Makernote_tag['Makernote Tags'] != "Olympus" )
242        {
243                // Not Olympus tags - can't interpret with this function
244                return FALSE;
245        }
246
247        // Check if the Decoded data is valid
248        if ( $Makernote_tag['Decoded Data'][0] === FALSE )
249        {
250                // Decoded data is not valid - can't interpret with this function
251                return FALSE;
252        }
253
254        // Minolta Thumbnail 1
255        if ( ( array_key_exists( 0x0088, $Makernote_tag['Decoded Data'][0] ) ) &&
256             ( $Makernote_tag['Makernote Tags'] == "Olympus" ) )
257        {
258                // Change: as of version 1.11 - Changed to make thumbnail link portable across directories
259                // Build the path of the thumbnail script and its filename parameter to put in a url
260                $link_str = get_relative_path( dirname(__FILE__)  . "/../get_minolta_thumb.php" , getcwd ( ) );
261                $link_str .= "?filename=";
262                $link_str .= get_relative_path( $filename, dirname(__FILE__) ."/.." );
263
264                // Add thumbnail link to html
265                $Makernote_tag['Decoded Data'][0][0x0088]['Text Value'] = "<a class=\"EXIF_Minolta_Thumb_Link\" href=\"$link_str\" ><img class=\"EXIF_Minolta_Thumb\" src=\"$link_str\"></a>";
266
267                $Makernote_tag['Decoded Data'][0][0x0088]['Type'] = "String";
268        }
269        // Minolta Thumbnail 2
270        if ( ( array_key_exists( 0x0081, $Makernote_tag['Decoded Data'][0] ) ) &&
271             ( $Makernote_tag['Makernote Tags'] == "Olympus" ) )
272        {
273                // Change: as of version 1.11 - Changed to make thumbnail link portable across directories
274                // Build the path of the thumbnail script and its filename parameter to put in a url
275                $link_str = get_relative_path( dirname(__FILE__) . " /../get_minolta_thumb.php" , getcwd ( ) );
276                $link_str .= "?filename=";
277                $link_str .= get_relative_path( $filename, dirname(__FILE__) ."/.." );
278
279                // Add thumbnail link to html
280                $Makernote_tag['Decoded Data'][0][0x0081]['Text Value'] = "<a class=\"EXIF_Minolta_Thumb_Link\" href=\"$link_str\" ><img class=\"EXIF_Minolta_Thumb\" src=\"$link_str\"></a>";
281                $Makernote_tag['Decoded Data'][0][0x0081]['Type'] = "String";
282        }
283
284        // Interpret the IFD and return the HTML
285        return interpret_IFD( $Makernote_tag['Decoded Data'][0], $filename );
286
287}
288
289/******************************************************************************
290* End of Function:     get_Olympus_Makernote_Html
291******************************************************************************/
292
293
294
295
296
297
298
299
300
301
302
303
304/******************************************************************************
305* Global Variable:      IFD_Tag_Definitions, Olympus
306*
307* Contents:     This global variable provides definitions of the known Olympus
308*               Makernote tags, indexed by their tag number.
309*               It also includes Minolta and Agfa tags, as they use many of the
310*               same tags
311*
312******************************************************************************/
313
314$GLOBALS[ "IFD_Tag_Definitions" ]["Olympus"] = array(
315
3160x0000 => array( 'Name' => "Makernote Version",           // Minolta
317                 'Type' => "String" ),
318
3190x0001 => array( 'Name' => "Camera Settings",           // Minolta
320                 'Type' => "Special" ),
321
3220x0003 => array( 'Name' => "Camera Settings",           // Minolta
323                 'Type' => "Special" ),
324
3250x0040 => array( 'Name' => "Compressed Image Size",           // Minolta
326                 'Type' => "Numeric",
327                 'Units' => "Bytes" ),
328
3290x0081 => array( 'Name' => "Minolta Thumbnail",           // Minolta
330                 'Type' => "Special" ),
331
3320x0088 => array( 'Name' => "Minolta Thumbnail",           // Minolta
333                 'Type' => "Special" ),
334
3350x0089 => array( 'Name' => "Minolta Thumbnail Length",           // Minolta
336                 'Type' => "Numeric",
337                 'Units' => "bytes" ),
338
3390x0101 => array( 'Name' => "Colour Mode",           // Minolta
340                 'Type' => "Lookup",
341                 0 => "Natural Colour",
342                 1 => "Black & White",
343                 2 => "Vivid colour",
344                 3 => "Solarization",
345                 4 => "AdobeRGB" ),
346
3470x0102 => array( 'Name' => "Image Quality",           // Minolta
348                 'Type' => "Lookup",
349                 0 => "Raw",
350                 1 => "Super Fine",
351                 2 => "Fine",
352                 3 => "Standard",
353                 4 => "Extra Fine" ),
354
3550x0103 => array( 'Name' => "Image Quality?",           // Minolta
356                 'Type' => "Lookup",
357                 0 => "Raw",
358                 1 => "Super Fine",
359                 2 => "Fine",
360                 3 => "Standard",
361                 4 => "Extra Fine" ),
362
363
364
3650x0200 => array( 'Name' => "Special Mode",
366                'Type' => "Special" ),
367
368
3690x0201 => array( 'Name' => "JPEG Quality",
370                 'Type' => "Lookup",
371                 1 => "Standard Quality",
372                 2 => "High Quality",
373                 3 => "Super High Quality" ),
374
3750x0202 => array( 'Name' => "Macro",
376                 'Type' => "Lookup",
377                 0 => "Normal (Not Macro)",
378                 1 => "Macro" ),
379
3800x0204 => array( 'Name' => "Digital Zoom",
381                 'Type' => "Numeric",
382                 'Units' => " x Digital Zoom, (0 or 1 = normal)" ),
383
3840x0207 => array( 'Name' => "Firmware Version",
385                'Type' => "String" ),
386
387
3880x0208 => array( 'Name' => "Picture Info Data",
389                'Type' => "String" ),
390
3910x0209 => array( 'Name' => "Camera ID",
392                'Type' => "String" ),
393
394
3950x020B => array( 'Name' => "Image Width",        // Epson Tag
396                'Type' => "Pixels" ),
397
3980x020C => array( 'Name' => "Image Height",        // Epson Tag
399                'Type' => "Pixels" ),
400
4010x020D => array( 'Name' => "Original Manufacturer Model?",        // Epson Tag
402                'Type' => "String" ),
403
4040x0E00 => array( 'Name'=> "Print Image Matching Info",     // Minolta Tag
405                 'Type' => "PIM" ),
406
4070x1004 => array( 'Name' => "Flash Mode",
408                 'Type' => "Numeric" ),
409
4100x1006 => array( 'Name' => "Bracket",
411                 'Type' => "Numeric" ),
412
4130x100B => array( 'Name' => "Focus Mode",
414                 'Type' => "Numeric" ),
415
4160x100C => array( 'Name' => "Focus Distance",
417                 'Type' => "Numeric" ),
418
4190x100D => array( 'Name' => "Zoom",
420                 'Type' => "Numeric" ),
421
4220x100E => array( 'Name' => "Macro Focus",
423                 'Type' => "Numeric" ),
424
4250x100F => array( 'Name' => "Sharpness",
426                 'Type' => "Numeric" ),
427
4280x1011 => array( 'Name' => "Colour Matrix",
429                 'Type' => "Numeric" ),
430
4310x1012 => array( 'Name' => "Black Level",
432                 'Type' => "Numeric" ),
433
4340x1015 => array( 'Name' => "White Balance",
435                 'Type' => "Numeric" ),
436
4370x1017 => array( 'Name' => "Red Bias",
438                 'Type' => "Numeric" ),
439
4400x1018 => array( 'Name' => "Blue Bias",
441                 'Type' => "Numeric" ),
442
4430x101A => array( 'Name' => "Serial Number",
444                 'Type' => "Numeric" ),
445
4460x1023 => array( 'Name' => "Flash Bias",
447                 'Type' => "Numeric" ),
448
4490x1029 => array( 'Name' => "Contrast",
450                 'Type' => "Numeric" ),
451
4520x102A => array( 'Name' => "Sharpness Factor",
453                 'Type' => "Numeric" ),
454
4550x102B => array( 'Name' => "Colour Control",
456                 'Type' => "Numeric" ),
457
4580x102C => array( 'Name' => "Valid Bits",
459                 'Type' => "Numeric" ),
460
4610x102D => array( 'Name' => "Coring Filter",
462                 'Type' => "Numeric" ),
463
4640x102E => array( 'Name' => "Final Width",
465                 'Type' => "Numeric" ),
466
4670x102F => array( 'Name' => "Final Height",
468                 'Type' => "Numeric" ),
469
4700x1034 => array( 'Name' => "Compression Ratio",
471                 'Type' => "Numeric" ),
472
473
474
475);
476
477
478/******************************************************************************
479* End of Global Variable:     IFD_Tag_Definitions, Olympus
480******************************************************************************/
481
482
483
484
485
486?>
Note: See TracBrowser for help on using the repository browser.