1 | <?php |
---|
2 | |
---|
3 | /****************************************************************************** |
---|
4 | * |
---|
5 | * Filename: pentax.php |
---|
6 | * |
---|
7 | * Description: Pentax (Asahi) Makernote Parser |
---|
8 | * Provides functions to decode an Pentax (Asahi) EXIF makernote and to interpret |
---|
9 | * the resulting array into html. |
---|
10 | * |
---|
11 | * Pentax Makernote Format: |
---|
12 | * |
---|
13 | * Type 1 |
---|
14 | * |
---|
15 | * Field Size Description |
---|
16 | * ---------------------------------------------------------------- |
---|
17 | * IFD Data Variable NON-Standard IFD Data using Pentax Tags |
---|
18 | * IFD has no Next-IFD pointer at end of IFD, |
---|
19 | * and Offsets are relative to the start |
---|
20 | * of the current IFD tag, not the TIFF header |
---|
21 | * ---------------------------------------------------------------- |
---|
22 | * |
---|
23 | * |
---|
24 | * Type 2 |
---|
25 | * |
---|
26 | * Field Size Description |
---|
27 | * ---------------------------------------------------------------- |
---|
28 | * Header 4 Bytes "AOC\x00" |
---|
29 | * Unknown 2 Bytes Unknown field |
---|
30 | * IFD Data Variable NON-Standard IFD Data using Casio Type 2 Tags |
---|
31 | * IFD has no Next-IFD pointer at end of IFD, |
---|
32 | * and Offsets are relative to the start |
---|
33 | * of the current IFD tag, not the TIFF header |
---|
34 | * ---------------------------------------------------------------- |
---|
35 | * |
---|
36 | * |
---|
37 | * |
---|
38 | * Author: Evan Hunter |
---|
39 | * |
---|
40 | * Date: 30/7/2004 |
---|
41 | * |
---|
42 | * Project: JPEG Metadata |
---|
43 | * |
---|
44 | * Revision: 1.00 |
---|
45 | * |
---|
46 | * URL: http://electronics.ozhiker.com |
---|
47 | * |
---|
48 | * Copyright: Copyright " . $auteur . " 2004 |
---|
49 | * This file may be used freely for non-commercial purposes.For |
---|
50 | * commercial uses please contact the author: evan@ozhiker.com |
---|
51 | * |
---|
52 | ******************************************************************************/ |
---|
53 | |
---|
54 | |
---|
55 | // Pentax Type 2 makernote uses Casio Type 2 tags - ensure they are included |
---|
56 | |
---|
57 | include_once 'casio.php'; |
---|
58 | |
---|
59 | |
---|
60 | |
---|
61 | // Add the parser and interpreter functions to the list of Makernote parsers and interpreters. |
---|
62 | |
---|
63 | $GLOBALS['Makernote_Function_Array']['Read_Makernote_Tag'][] = "get_Pentax_Makernote"; |
---|
64 | $GLOBALS['Makernote_Function_Array']['get_Makernote_Text_Value'][] = "get_Pentax_Text_Value"; |
---|
65 | $GLOBALS['Makernote_Function_Array']['Interpret_Makernote_to_HTML'][] = "get_Pentax_Makernote_Html"; |
---|
66 | |
---|
67 | |
---|
68 | |
---|
69 | |
---|
70 | |
---|
71 | |
---|
72 | |
---|
73 | /****************************************************************************** |
---|
74 | * |
---|
75 | * Function: get_Pentax_Makernote |
---|
76 | * |
---|
77 | * Description: Decodes the Makernote tag and returns the new tag with the decoded |
---|
78 | * information attached. Returns false if this is not a makernote |
---|
79 | * that can be processed with this script |
---|
80 | * |
---|
81 | * Parameters: Makernote_Tag - the element of an EXIF array containing the |
---|
82 | * makernote, as returned from get_EXIF_JPEG |
---|
83 | * EXIF_Array - the entire EXIF array containing the |
---|
84 | * makernote, as returned from get_EXIF_JPEG, in |
---|
85 | * case more information is required for decoding |
---|
86 | * filehnd - an open file handle for the file containing the |
---|
87 | * makernote - does not have to be positioned at the |
---|
88 | * start of the makernote |
---|
89 | * Make_Field - The contents of the EXIF Make field, to aid |
---|
90 | * determining whether this script can decode |
---|
91 | * the makernote |
---|
92 | * |
---|
93 | * |
---|
94 | * Returns: Makernote_Tag - the Makernote_Tag from the parameters, but |
---|
95 | * modified to contain the decoded information |
---|
96 | * FALSE - If this script could not decode the makernote, or if |
---|
97 | * an error occured in decoding |
---|
98 | * |
---|
99 | ******************************************************************************/ |
---|
100 | |
---|
101 | function get_Pentax_Makernote( $Makernote_Tag, $EXIF_Array, $filehnd, $Make_Field ) |
---|
102 | { |
---|
103 | // Check if the Make Field contains the word Pentax or Asahi |
---|
104 | if ( ( stristr( $Make_Field, "Pentax" ) === FALSE ) && |
---|
105 | ( stristr( $Make_Field, "Asahi" ) === FALSE ) ) |
---|
106 | { |
---|
107 | // Couldn't find Pentax or Asahi in the maker - abort |
---|
108 | return FALSE; |
---|
109 | } |
---|
110 | |
---|
111 | // Check if the header exists at the start of the Makernote |
---|
112 | if ( substr( $Makernote_Tag['Data'], 0, 4 ) == "AOC\x00" ) |
---|
113 | { |
---|
114 | // Type 2 Pentax Makernote |
---|
115 | |
---|
116 | // Seek to the start of the IFD |
---|
117 | fseek($filehnd, $Makernote_Tag['Tiff Offset'] + $Makernote_Tag['Offset'] + 6 ); |
---|
118 | |
---|
119 | // Read the IFD(s) into an array |
---|
120 | $Makernote_Tag['Decoded Data'] = read_Multiple_IFDs( $filehnd, $Makernote_Tag['Tiff Offset'], $Makernote_Tag['ByteAlign'], "Casio Type 2" ); |
---|
121 | |
---|
122 | // Save some information into the Tag element to aid interpretation |
---|
123 | $Makernote_Tag['Decoded'] = TRUE; |
---|
124 | $Makernote_Tag['Makernote Type'] = "Casio Type 2"; |
---|
125 | $Makernote_Tag['Makernote Tags'] = "Casio Type 2"; |
---|
126 | |
---|
127 | // Return the new tag |
---|
128 | return $Makernote_Tag; |
---|
129 | } |
---|
130 | else |
---|
131 | { |
---|
132 | // Type 1 Penax Makernote |
---|
133 | |
---|
134 | // Seek to the start of the IFD |
---|
135 | fseek($filehnd, $Makernote_Tag['Tiff Offset'] + $Makernote_Tag['Offset'] + 0 ); |
---|
136 | |
---|
137 | // Read the IFD(s) into an array |
---|
138 | $Makernote_Tag['Decoded Data'] = read_Multiple_IFDs( $filehnd, $Makernote_Tag['Tiff Offset'], $Makernote_Tag['ByteAlign'], "Pentax" ); |
---|
139 | |
---|
140 | // Save some information into the Tag element to aid interpretation |
---|
141 | $Makernote_Tag['Decoded'] = TRUE; |
---|
142 | $Makernote_Tag['Makernote Type'] = "Pentax"; |
---|
143 | $Makernote_Tag['Makernote Tags'] = "Pentax"; |
---|
144 | |
---|
145 | // Return the new tag |
---|
146 | return $Makernote_Tag; |
---|
147 | } |
---|
148 | |
---|
149 | |
---|
150 | // Shouldn't get here |
---|
151 | return FALSE; |
---|
152 | } |
---|
153 | |
---|
154 | /****************************************************************************** |
---|
155 | * End of Function: get_Pentax_Makernote |
---|
156 | ******************************************************************************/ |
---|
157 | |
---|
158 | |
---|
159 | |
---|
160 | |
---|
161 | |
---|
162 | |
---|
163 | |
---|
164 | /****************************************************************************** |
---|
165 | * |
---|
166 | * Function: get_Pentax_Text_Value |
---|
167 | * |
---|
168 | * Description: Provides a text value for any tag marked as special for makernotes |
---|
169 | * that this script can decode. Returns false if this is not a makernote |
---|
170 | * that can be processed with this script |
---|
171 | * |
---|
172 | * Parameters: Exif_Tag - the element of an the Makernote array containing the |
---|
173 | * tag in question, as returned from get_Pentax_Makernote |
---|
174 | * Tag_Definitions_Name - The name of the Tag Definitions group |
---|
175 | * within the global array IFD_Tag_Definitions |
---|
176 | * |
---|
177 | * |
---|
178 | * Returns: output - the text value for the tag |
---|
179 | * FALSE - If this script could not decode the makernote, or if |
---|
180 | * an error occured in decoding |
---|
181 | * |
---|
182 | ******************************************************************************/ |
---|
183 | |
---|
184 | function get_Pentax_Text_Value( $Exif_Tag, $Tag_Definitions_Name ) |
---|
185 | { |
---|
186 | // Check that this tag uses the Pentax tags, otherwise it can't be interpreted here |
---|
187 | if ( $Tag_Definitions_Name == "Pentax" ) |
---|
188 | { |
---|
189 | // No Special Tags so far |
---|
190 | return FALSE; |
---|
191 | } |
---|
192 | |
---|
193 | return FALSE; |
---|
194 | } |
---|
195 | |
---|
196 | /****************************************************************************** |
---|
197 | * End of Function: get_Pentax_Text_Value |
---|
198 | ******************************************************************************/ |
---|
199 | |
---|
200 | |
---|
201 | |
---|
202 | |
---|
203 | |
---|
204 | |
---|
205 | /****************************************************************************** |
---|
206 | * |
---|
207 | * Function: get_Pentax_Makernote_Html |
---|
208 | * |
---|
209 | * Description: Attempts to interpret a makernote into html. Returns false if |
---|
210 | * it is not a makernote that can be processed with this script |
---|
211 | * |
---|
212 | * Parameters: Makernote_Tag - the element of an EXIF array containing the |
---|
213 | * makernote, as returned from get_EXIF_JPEG |
---|
214 | * filename - the name of the JPEG file being processed ( used |
---|
215 | * by scripts which display embedded thumbnails) |
---|
216 | * |
---|
217 | * |
---|
218 | * Returns: output - the html representing the makernote |
---|
219 | * FALSE - If this script could not interpret the makernote, or if |
---|
220 | * an error occured in decoding |
---|
221 | * |
---|
222 | ******************************************************************************/ |
---|
223 | |
---|
224 | function get_Pentax_Makernote_Html( $Makernote_tag, $filename ) |
---|
225 | { |
---|
226 | // Check that this is a Pentax type makernote |
---|
227 | if ( $Makernote_tag['Makernote Type'] != "Pentax" ) |
---|
228 | { |
---|
229 | // Not a Pentax makernote - abort |
---|
230 | return False; |
---|
231 | } |
---|
232 | |
---|
233 | // Interpret the IFD and return the html |
---|
234 | return interpret_IFD( $Makernote_tag['Decoded Data'][0], $filename ); |
---|
235 | |
---|
236 | } |
---|
237 | |
---|
238 | /****************************************************************************** |
---|
239 | * End of Function: get_Pentax_Makernote_Html |
---|
240 | ******************************************************************************/ |
---|
241 | |
---|
242 | |
---|
243 | |
---|
244 | |
---|
245 | |
---|
246 | |
---|
247 | |
---|
248 | |
---|
249 | |
---|
250 | |
---|
251 | /****************************************************************************** |
---|
252 | * Global Variable: IFD_Tag_Definitions, Pentax |
---|
253 | * |
---|
254 | * Contents: This global variable provides definitions of the known Pentax Type 1 |
---|
255 | * Makernote tags, indexed by their tag number. |
---|
256 | * |
---|
257 | ******************************************************************************/ |
---|
258 | |
---|
259 | $GLOBALS[ "IFD_Tag_Definitions" ]["Pentax"] = array( |
---|
260 | |
---|
261 | |
---|
262 | 0x0001 => array( 'Name' => "Capture Mode", |
---|
263 | 'Type' => "Lookup", |
---|
264 | 0 => "Auto", |
---|
265 | 1 => "Night-scene", |
---|
266 | 2 => "Manual", |
---|
267 | 4 => "Multiple" ), |
---|
268 | |
---|
269 | 0x0002 => array( 'Name' => "Quality Level", |
---|
270 | 'Type' => "Lookup", |
---|
271 | 0 => "Good", |
---|
272 | 1 => "Better", |
---|
273 | 2 => "Best" ), |
---|
274 | |
---|
275 | 0x0003 => array( 'Name' => "Focus Mode", |
---|
276 | 'Type' => "Lookup", |
---|
277 | 2 => "Custom", |
---|
278 | 3 => "Auto" ), |
---|
279 | |
---|
280 | 0x0004 => array( 'Name' => "Flash Mode", |
---|
281 | 'Type' => "Lookup", |
---|
282 | 1 => "Auto", |
---|
283 | 2 => "Flash on", |
---|
284 | 4 => "Flash off", |
---|
285 | 6 => "Red-eye Reduction" ), |
---|
286 | |
---|
287 | 0x0007 => array( 'Name' => "White Balance", |
---|
288 | 'Type' => "Lookup", |
---|
289 | 0 => "Auto", |
---|
290 | 1 => "Daylight", |
---|
291 | 2 => "Shade", |
---|
292 | 3 => "Tungsten", |
---|
293 | 4 => "Fluorescent", |
---|
294 | 5 => "Manual" ), |
---|
295 | |
---|
296 | |
---|
297 | 0x000a => array( 'Name' => "Digital Zoom", |
---|
298 | 'Type' => "Numeric", |
---|
299 | 'Units' => " (0 = Off)" ), |
---|
300 | |
---|
301 | 0x000b => array( 'Name' => "Sharpness", |
---|
302 | 'Type' => "Lookup", |
---|
303 | 0 => "Normal", |
---|
304 | 1 => "Soft", |
---|
305 | 2 => "Hard" ), |
---|
306 | |
---|
307 | 0x000c => array( 'Name' => "Contrast", |
---|
308 | 'Type' => "Lookup", |
---|
309 | 0 => "Normal", |
---|
310 | 1 => "Low", |
---|
311 | 2 => "High" ), |
---|
312 | |
---|
313 | 0x000d => array( 'Name' => "Saturation", |
---|
314 | 'Type' => "Lookup", |
---|
315 | 0 => "Normal", |
---|
316 | 1 => "Low", |
---|
317 | 2 => "High" ), |
---|
318 | |
---|
319 | 0x0014 => array( 'Name' => "ISO Speed", |
---|
320 | 'Type' => "Lookup", |
---|
321 | 10 => "100", |
---|
322 | 16 => "200", |
---|
323 | 100 => "100", |
---|
324 | 200 => "200" ), |
---|
325 | |
---|
326 | 0x0017 => array( 'Name' => "Colour", |
---|
327 | 'Type' => "Lookup", |
---|
328 | 1 => "Normal", |
---|
329 | 2 => "Black & White", |
---|
330 | 3 => "Sepia" ), |
---|
331 | |
---|
332 | 0x0e00 => array( 'Name' => "Print Image Matching Info", |
---|
333 | 'Type' => "PIM" ), |
---|
334 | |
---|
335 | 0x1000 => array( 'Name' => "Time Zone", |
---|
336 | 'Type' => "String" ), |
---|
337 | |
---|
338 | 0x1001 => array( 'Name' => "Daylight Savings", |
---|
339 | 'Type' => "String" ), |
---|
340 | |
---|
341 | |
---|
342 | |
---|
343 | |
---|
344 | |
---|
345 | ); |
---|
346 | |
---|
347 | /****************************************************************************** |
---|
348 | * End of Global Variable: IFD_Tag_Definitions, Pentax |
---|
349 | ******************************************************************************/ |
---|
350 | |
---|
351 | |
---|
352 | |
---|
353 | ?> |
---|