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