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