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

Last change on this file since 9412 was 9412, checked in by cljosse, 13 years ago
File size: 8.5 KB
Line 
1<?php
2
3/******************************************************************************
4*
5* Filename:     sony.php
6*
7* Description:  Sony Makernote Parser
8*               Provides functions to decode an Sony EXIF makernote and to interpret
9*               the resulting array into html.
10*
11*               Sony Makernote Format:
12*
13*               Field           Size            Description
14*               ----------------------------------------------------------------
15*               Header          12 Bytes        "SONY CAM \x00\x00\x00"
16*                                               or
17*                                               "SONY DSC \x00\x00\x00"
18*               IFD Data        Variable        NON-Standard IFD Data using Sony Tags
19*                                               IFD has no Next-IFD pointer at end of IFD,
20*               ----------------------------------------------------------------
21*
22*
23* Author:      Evan Hunter
24*
25* Date:         30/7/2004
26*
27* Project:      JPEG Metadata
28*
29* Revision:     1.00
30*
31* URL:          http://electronics.ozhiker.com
32*
33* Copyright:    Copyright " . $auteur . " 2004
34*               This file may be used freely for non-commercial purposes.For
35*               commercial uses please contact the author: evan@ozhiker.com
36*
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_Sony_Makernote";
45$GLOBALS['Makernote_Function_Array']['get_Makernote_Text_Value'][] = "get_Sony_Text_Value";
46$GLOBALS['Makernote_Function_Array']['Interpret_Makernote_to_HTML'][] = "get_Sony_Makernote_Html";
47
48
49
50
51
52/******************************************************************************
53*
54* Function:     get_Sony_Makernote
55*
56* Description:  Decodes the Makernote tag and returns the new tag with the decoded
57*               information attached. Returns false if this is not a makernote
58*               that can be processed with this script
59*
60* Parameters:   Makernote_Tag - the element of an EXIF array containing the
61*                               makernote, as returned from get_EXIF_JPEG
62*               EXIF_Array - the entire EXIF array containing the
63*                            makernote, as returned from get_EXIF_JPEG, in
64*                            case more information is required for decoding
65*               filehnd - an open file handle for the file containing the
66*                         makernote - does not have to be positioned at the
67*                         start of the makernote
68*               Make_Field - The contents of the EXIF Make field, to aid
69*                            determining whether this script can decode
70*                            the makernote
71*
72*
73* Returns:      Makernote_Tag - the Makernote_Tag from the parameters, but
74*                               modified to contain the decoded information
75*               FALSE - If this script could not decode the makernote, or if
76*                       an error occured in decoding
77*
78******************************************************************************/
79
80function get_Sony_Makernote( $Makernote_Tag, $EXIF_Array, $filehnd, $Make_Field )
81{
82
83        // Check if the Make Field contains the word Sony
84        if ( stristr( $Make_Field, "Sony" ) === FALSE )
85        {
86                // This isn't a Sony makernote
87                return FALSE;
88        }
89               
90        // Check if the header exists at the start of the Makernote
91        if ( ( substr( $Makernote_Tag['Data'], 0, 12 ) != "SONY CAM \x00\x00\x00" ) &&
92             ( substr( $Makernote_Tag['Data'], 0, 12 ) != "SONY DSC \x00\x00\x00" ) )
93        {
94                // This isn't a Sony Makernote, abort
95                return FALSE ;
96        }
97
98        // Seek to the start of the IFD
99        fseek($filehnd, $Makernote_Tag['Tiff Offset'] + $Makernote_Tag['Offset'] + 12 );
100
101        // Read the IFD(s) into an array
102
103
104        $Makernote_Tag['Decoded Data'] = read_Multiple_IFDs( $filehnd, $Makernote_Tag['Tiff Offset'], $Makernote_Tag['ByteAlign'], "Sony", FALSE, FALSE );
105
106        // Save some information into the Tag element to aid interpretation
107        $Makernote_Tag['Decoded'] = TRUE;
108        $Makernote_Tag['Makernote Type'] = "Sony";
109        $Makernote_Tag['Makernote Tags'] = "sony";
110
111
112        // Return the new tag
113        return $Makernote_Tag;
114
115
116}
117
118/******************************************************************************
119* End of Function:     get_Sony_Makernote
120******************************************************************************/
121
122
123
124
125
126
127/******************************************************************************
128*
129* Function:     get_Sony_Text_Value
130*
131* Description:  Provides a text value for any tag marked as special for makernotes
132*               that this script can decode. Returns false if this is not a makernote
133*               that can be processed with this script
134*
135* Parameters:   Exif_Tag - the element of an the Makernote array containing the
136*                          tag in question, as returned from get_Sony_Makernote
137*               Tag_Definitions_Name - The name of the Tag Definitions group
138*                                      within the global array IFD_Tag_Definitions
139*
140*
141* Returns:      output - the text value for the tag
142*               FALSE - If this script could not decode the makernote, or if
143*                       an error occured in decoding
144*
145******************************************************************************/
146
147function get_Sony_Text_Value( $Exif_Tag, $Tag_Definitions_Name )
148{
149        // Check that this tag uses the Sony tags, otherwise it can't be decoded here
150        if ( $Tag_Definitions_Name == "Sony" )
151        {
152                // No Special Tags yet
153                return FALSE;
154        }
155
156        return FALSE;
157}
158
159/******************************************************************************
160* End of Function:     get_Sony_Text_Value
161******************************************************************************/
162
163
164
165
166
167
168/******************************************************************************
169*
170* Function:     get_Sony_Makernote_Html
171*
172* Description:  Attempts to interpret a makernote into html. Returns false if
173*               it is not a makernote that can be processed with this script
174*
175* Parameters:   Makernote_Tag - the element of an EXIF array containing the
176*                               makernote, as returned from get_EXIF_JPEG
177*               filename - the name of the JPEG file being processed ( used
178*                          by scripts which display embedded thumbnails)
179*
180*
181* Returns:      output - the html representing the makernote
182*               FALSE - If this script could not interpret the makernote, or if
183*                       an error occured in decoding
184*
185******************************************************************************/
186
187function get_Sony_Makernote_Html( $Makernote_tag, $filename )
188{
189
190        // Check that this tag uses the Sony tags, otherwise it can't be interpreted here
191        if ( $Makernote_tag['Makernote Type'] != "Sony" )
192        {
193                // Not Sony tags - can't interpret with this function
194                return FALSE;
195        }
196
197        // Interpret the IFD and return the HTML
198        return interpret_IFD( $Makernote_tag['Decoded Data'][0], $filename );
199
200}
201
202/******************************************************************************
203* End of Function:     get_Sony_Makernote_Html
204******************************************************************************/
205
206
207
208
209
210
211
212
213
214
215/******************************************************************************
216* Global Variable:      IFD_Tag_Definitions, Sony
217*
218* Contents:     This global variable provides definitions of the known Sony
219*               Makernote tags, indexed by their tag number.
220*
221******************************************************************************/
222
223$GLOBALS[ "IFD_Tag_Definitions" ]["Sony"] = array(
224
2250xE00 => array( 'Name' => "Print Image Matching Info",
226                'Type' => "PIM" ),
227
228);
229
230/******************************************************************************
231* End of Global Variable:     IFD_Tag_Definitions, Sony
232******************************************************************************/
233
234
235
236
237
238
239
240
241
242
243
244?>
Note: See TracBrowser for help on using the repository browser.