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

Last change on this file since 9412 was 9412, checked in by cljosse, 13 years ago
File size: 10.1 KB
Line 
1<?php
2
3/******************************************************************************
4*
5* Filename:     panasonic.php
6*
7* Description:  Panasonic Makernote Parser
8*               Provides functions to decode a Panasonic EXIF makernote and to interpret
9*               the resulting array into html.
10*
11*               Panasonic Makernote Format:
12*
13*               Type 1  - IFD form
14*
15*               Field           Size            Description
16*               ----------------------------------------------------------------
17*               Header          12 Bytes        "Panasonic\x00\x00\x00"
18*               IFD Data        Variable        NON-Standard IFD Data using Panasonic Tags
19*                                               There is no Next-IFD pointer after the IFD
20*               ----------------------------------------------------------------
21*
22*               Type 2  - Blank (Header only)
23*
24*               Field           Size            Description
25*               ----------------------------------------------------------------
26*               Header          4 Bytes         "MKED"
27*               Junk            1 or 2 bytes    Blank or Junk data
28*               ----------------------------------------------------------------
29*
30*
31* Author:      Evan Hunter
32*
33* Date:         30/7/2004
34*
35* Project:      JPEG Metadata
36*
37* Revision:     1.00
38*
39* URL:          http://electronics.ozhiker.com
40*
41* Copyright:    Copyright " . $auteur . " 2004
42*               This file may be used freely for non-commercial purposes.For
43*               commercial uses please contact the author: evan@ozhiker.com
44*
45******************************************************************************/
46
47
48
49// Add the parser and interpreter functions to the list of Makernote parsers and interpreters.
50
51$GLOBALS['Makernote_Function_Array']['Read_Makernote_Tag'][] = "get_Panasonic_Makernote";
52$GLOBALS['Makernote_Function_Array']['get_Makernote_Text_Value'][] = "get_Panasonic_Text_Value";
53$GLOBALS['Makernote_Function_Array']['Interpret_Makernote_to_HTML'][] = "get_Panasonic_Makernote_Html";
54
55
56
57
58/******************************************************************************
59*
60* Function:     get_Panasonic_Makernote
61*
62* Description:  Decodes the Makernote tag and returns the new tag with the decoded
63*               information attached. Returns false if this is not a makernote
64*               that can be processed with this script
65*
66* Parameters:   Makernote_Tag - the element of an EXIF array containing the
67*                               makernote, as returned from get_EXIF_JPEG
68*               EXIF_Array - the entire EXIF array containing the
69*                            makernote, as returned from get_EXIF_JPEG, in
70*                            case more information is required for decoding
71*               filehnd - an open file handle for the file containing the
72*                         makernote - does not have to be positioned at the
73*                         start of the makernote
74*               Make_Field - The contents of the EXIF Make field, to aid
75*                            determining whether this script can decode
76*                            the makernote
77*
78*
79* Returns:      Makernote_Tag - the Makernote_Tag from the parameters, but
80*                               modified to contain the decoded information
81*               FALSE - If this script could not decode the makernote, or if
82*                       an error occured in decoding
83*
84******************************************************************************/
85
86function get_Panasonic_Makernote( $Makernote_Tag, $EXIF_Array, $filehnd, $Make_Field )
87{
88        // Check if the Make Field contains the word Panasonic
89        if ( stristr( $Make_Field, "Panasonic" ) === FALSE )
90        {
91                // No Panasonic in the maker - abort
92                return FALSE;
93        }
94       
95
96        // Check if the header exists at the start of the Makernote
97        if ( substr( $Makernote_Tag['Data'], 0, 4 ) == "MKED" )
98        {
99                // Panasonic Type 2 - Empty Makernote
100                // No Makernote Data
101                $Makernote_Tag['Makernote Type'] = "Panasonic Empty Makernote";
102                $Makernote_Tag['Makernote Tags'] = "-";
103                $Makernote_Tag['Decoded'] = TRUE;
104               
105                // Return the new tag
106                return $Makernote_Tag;
107        }
108        else if ( substr( $Makernote_Tag['Data'], 0, 12 ) == "Panasonic\x00\x00\x00" )
109        {
110                // Panasonic Type 1 - IFD Makernote
111
112                // Seek to the start of the IFD
113                fseek($filehnd, $Makernote_Tag['Tiff Offset'] + $Makernote_Tag['Offset'] + 12 );
114
115                // Read the IFD(s) into an array
116                $Makernote_Tag['Decoded Data'] = read_Multiple_IFDs( $filehnd, $Makernote_Tag['Tiff Offset'], $Makernote_Tag['ByteAlign'], "Panasonic", FALSE, FALSE );
117
118                // Save some information into the Tag element to aid interpretation
119                $Makernote_Tag['Decoded'] = TRUE;
120                $Makernote_Tag['Makernote Type'] = "Panasonic";
121                $Makernote_Tag['Makernote Tags'] = "Panasonic";
122
123                // Return the new tag
124                return $Makernote_Tag;
125        }
126        else
127        {
128                // Unknown Header
129                return FALSE;
130        }
131
132        // Shouldn't get here
133        return FALSE;
134}
135
136/******************************************************************************
137* End of Function:     get_Panasonic_Makernote
138******************************************************************************/
139
140
141
142
143
144
145
146
147
148
149/******************************************************************************
150*
151* Function:     get_Panasonic_Text_Value
152*
153* Description:  Provides a text value for any tag marked as special for makernotes
154*               that this script can decode. Returns false if this is not a makernote
155*               that can be processed with this script
156*
157* Parameters:   Exif_Tag - the element of an the Makernote array containing the
158*                          tag in question, as returned from get_Panasonic_Makernote
159*               Tag_Definitions_Name - The name of the Tag Definitions group
160*                                      within the global array IFD_Tag_Definitions
161*
162*
163* Returns:      output - the text value for the tag
164*               FALSE - If this script could not decode the makernote, or if
165*                       an error occured in decoding
166*
167******************************************************************************/
168
169function get_Panasonic_Text_Value( $Exif_Tag, $Tag_Definitions_Name )
170{
171
172        // Check that this tag uses the Olympus tags, otherwise it can't be decoded here
173        if ( $Tag_Definitions_Name == "Panasonic" )
174        {
175                // No Special Tags yet
176                return FALSE;
177        }
178       
179        return FALSE;
180}
181
182/******************************************************************************
183* End of Function:     get_Panasonic_Text_Value
184******************************************************************************/
185
186
187
188
189
190
191
192
193
194
195/******************************************************************************
196*
197* Function:     get_Panasonic_Makernote_Html
198*
199* Description:  Attempts to interpret a makernote into html. Returns false if
200*               it is not a makernote that can be processed with this script
201*
202* Parameters:   Makernote_Tag - the element of an EXIF array containing the
203*                               makernote, as returned from get_EXIF_JPEG
204*               filename - the name of the JPEG file being processed ( used
205*                          by scripts which display embedded thumbnails)
206*
207*
208* Returns:      output - the html representing the makernote
209*               FALSE - If this script could not interpret the makernote, or if
210*                       an error occured in decoding
211*
212******************************************************************************/
213
214function get_Panasonic_Makernote_Html( $Makernote_tag, $filename )
215{
216        if ( $Makernote_tag['Makernote Type'] == "Panasonic" )
217        {
218                return interpret_IFD( $Makernote_tag['Decoded Data'][0], $filename );
219        }
220        else if ( $Makernote_tag['Makernote Type'] == "Panasonic Empty Makernote" )
221        {
222                // Do Nothing
223                return "";
224        }
225        else
226        {
227                // Unknown Makernote Type
228                return FALSE;
229        }
230
231        // Shouldn't get here
232        return FALSE;
233}
234
235/******************************************************************************
236* End of Function:     get_Panasonic_Makernote_Html
237******************************************************************************/
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252/******************************************************************************
253* Global Variable:      IFD_Tag_Definitions, Panasonic
254*
255* Contents:     This global variable provides definitions of the known Panasonic
256*               Makernote tags, indexed by their tag number.
257*
258******************************************************************************/
259
260$GLOBALS[ "IFD_Tag_Definitions" ]["Panasonic"] = array(
261
2620x01 => array(  'Name' => "Quality Mode",
263                'Type' => "Numeric" ),
264
2650x02 => array(  'Name' => "Version",
266                'Type' => "String" ),
267
2680x1c => array(  'Name' => "Macro Mode",
269                'Type' => "Lookup",
270                1 => "On",
271                2 => "Off" ),
272
2730x1f => array(  'Name' => "Record Mode",
274                'Type' => "Lookup",
275                1 => "Normal",
276                2 => "Portrait",
277                9 => "Macro" ),
278
2790xE00 => array( 'Name' => "Print Image Matching Info",
280                'Type' => "PIM" ),
281
282);
283
284/******************************************************************************
285* End of Global Variable:     IFD_Tag_Definitions, Panasonic
286******************************************************************************/
287
288
289
290
291
292?>
Note: See TracBrowser for help on using the repository browser.