1: <?php
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: class Horde_Image_Exif_Parser_Fujifilm extends Horde_Image_Exif_Parser_Base
30: {
31: 32: 33:
34: protected function _lookupTag($tag)
35: {
36: switch ($tag) {
37: case '0000': return 'Version';
38: case '1000': return 'Quality';
39: case '1001': return 'Sharpness';
40: case '1002': return 'WhiteBalance';
41: case '1003': return 'Color';
42: case '1004': return 'Tone';
43: case '1010': return 'FlashMode';
44: case '1011': return 'FlashStrength';
45: case '1020': return 'Macro';
46: case '1021': return 'FocusMode';
47: case '1030': return 'SlowSync';
48: case '1031': return 'PictureMode';
49: case '1032': return 'Unknown';
50: case '1100': return 'ContinuousTakingBracket';
51: case '1200': return 'Unknown';
52: case '1300': return 'BlurWarning';
53: case '1301': return 'FocusWarning';
54: case '1302': return 'AEWarning';
55: default: return 'unknown:' . $tag;
56: }
57: }
58:
59: 60: 61: 62: 63: 64: 65: 66:
67: protected function _formatData($type, $tag, $intel, $data)
68: {
69: switch ($type) {
70: case 'ASCII':
71: case 'UNDEFINED':
72: break;
73:
74: case 'URATIONAL':
75: case 'SRATIONAL':
76: $data = bin2hex($data);
77: if ($intel) {
78: $data = Horde_Image_Exif::intel2Moto($data);
79: }
80: $top = hexdec(substr($data, 8, 8));
81: $bottom = hexdec(substr($data, 0, 8));
82: if ($bottom) {
83: $data = $top / $bottom;
84: } elseif (!$top) {
85: $data = 0;
86: } else {
87: $data = $top . '/' . $bottom;
88: }
89:
90: if ($tag == '1011') {
91:
92: $data = $data . ' EV';
93: }
94: break;
95:
96: case 'USHORT':
97: case 'SSHORT':
98: case 'ULONG':
99: case 'SLONG':
100: case 'FLOAT':
101: case 'DOUBLE':
102: $data = bin2hex($data);
103: if ($intel) {
104: $data = Horde_Image_Exif::intel2Moto($data);
105: }
106: $data = hexdec($data);
107:
108: switch ($tag) {
109: case '1001':
110:
111: switch ($data) {
112: case 1: $data = Horde_Image_Translation::t("Soft"); break;
113: case 2: $data = Horde_Image_Translation::t("Soft"); break;
114: case 3: $data = Horde_Image_Translation::t("Normal"); break;
115: case 4: $data = Horde_Image_Translation::t("Hard"); break;
116: case 5: $data = Horde_Image_Translation::t("Hard"); break;
117: default: $data = Horde_Image_Translation::t("Unknown") . ': ' . $data; break;
118: }
119: break;
120:
121: case '1002':
122:
123: switch ($data) {
124: case 0: $data = Horde_Image_Translation::t("Auto"); break;
125: case 256: $data = Horde_Image_Translation::t("Daylight"); break;
126: case 512: $data = Horde_Image_Translation::t("Cloudy"); break;
127: case 768: $data = Horde_Image_Translation::t("DaylightColor-fluorescence"); break;
128: case 769: $data = Horde_Image_Translation::t("DaywhiteColor-fluorescence"); break;
129: case 770: $data = Horde_Image_Translation::t("White-fluorescence"); break;
130: case 1024: $data = Horde_Image_Translation::t("Incandescense"); break;
131: case 3840: $data = Horde_Image_Translation::t("Custom"); break;
132: default: $data = Horde_Image_Translation::t("Unknown") . ': ' . $data; break;
133: }
134: break;
135:
136: case '1003':
137:
138: switch ($data) {
139: case 0: $data = Horde_Image_Translation::t("Chroma Saturation Normal(STD)"); break;
140: case 256: $data = Horde_Image_Translation::t("Chroma Saturation High"); break;
141: case 512: $data = Horde_Image_Translation::t("Chroma Saturation Low(ORG)"); break;
142: default: $data = Horde_Image_Translation::t("Unknown: ") . $data; break;
143: }
144: break;
145:
146: case '1004':
147:
148: switch ($data) {
149: case 0: $data = Horde_Image_Translation::t("Contrast Normal(STD)"); break;
150: case 256: $data = Horde_Image_Translation::t("Contrast High(HARD)"); break;
151: case 512: $data = Horde_Image_Translation::t("Contrast Low(ORG)"); break;
152: default: $data = Horde_Image_Translation::t("Unknown: ") . $data; break;
153: }
154: break;
155:
156: case '1010':
157:
158: switch ($data) {
159: case 0: $data = Horde_Image_Translation::t("Auto"); break;
160: case 1: $data = Horde_Image_Translation::t("On"); break;
161: case 2: $data = Horde_Image_Translation::t("Off"); break;
162: case 3: $data = Horde_Image_Translation::t("Red-Eye Reduction"); break;
163: default: $data = Horde_Image_Translation::t("Unknown: ") . $data; break;
164: }
165: break;
166:
167: case '1020':
168:
169: switch ($data) {
170: case 0: $data = Horde_Image_Translation::t("Off"); break;
171: case 1: $data = Horde_Image_Translation::t("On"); break;
172: default: $data = Horde_Image_Translation::t("Unknown: ") . $data; break;
173: }
174: break;
175:
176: case '1021':
177:
178: switch ($data) {
179: case 0: $data = Horde_Image_Translation::t("Auto"); break;
180: case 1: $data = Horde_Image_Translation::t("Manual"); break;
181: default: $data = Horde_Image_Translation::t("Unknown: ") . $data; break;
182: }
183: break;
184:
185: case '1030':
186:
187: switch ($data) {
188: case 0: $data = Horde_Image_Translation::t("Off"); break;
189: case 1: $data = Horde_Image_Translation::t("On"); break;
190: default: $data = Horde_Image_Translation::t("Unknown: ") . $data; break;
191: }
192: break;
193:
194: case '1031':
195:
196: switch ($data) {
197: case 0: $data = Horde_Image_Translation::t("Auto"); break;
198: case 1: $data = Horde_Image_Translation::t("Portrait"); break;
199: case 2: $data = Horde_Image_Translation::t("Landscape"); break;
200: case 4: $data = Horde_Image_Translation::t("Sports"); break;
201: case 5: $data = Horde_Image_Translation::t("Night"); break;
202: case 6: $data = Horde_Image_Translation::t("Program AE"); break;
203: case 256: $data = Horde_Image_Translation::t("Aperture Prority AE"); break;
204: case 512: $data = Horde_Image_Translation::t("Shutter Priority"); break;
205: case 768: $data = Horde_Image_Translation::t("Manual Exposure"); break;
206: default: $data = Horde_Image_Translation::t("Unknown: ") . $data; break;
207: }
208: break;
209:
210: case '1100':
211:
212: switch ($data) {
213: case 0: $data = Horde_Image_Translation::t("Off"); break;
214: case 1: $data = Horde_Image_Translation::t("On"); break;
215: default: $data = Horde_Image_Translation::t("Unknown: ") . $data; break;
216: }
217: break;
218:
219: case '1300':
220:
221: switch ($data) {
222: case 0: $data = Horde_Image_Translation::t("No Warning"); break;
223: case 1: $data = Horde_Image_Translation::t("Warning"); break;
224: default: $data = Horde_Image_Translation::t("Unknown: ") . $data; break;
225: }
226: break;
227:
228: case '1301':
229:
230: switch ($data) {
231: case 0: $data = Horde_Image_Translation::t("Auto Focus Good"); break;
232: case 1: $data = Horde_Image_Translation::t("Out of Focus"); break;
233: default: $data = Horde_Image_Translation::t("Unknown: ") . $data; break;
234: }
235: break;
236:
237: case '1302':
238:
239: switch ($data) {
240: case 0: $data = Horde_Image_Translation::t("AE Good"); break;
241: case 1: $data = Horde_Image_Translation::t("Over Exposure"); break;
242: default: $data = Horde_Image_Translation::t("Unknown: ") . $data; break;
243: }
244: break;
245: }
246: break;
247:
248: default:
249: $data = bin2hex($data);
250: if ($intel) {
251: $data = Horde_Image_Exif::intel2Moto($data);
252: }
253: break;
254: }
255:
256: return $data;
257: }
258:
259: 260: 261: 262: 263: 264:
265: public function parse($block, &$result)
266: {
267: $intel = true;
268: $model = $result['IFD0']['Model'];
269:
270:
271: $place = 8;
272: $offset = 8;
273:
274: $num = bin2hex(substr($block, $place, 4));
275: $place += 4;
276: if ($intel) {
277: $num = Horde_Image_Exif::intel2Moto($num);
278: }
279: $result['SubIFD']['MakerNote']['Offset'] = hexdec($num);
280:
281:
282: $num = bin2hex(substr($block, $place, 2));
283: $place += 2;
284: if ($intel) {
285: $num = Horde_Image_Exif::intel2Moto($num);
286: }
287: $result['SubIFD']['MakerNote']['MakerNoteNumTags'] = hexdec($num);
288:
289:
290: for ($i = 0; $i < hexdec($num); $i++) {
291:
292: $tag = bin2hex(substr($block, $place, 2));
293: $place += 2;
294: if ($intel) {
295: $tag = Horde_Image_Exif::intel2Moto($tag);
296: }
297: $tag_name = $this->_lookupTag($tag);
298:
299:
300: $type = bin2hex(substr($block, $place, 2));
301: $place += 2;
302: if ($intel) {
303: $type = Horde_Image_Exif::intel2Moto($type);
304: }
305: $this->_lookupType($type, $size);
306:
307:
308: $count = bin2hex(substr($block, $place, 4));
309: $place += 4;
310: if ($intel) {
311: $count = Horde_Image_Exif::intel2Moto($count);
312: }
313: $bytesofdata = $size * hexdec($count);
314:
315:
316: $value = substr($block, $place, 4);
317: $place += 4;
318:
319: if ($bytesofdata <= 4) {
320: $data = $value;
321: } else {
322: $value = bin2hex($value);
323: if ($intel) {
324: $value = Horde_Image_Exif::intel2Moto($value);
325: }
326: $data = substr($block, hexdec($value) - $offset, $bytesofdata * 2);
327: }
328: $formated_data = $this->_formatData($type, $tag, $intel, $data);
329: $result['SubIFD']['MakerNote'][$tag_name] = $formated_data;
330: }
331: }
332: }
333: