switch ($tag_name) {
case 'MakerNote':
$make = Horde_String::lower($result['IFD0']['Make']);
+ $parser = null;
if (strpos($make, 'nikon') !== false) {
- Horde_Image_Exif_Parser_Nikon::parse($data, $result);
+ $parser = new Horde_Image_Exif_Parser_Nikon();
$result[$ifd_name]['KnownMaker'] = 1;
} elseif (strpos($make, 'olympus') !== false) {
- Horde_Image_Exif_Parser_Olympus::parse($data, $result, $seek, $globalOffset);
+ $parser = new Horde_Image_Exif_Parser_Olympus();
$result[$ifd_name]['KnownMaker'] = 1;
} elseif (strpos($make, 'canon') !== false) {
- Horde_Image_Exif_Parser_Canon::parse($data, $result, $seek, $globalOffset);
+ $parser = new Horde_Image_Exif_Parser_Canon();
$result[$ifd_name]['KnownMaker'] = 1;
} elseif (strpos($make, 'fujifilm') !== false) {
- Horde_Image_Exif_Parser_Fujifilm::parse($data, $result);
+ $parser = new Horde_Image_Exif_Parser_Fujifilm();
$result[$ifd_name]['KnownMaker'] = 1;
} elseif (strpos($make, 'sanyo') !== false) {
- Horde_Image_Exif_Parser_Sanyo::parse($data, $result, $seek, $globalOffset);
+ $parser = new Horde_Image_Exif_Parser_Sanyo();
$result[$ifd_name]['KnownMaker'] = 1;
} elseif (strpos($make, 'panasonic') !== false) {
- Horde_Image_Exif_Parser_Panasonic::parse($data, $result, $seek, $globalOffset);
+ $parser = new Horde_Image_Exif_Parser_Panasonic();
$result[$ifd_name]['KnownMaker'] = 1;
} else {
$result[$ifd_name]['KnownMaker'] = 0;
}
+ if ($parser) {
+ $parser->parse($data, $result, $seek, $globalOffset);
+ }
break;
case 'GPSInfoOffset':
$formated_data = $this->_formatData($type, $tag, $intel, $data);
$result[$ifd_name]['GPSInfo'] = $formated_data;
- Horde_Image_Exif_Parser_Gps::parse($data, $result, $formated_data, $seek, $globalOffset);
+ $parser = new Horde_Image_Exif_Parser_Gps();
+ $parser->parse($data, $result, $formated_data, $seek, $globalOffset);
break;
default:
<?php
/**
- *
* @category Horde
- * @package Horde_Image
+ * @package Image
*/
class Horde_Image_Exif_Parser_Base
{
* @param $size
* @return unknown_type
*/
- static protected function _lookupType(&$type,&$size) {
+ protected function _lookupType(&$type, &$size)
+ {
switch($type) {
- case '0001': $type = 'UBYTE'; $size=1; break;
- case '0002': $type = 'ASCII'; $size=1; break;
- case '0003': $type = 'USHORT'; $size=2; break;
- case '0004': $type = 'ULONG'; $size=4; break;
- case '0005': $type = 'URATIONAL'; $size=8; break;
- case '0006': $type = 'SBYTE'; $size=1; break;
- case '0007': $type = 'UNDEFINED'; $size=1; break;
- case '0008': $type = 'SSHORT'; $size=2; break;
- case '0009': $type = 'SLONG'; $size=4; break;
- case '000a': $type = 'SRATIONAL'; $size=8; break;
- case '000b': $type = 'FLOAT'; $size=4; break;
- case '000c': $type = 'DOUBLE'; $size=8; break;
- default: $type = 'error:'.$type; $size=0; break;
+ case '0001': $type = 'UBYTE'; $size = 1; break;
+ case '0002': $type = 'ASCII'; $size = 1; break;
+ case '0003': $type = 'USHORT'; $size = 2; break;
+ case '0004': $type = 'ULONG'; $size = 4; break;
+ case '0005': $type = 'URATIONAL'; $size = 8; break;
+ case '0006': $type = 'SBYTE'; $size = 1; break;
+ case '0007': $type = 'UNDEFINED'; $size = 1; break;
+ case '0008': $type = 'SSHORT'; $size = 2; break;
+ case '0009': $type = 'SLONG'; $size = 4; break;
+ case '000a': $type = 'SRATIONAL'; $size = 8; break;
+ case '000b': $type = 'FLOAT'; $size = 4; break;
+ case '000c': $type = 'DOUBLE'; $size = 8; break;
+ default: $type = 'error:' . $type; $size = 0; break;
}
-
- return $type;
}
-
}
\ No newline at end of file
<?php
/**
- *
- * @author Michael J. Rubinsky <mrubinsk@horde.org>
+ * @author Michael J. Rubinsky <mrubinsk@horde.org>
+ * @author Jan Schneider <jan@horde.org>
* @category Horde
- * @package Horde_Image
+ * @package Image
*/
/**
- * Exifer
- * Extracts EXIF information from digital photos.
- *
- * Copyright 2003 Jake Olefsky
- * http://www.offsky.com/software/exif/index.php
- * jake@olefsky.com
+ * Exifer
+ * Extracts EXIF information from digital photos.
*
- * Please see exif.php for the complete information about this software.
+ * Copyright © 2003 Jake Olefsky
+ * http://www.offsky.com/software/exif/index.php
+ * jake@olefsky.com
*
- * ------------
+ * ------------
*
- * This program is free software; you can redistribute it and/or modify it under the terms of
- * the GNU General Public License as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
*
- * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- * See the GNU General Public License for more details. http://www.gnu.org/copyleft/gpl.html
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * for more details. http://www.gnu.org/copyleft/gpl.html
*/
class Horde_Image_Exif_Parser_Canon extends Horde_Image_Exif_Parser_Base
{
/**
- *Looks up the name of the tag for the MakerNote (Depends on Manufacturer)
+ * Looks up the name of the tag for the MakerNote (Depends on Manufacturer)
*/
- static protected function _lookupTag($tag)
+ protected function _lookupTag($tag)
{
switch($tag) {
case '0001': $tag = 'Settings 1'; break;
case '0009': $tag = 'OwnerName'; break;
case '000c': $tag = 'CameraSerialNumber'; break;
case '000f': $tag = 'CustomFunctions'; break;
- default: $tag = sprintf(_("Unknown: (%s)"), $tag); break;
+ default: $tag = sprintf(_("Unknown: (%s)"), $tag); break;
}
return $tag;
/**
* Formats Data for the data type
*/
- static protected function _formatData($type, $tag, $intel, $data, $exif, &$result)
+ protected function _formatData($type, $tag, $intel, $data, $exif, &$result)
{
$place = 0;
- if ($type == 'ASCII') {
+ switch ($type) {
+ case 'ASCII':
$result = $data = str_replace('\0', '', $data);
- } elseif ($type == 'URATIONAL' || $type == 'SRATIONAL') {
+ break;
+
+ case 'URATIONAL':
+ case 'SRATIONAL':
$data = bin2hex($data);
if ($intel == 1) {
$data = Horde_Image_Exif::intel2Moto($data);
$data = $top . '/' . $bottom;
}
- if ($tag == '0204') { //DigitalZoom
+ if ($tag == '0204') {
+ //DigitalZoom
$data = $data . 'x';
}
- } elseif ($type == 'USHORT' || $type == 'SSHORT' || $type == 'ULONG' ||
- $type == 'SLONG' || $type == 'FLOAT' || $type == 'DOUBLE') {
-
+ case 'USHORT':
+ case 'SSHORT':
+ case 'ULONG':
+ case 'SLONG':
+ case 'FLOAT':
+ case 'DOUBLE':
$data = bin2hex($data);
$result['RAWDATA'] = $data;
- if ($tag == '0001') { //first chunk
+ // TODO: split this code up
+ switch ($tag) {
+ case '0001':
+ //first chunk
$result['Bytes'] = hexdec(Horde_Image_Exif::intel2Moto(substr($data, $place, 4)));
$place += 4;
if ($result['Bytes'] != strlen($data) / 2) {
- return $result; //Bad chunk
+ //Bad chunk
+ return $result;
}
$result['Macro'] = hexdec(Horde_Image_Exif::intel2Moto(substr($data, $place, 4)));
$place += 4;//1
default: $result['FocusMode'] = _("Unknown");
}
}
+ break;
- } elseif ($tag=='0004') { //second chunk
+ case '0004':
+ //second chunk
$result['Bytes']=hexdec(Horde_Image_Exif::intel2Moto(substr($data, $place, 4)));
$place += 4;//0
if ($result['Bytes'] != strlen($data) / 2) {
$result['SubjectDistance'] = hexdec(Horde_Image_Exif::intel2Moto(substr($data, $place, 4)));
$place += 4;//19
$result['SubjectDistance'] .= '/100 m';
+ break;
- } elseif ($tag=='0008') { //image number
+ case '0008':
+ //image number
if ($intel == 1) {
$data = Horde_Image_Exif::intel2Moto($data);
}
$data = hexdec($data);
$result = round($data / 10000) . '-' . $data % 10000;
- } elseif ($tag == '000c') { //camera serial number
+ break;
+
+ case '000c':
+ //camera serial number
if ($intel == 1) {
$data = Horde_Image_Exif::intel2Moto($data);
}
$data = hexdec($data);
$result = '#' . bin2hex(substr($data, 0, 16)) . substr($data, 16, 16);
+ break;
}
+ break;
- } elseif ($type != 'UNDEFINED') {
- $data = bin2hex($data);
- if ($intel == 1) {
- $data = Horde_Image_Exif::intel2Moto($data);
+ default:
+ if ($type != 'UNDEFINED') {
+ $data = bin2hex($data);
+ if ($intel == 1) {
+ $data = Horde_Image_Exif::intel2Moto($data);
+ }
}
+ break;
}
return $data;
}
/**
- * Cannon Special data section
- * Useful: http://www.burren.cx/david/canon.html
- * http://www.burren.cx/david/canon.html
- * http://www.ozhiker.com/electronics/pjmt/jpeg_info/canon_mn.html
+ * Canon Special data section.
+ *
+ * @see http://www.burren.cx/david/canon.html
+ * @see http://www.burren.cx/david/canon.html
+ * @see http://www.ozhiker.com/electronics/pjmt/jpeg_info/canon_mn.html
*/
- static public function parse($block, &$result, $seek, $globalOffset)
+ public function parse($block, &$result, $seek, $globalOffset)
{
$place = 0; //current place
if ($result['Endien'] == 'Intel') {
//loop thru all tags Each field is 12 bytes
for ($i = 0; $i < hexdec($num); $i++) {
- //2 byte tag
+ //2 byte tag
$tag = bin2hex(substr($block, $place, 2));
$place += 2;
if ($intel == 1) {
$tag = Horde_Image_Exif::intel2Moto($tag);
}
- $tag_name = self::_lookupTag($tag);
+ $tag_name = $this->_lookupTag($tag);
//2 byte type
$type = bin2hex(substr($block, $place, 2));
if ($intel == 1) {
$type = Horde_Image_Exif::intel2Moto($type);
}
- self::_lookupType($type, $size);
+ $this->_lookupType($type, $size);
//4 byte count of number of data units
$count = bin2hex(substr($block, $place, 4));
return; //if this value is 0 or less then we have read all the tags we can
}
- //4 byte value of data or pointer to data
+ //4 byte value of data or pointer to data
$value = substr($block, $place, 4);
$place += 4;
if ($intel == 1) {
$value = Horde_Image_Exif::intel2Moto($value);
}
- $v = fseek($seek, $globalOffset+hexdec($value)); //offsets are from TIFF header which is 12 bytes from the start of the file
+ //offsets are from TIFF header which is 12 bytes from the start
+ //of the file
+ $v = fseek($seek, $globalOffset + hexdec($value));
$exiferFileSize = 0;
if ($v == 0 && $bytesofdata < $exiferFileSize) {
$data = fread($seek, $bytesofdata);
$data = '';
}
}
- $result['SubIFD']['MakerNote'][$tag_name] = ''; // insure the index exists
- $formated_data = self::_formatData($type, $tag, $intel, $data, $result, $result['SubIFD']['MakerNote'][$tag_name]);
+ // Ensure the index exists.
+ $result['SubIFD']['MakerNote'][$tag_name] = '';
+ $formated_data = $this->_formatData($type, $tag, $intel, $data, $result, $result['SubIFD']['MakerNote'][$tag_name]);
$result['SubIFD']['MakerNote'][$tag_name] = $formated_data;
}
-
}
-
}
<?php
/**
- * @author Michael J. Rubinsky <mrubinsk@horde.org>
+ * @author Michael J. Rubinsky <mrubinsk@horde.org>
+ * @author Jan Schneider <jan@horde.org>
* @category Horde
- * @package Horde_Image
+ * @package Image
*/
/**
- * Exifer
- * Extracts EXIF information from digital photos.
+ * Exifer
+ * Extracts EXIF information from digital photos.
*
- * Copyright � 2003 Jake Olefsky
- * http://www.offsky.com/software/exif/index.php
- * jake@olefsky.com
+ * Copyright © 2003 Jake Olefsky
+ * http://www.offsky.com/software/exif/index.php
+ * jake@olefsky.com
*
- * Please see exif.php for the complete information about this software.
+ * ------------
*
- * ------------
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
*
- * This program is free software; you can redistribute it and/or modify it under the terms of
- * the GNU General Public License as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- * See the GNU General Public License for more details. http://www.gnu.org/copyleft/gpl.html
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details. http://www.gnu.org/copyleft/gpl.html
*/
class Horde_Image_Exif_Parser_Fujifilm extends Horde_Image_Exif_Parser_Base
{
/**
* Looks up the name of the tag for the MakerNote (Depends on Manufacturer)
*/
- static protected function _lookupTag($tag) {
-
+ protected function _lookupTag($tag)
+ {
switch($tag) {
- case "0000": $tag = "Version";break;
- case "1000": $tag = "Quality";break;
- case "1001": $tag = "Sharpness";break;
- case "1002": $tag = "WhiteBalance";break;
- case "1003": $tag = "Color";break;
- case "1004": $tag = "Tone";break;
- case "1010": $tag = "FlashMode";break;
- case "1011": $tag = "FlashStrength";break;
- case "1020": $tag = "Macro";break;
- case "1021": $tag = "FocusMode";break;
- case "1030": $tag = "SlowSync";break;
- case "1031": $tag = "PictureMode";break;
- case "1032": $tag = "Unknown";break;
- case "1100": $tag = "ContinuousTakingBracket";break;
- case "1200": $tag = "Unknown";break;
- case "1300": $tag = "BlurWarning";break;
- case "1301": $tag = "FocusWarning";break;
- case "1302": $tag = "AEWarning";break;
-
- default: $tag = "unknown:".$tag;break;
+ case '0000': return 'Version';
+ case '1000': return 'Quality';
+ case '1001': return 'Sharpness';
+ case '1002': return 'WhiteBalance';
+ case '1003': return 'Color';
+ case '1004': return 'Tone';
+ case '1010': return 'FlashMode';
+ case '1011': return 'FlashStrength';
+ case '1020': return 'Macro';
+ case '1021': return 'FocusMode';
+ case '1030': return 'SlowSync';
+ case '1031': return 'PictureMode';
+ case '1032': return 'Unknown';
+ case '1100': return 'ContinuousTakingBracket';
+ case '1200': return 'Unknown';
+ case '1300': return 'BlurWarning';
+ case '1301': return 'FocusWarning';
+ case '1302': return 'AEWarning';
+ default: return 'unknown:' . $tag;
}
-
- return $tag;
}
/**
* @param $data
* @return unknown_type
*/
- static protected function _formatData($type, $tag, $intel, $data)
+ protected function _formatData($type, $tag, $intel, $data)
{
- if($type=="ASCII") {
-
-
- } else if($type=="URATIONAL" || $type=="SRATIONAL") {
- $data = bin2hex($data);
- if($intel==1) $data = Horde_Image_Exif::intel2Moto($data);
- $top = hexdec(substr($data,8,8));
- $bottom = hexdec(substr($data,0,8));
- if($bottom!=0) $data=$top/$bottom;
- else if($top==0) $data = 0;
- else $data=$top."/".$bottom;
-
- if($tag=="1011") { //FlashStrength
- $data=$data." EV";
- }
+ switch ($type) {
+ case 'ASCII':
+ case 'UNDEFINED':
+ break;
- } else if($type=="USHORT" || $type=="SSHORT" || $type=="ULONG" || $type=="SLONG" || $type=="FLOAT" || $type=="DOUBLE") {
+ case 'URATIONAL':
+ case 'SRATIONAL':
$data = bin2hex($data);
- if($intel==1) $data = Horde_Image_Exif::intel2Moto($data);
- $data=hexdec($data);
-
- if($tag=="1001") { //Sharpness
- if($data == 1) $data = _("Soft");
- else if($data == 2) $data = _("Soft");
- else if($data == 3) $data = _("Normal");
- else if($data == 4) $data = _("Hard");
- else if($data == 5) $data = _("Hard");
- else $data = _("Unknown").": ".$data;
- }
- if($tag=="1002") { //WhiteBalance
- if($data == 0) $data = _("Auto");
- else if($data == 256) $data = _("Daylight");
- else if($data == 512) $data = _("Cloudy");
- else if($data == 768) $data = _("DaylightColor-fluorescence");
- else if($data == 769) $data = _("DaywhiteColor-fluorescence");
- else if($data == 770) $data = _("White-fluorescence");
- else if($data == 1024) $data = _("Incandescense");
- else if($data == 3840) $data = _("Custom");
- else $data = _("Unknown").": ".$data;
- }
- if($tag=="1003") { //Color
- if($data == 0) $data = _("Chroma Saturation Normal(STD)");
- else if($data == 256) $data = _("Chroma Saturation High");
- else if($data == 512) $data = _("Chroma Saturation Low(ORG)");
- else $data = _("Unknown: ").$data;
- }
- if($tag=="1004") { //Tone
- if($data == 0) $data = _("Contrast Normal(STD)");
- else if($data == 256) $data = _("Contrast High(HARD)");
- else if($data == 512) $data = _("Contrast Low(ORG)");
- else $data = _("Unknown: ").$data;
- }
- if($tag=="1010") { //FlashMode
- if($data == 0) $data = _("Auto");
- else if($data == 1) $data = _("On");
- else if($data == 2) $data = _("Off");
- else if($data == 3) $data = _("Red-Eye Reduction");
- else $data = _("Unknown: ").$data;
+ if ($intel == 1) {
+ $data = Horde_Image_Exif::intel2Moto($data);
}
- if($tag=="1020") { //Macro
- if($data == 0) $data = _("Off");
- else if($data == 1) $data = _("On");
- else $data = _("Unknown: ").$data;
- }
- if($tag=="1021") { //FocusMode
- if($data == 0) $data = _("Auto");
- else if($data == 1) $data = _("Manual");
- else $data = _("Unknown: ").$data;
- }
- if($tag=="1030") { //SlowSync
- if($data == 0) $data = _("Off");
- else if($data == 1) $data = _("On");
- else $data = _("Unknown: ").$data;
- }
- if($tag=="1031") { //PictureMode
- if($data == 0) $data = _("Auto");
- else if($data == 1) $data = _("Portrait");
- else if($data == 2) $data = _("Landscape");
- else if($data == 4) $data = _("Sports");
- else if($data == 5) $data = _("Night");
- else if($data == 6) $data = _("Program AE");
- else if($data == 256) $data = _("Aperture Prority AE");
- else if($data == 512) $data = _("Shutter Priority");
- else if($data == 768) $data = _("Manual Exposure");
- else $data = _("Unknown: ").$data;
- }
- if($tag=="1100") { //ContinuousTakingBracket
- if($data == 0) $data = _("Off");
- else if($data == 1) $data = _("On");
- else $data = _("Unknown: ").$data;
- }
- if($tag=="1300") { //BlurWarning
- if($data == 0) $data = _("No Warning");
- else if($data == 1) $data = _("Warning");
- else $data = _("Unknown: ").$data;
+ $top = hexdec(substr($data, 8, 8));
+ $bottom = hexdec(substr($data, 0, 8));
+ if ($bottom) {
+ $data = $top / $bottom;
+ } elseif (!$top) {
+ $data = 0;
+ } else {
+ $data = $top . '/' . $bottom;
}
- if($tag=="1301") { //FocusWarning
- if($data == 0) $data = _("Auto Focus Good");
- else if($data == 1) $data = _("Out of Focus");
- else $data = _("Unknown: ").$data;
+
+ if ($tag == '1011') {
+ //FlashStrength
+ $data = $data . ' EV';
}
- if($tag=="1302") { //AEWarning
- if($data == 0) $data = _("AE Good");
- else if($data == 1) $data = _("Over Exposure");
- else $data = _("Unknown: ").$data;
+ break;
+
+ case 'USHORT':
+ case 'SSHORT':
+ case 'ULONG':
+ case 'SLONG':
+ case 'FLOAT':
+ case 'DOUBLE':
+ $data = bin2hex($data);
+ if ($intel == 1) {
+ $data = Horde_Image_Exif::intel2Moto($data);
}
- } else if($type=="UNDEFINED") {
+ $data = hexdec($data);
+
+ switch ($tag) {
+ case '1001':
+ //Sharpness
+ switch ($data) {
+ case 1: $data = _("Soft"); break;
+ case 2: $data = _("Soft"); break;
+ case 3: $data = _("Normal"); break;
+ case 4: $data = _("Hard"); break;
+ case 5: $data = _("Hard"); break;
+ default: $data = _("Unknown") . ': ' . $data; break;
+ }
+ break;
+
+ case '1002':
+ //WhiteBalance
+ switch ($data) {
+ case 0: $data = _("Auto"); break;
+ case 256: $data = _("Daylight"); break;
+ case 512: $data = _("Cloudy"); break;
+ case 768: $data = _("DaylightColor-fluorescence"); break;
+ case 769: $data = _("DaywhiteColor-fluorescence"); break;
+ case 770: $data = _("White-fluorescence"); break;
+ case 1024: $data = _("Incandescense"); break;
+ case 3840: $data = _("Custom"); break;
+ default: $data = _("Unknown") . ': ' . $data; break;
+ }
+ break;
+ case '1003':
+ //Color
+ switch ($data) {
+ case 0: $data = _("Chroma Saturation Normal(STD)"); break;
+ case 256: $data = _("Chroma Saturation High"); break;
+ case 512: $data = _("Chroma Saturation Low(ORG)"); break;
+ default: $data = _("Unknown: ") . $data; break;
+ }
+ break;
+ case '1004':
+ //Tone
+ switch ($data) {
+ case 0: $data = _("Contrast Normal(STD)"); break;
+ case 256: $data = _("Contrast High(HARD)"); break;
+ case 512: $data = _("Contrast Low(ORG)"); break;
+ default: $data = _("Unknown: ") . $data; break;
+ }
+ break;
- } else {
+ case '1010':
+ //FlashMode
+ switch ($data) {
+ case 0: $data = _("Auto"); break;
+ case 1: $data = _("On"); break;
+ case 2: $data = _("Off"); break;
+ case 3: $data = _("Red-Eye Reduction"); break;
+ default: $data = _("Unknown: ") . $data; break;
+ }
+ break;
+
+ case '1020':
+ //Macro
+ switch ($data) {
+ case 0: $data = _("Off"); break;
+ case 1: $data = _("On"); break;
+ default: $data = _("Unknown: ") . $data; break;
+ }
+ break;
+
+ case '1021':
+ //FocusMode
+ switch ($data) {
+ case 0: $data = _("Auto"); break;
+ case 1: $data = _("Manual"); break;
+ default: $data = _("Unknown: ") . $data; break;
+ }
+ break;
+
+ case '1030':
+ //SlowSync
+ switch ($data) {
+ case 0: $data = _("Off"); break;
+ case 1: $data = _("On"); break;
+ default: $data = _("Unknown: ") . $data; break;
+ }
+ break;
+
+ case '1031':
+ //PictureMode
+ switch ($data) {
+ case 0: $data = _("Auto"); break;
+ case 1: $data = _("Portrait"); break;
+ case 2: $data = _("Landscape"); break;
+ case 4: $data = _("Sports"); break;
+ case 5: $data = _("Night"); break;
+ case 6: $data = _("Program AE"); break;
+ case 256: $data = _("Aperture Prority AE"); break;
+ case 512: $data = _("Shutter Priority"); break;
+ case 768: $data = _("Manual Exposure"); break;
+ default: $data = _("Unknown: ") . $data; break;
+ }
+ break;
+
+ case '1100':
+ //ContinuousTakingBracket
+ switch ($data) {
+ case 0: $data = _("Off"); break;
+ case 1: $data = _("On"); break;
+ default: $data = _("Unknown: ") . $data; break;
+ }
+ break;
+
+ case '1300':
+ //BlurWarning
+ switch ($data) {
+ case 0: $data = _("No Warning"); break;
+ case 1: $data = _("Warning"); break;
+ default: $data = _("Unknown: ") . $data; break;
+ }
+ break;
+
+ case '1301':
+ //FocusWarning
+ switch ($data) {
+ case 0: $data = _("Auto Focus Good"); break;
+ case 1: $data = _("Out of Focus"); break;
+ default: $data = _("Unknown: ") . $data; break;
+ }
+ break;
+
+ case '1302':
+ //AEWarning
+ switch ($data) {
+ case 0: $data = _("AE Good"); break;
+ case 1: $data = _("Over Exposure"); break;
+ default: $data = _("Unknown: ") . $data; break;
+ }
+ break;
+ }
+ break;
+
+ default:
$data = bin2hex($data);
- if($intel==1) $data = Horde_Image_Exif::intel2Moto($data);
+ if ($intel == 1) {
+ $data = Horde_Image_Exif::intel2Moto($data);
+ }
+ break;
}
return $data;
* @param $result
* @return unknown_type
*/
- static public function parse($block, &$result)
+ public function parse($block, &$result)
{
- $intel=1;
-
+ $intel = 1;
$model = $result['IFD0']['Model'];
- $place=8; //current place
- $offset=8;
-
+ //current place
+ $place = 8;
+ $offset = 8;
- $num = bin2hex(substr($block,$place,4));$place+=4;
- if($intel==1) $num = Horde_Image_Exif::intel2Moto($num);
+ $num = bin2hex(substr($block, $place, 4));
+ $place += 4;
+ if ($intel == 1) {
+ $num = Horde_Image_Exif::intel2Moto($num);
+ }
$result['SubIFD']['MakerNote']['Offset'] = hexdec($num);
- //Get number of tags (2 bytes)
- $num = bin2hex(substr($block,$place,2));$place+=2;
- if($intel==1) $num = Horde_Image_Exif::intel2Moto($num);
+ //Get number of tags (2 bytes)
+ $num = bin2hex(substr($block, $place, 2));
+ $place += 2;
+ if ($intel == 1) {
+ $num = Horde_Image_Exif::intel2Moto($num);
+ }
$result['SubIFD']['MakerNote']['MakerNoteNumTags'] = hexdec($num);
//loop thru all tags Each field is 12 bytes
- for($i=0;$i<hexdec($num);$i++) {
-
- //2 byte tag
- $tag = bin2hex(substr($block,$place,2));$place+=2;
- if($intel==1) $tag = Horde_Image_Exif::intel2Moto($tag);
- $tag_name = self::_lookupTag($tag);
-
- //2 byte type
- $type = bin2hex(substr($block,$place,2));$place+=2;
- if($intel==1) $type = Horde_Image_Exif::intel2Moto($type);
- self::_lookupType($type,$size);
+ for ($i = 0; $i < hexdec($num); $i++) {
+ //2 byte tag
+ $tag = bin2hex(substr($block, $place, 2));
+ $place += 2;
+ if ($intel == 1) {
+ $tag = Horde_Image_Exif::intel2Moto($tag);
+ }
+ $tag_name = $this->_lookupTag($tag);
- //4 byte count of number of data units
- $count = bin2hex(substr($block,$place,4));$place+=4;
- if($intel==1) $count = Horde_Image_Exif::intel2Moto($count);
- $bytesofdata = $size*hexdec($count);
+ //2 byte type
+ $type = bin2hex(substr($block, $place, 2));
+ $place += 2;
+ if ($intel == 1) {
+ $type = Horde_Image_Exif::intel2Moto($type);
+ }
+ $this->_lookupType($type, $size);
- //4 byte value of data or pointer to data
- $value = substr($block,$place,4);$place+=4;
+ //4 byte count of number of data units
+ $count = bin2hex(substr($block, $place, 4));
+ $place += 4;
+ if ($intel == 1) {
+ $count = Horde_Image_Exif::intel2Moto($count);
+ }
+ $bytesofdata = $size * hexdec($count);
+ //4 byte value of data or pointer to data
+ $value = substr($block, $place, 4);
+ $place += 4;
- if($bytesofdata<=4) {
+ if ($bytesofdata <= 4) {
$data = $value;
} else {
$value = bin2hex($value);
- if($intel==1) $value = Horde_Image_Exif::intel2Moto($value);
- $data = substr($block,hexdec($value)-$offset,$bytesofdata*2);
+ if ($intel == 1) {
+ $value = Horde_Image_Exif::intel2Moto($value);
+ }
+ $data = substr($block, hexdec($value) - $offset, $bytesofdata * 2);
}
- $formated_data = self::_formatData($type,$tag,$intel,$data);
+ $formated_data = $this->_formatData($type, $tag, $intel, $data);
$result['SubIFD']['MakerNote'][$tag_name] = $formated_data;
}
-
}
-
-}
\ No newline at end of file
+}
<?php
/**
- * @author Michael J. Rubinsky <mrubinsk@horde.org>
+ * @author Michael J. Rubinsky <mrubinsk@horde.org>
+ * @author Jan Schneider <jan@horde.org>
* @category Horde
- * @package Horde_Image
+ * @package Image
*/
/**
- Exifer
- Extracts EXIF information from digital photos.
-
- Copyright © 2003 Jake Olefsky
- http://www.offsky.com/software/exif/index.php
- jake@olefsky.com
-
- Please see exif.php for the complete information about this software.
-
- ------------
-
- This program is free software; you can redistribute it and/or modify it under the terms of
- the GNU General Public License as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
- without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- See the GNU General Public License for more details. http://www.gnu.org/copyleft/gpl.html
-*/
+ * Exifer
+ * Extracts EXIF information from digital photos.
+ *
+ * Copyright © 2003 Jake Olefsky
+ * http://www.offsky.com/software/exif/index.php
+ * jake@olefsky.com
+ *
+ * ------------
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details. http://www.gnu.org/copyleft/gpl.html
+ */
class Horde_Image_Exif_Parser_Gps extends Horde_Image_Exif_Parser_Base
{
/**
* @param unknown_type $tag
* @return string
*/
- static protected function _lookupTag($tag)
+ protected function _lookupTag($tag)
{
switch($tag) {
- case "0000": return "Version";
- case "0001": return "LatitudeRef"; //north or south
- case "0002": return "Latitude"; //dd mm.mm or dd mm ss
- case "0003": return "LongitudeRef"; //east or west
- case "0004": return "Longitude"; //dd mm.mm or dd mm ss
- case "0005": return "AltitudeRef"; //sea level or below sea level
- case "0006": return "Altitude"; //positive rational number
- case "0007": return "Time"; //three positive rational numbers
- case "0008": return "Satellite"; //text string up to 999 bytes long
- case "0009": return "ReceiveStatus"; //in progress or interop
- case "000a": return "MeasurementMode"; //2D or 3D
- case "000b": return "MeasurementPrecision"; //positive rational number
- case "000c": return "SpeedUnit"; //KPH, MPH, knots
- case "000d": return "ReceiverSpeed"; //positive rational number
- case "000e": return "MovementDirectionRef"; //true or magnetic north
- case "000f": return "MovementDirection"; //positive rational number
- case "0010": return "ImageDirectionRef"; //true or magnetic north
- case "0011": return "ImageDirection"; //positive rational number
- case "0012": return "GeodeticSurveyData"; //text string up to 999 bytes long
- case "0013": return "DestLatitudeRef"; //north or south
- case "0014": return "DestinationLatitude"; //three positive rational numbers
- case "0015": return "DestLongitudeRef"; //east or west
- case "0016": return "DestinationLongitude"; //three positive rational numbers
- case "0017": return "DestBearingRef"; //true or magnetic north
- case "0018": return "DestinationBearing"; //positive rational number
- case "0019": return "DestDistanceRef"; //km, miles, knots
- case "001a": return "DestinationDistance"; //positive rational number
- case "001b": return "ProcessingMethod";
- case "001c": return "AreaInformation";
- case "001d": return "Datestamp"; //text string 10 bytes long
- case "001e": return "DifferentialCorrection"; //integer in range 0-65535
- default: return "unknown:".$tag;
+ case '0000': return 'Version';
+ //north or south
+ case '0001': return 'LatitudeRef';
+ //dd mm.mm or dd mm ss
+ case '0002': return 'Latitude';
+ //east or west
+ case '0003': return 'LongitudeRef';
+ //dd mm.mm or dd mm ss
+ case '0004': return 'Longitude';
+ //sea level or below sea level
+ case '0005': return 'AltitudeRef';
+ //positive rational number
+ case '0006': return 'Altitude';
+ //three positive rational numbers
+ case '0007': return 'Time';
+ //text string up to 999 bytes long
+ case '0008': return 'Satellite';
+ //in progress or interop
+ case '0009': return 'ReceiveStatus';
+ //2D or 3D
+ case '000a': return 'MeasurementMode';
+ //positive rational number
+ case '000b': return 'MeasurementPrecision';
+ //KPH, MPH, knots
+ case '000c': return 'SpeedUnit';
+ //positive rational number
+ case '000d': return 'ReceiverSpeed';
+ //true or magnetic north
+ case '000e': return 'MovementDirectionRef';
+ //positive rational number
+ case '000f': return 'MovementDirection';
+ //true or magnetic north
+ case '0010': return 'ImageDirectionRef';
+ //positive rational number
+ case '0011': return 'ImageDirection';
+ //text string up to 999 bytes long
+ case '0012': return 'GeodeticSurveyData';
+ //north or south
+ case '0013': return 'DestLatitudeRef';
+ //three positive rational numbers
+ case '0014': return 'DestinationLatitude';
+ //east or west
+ case '0015': return 'DestLongitudeRef';
+ //three positive rational numbers
+ case '0016': return 'DestinationLongitude';
+ //true or magnetic north
+ case '0017': return 'DestBearingRef';
+ //positive rational number
+ case '0018': return 'DestinationBearing';
+ //km, miles, knots
+ case '0019': return 'DestDistanceRef';
+ //positive rational number
+ case '001a': return 'DestinationDistance';
+ case '001b': return 'ProcessingMethod';
+ case '001c': return 'AreaInformation';
+ //text string 10 bytes long
+ case '001d': return 'Datestamp';
+ //integer in range 0-65535
+ case '001e': return 'DifferentialCorrection';
+ default: return 'unknown: ' . $tag;
}
-
}
/**
* Formats a rational number
*/
- static protected function _rational($data, $intel)
+ protected function _rational($data, $intel)
{
-
if ($intel == 1) {
- $top = hexdec(substr($data, 8, 8)); //intel stores them bottom-top
+ //intel stores them bottom-top
+ $top = hexdec(substr($data, 8, 8));
} else {
- $top = hexdec(substr($data, 0, 8)); //motorola stores them top-bottom
+ //motorola stores them top-bottom
+ $top = hexdec(substr($data, 0, 8));
}
if ($intel == 1) {
$bottom = hexdec(substr($data, 8, 8));
}
- if ($bottom!=0) {
+ if ($bottom != 0) {
$data = $top / $bottom;
} elseif ($top == 0) {
$data = 0;
} else {
- $data = $top . "/" . $bottom;
+ $data = $top . '/' . $bottom;
}
return $data;
/**
* Formats Data for the data type
*/
- static protected function _formatData($type, $tag, $intel, $data)
+ protected function _formatData($type, $tag, $intel, $data)
{
-
- if($type == "ASCII") {
+ switch ($type) {
+ case 'ASCII':
// Latitude Reference, Longitude Reference
- if ($tag == "0001" || $tag == "0003") {
+ if ($tag == '0001' || $tag == '0003') {
$data = ($data{1} == $data{2} && $data{1} == $data{3}) ? $data{0} : $data;
}
- } elseif ($type == "URATIONAL" || $type == "SRATIONAL") {
+ break;
+
+ case 'URATIONAL':
+ case 'SRATIONAL':
$data = bin2hex($data);
- if ($intel ==1 ) {
+ if ($intel == 1) {
$data = Horde_Image_Exif::intel2Moto($data);
}
if ($intel == 1) {
- $top = hexdec(substr($data, 8, 8)); //intel stores them bottom-top
+ //intel stores them bottom-top
+ $top = hexdec(substr($data, 8, 8));
} else {
- $top = hexdec(substr($data, 0, 8)); //motorola stores them top-bottom
+ //motorola stores them top-bottom
+ $top = hexdec(substr($data, 0, 8));
}
if ($intel == 1) {
$bottom = hexdec(substr($data, 8, 8));
}
- if ($type == "SRATIONAL" && $top > 2147483647) {
- // make the number signed instead of unsigned
+ if ($type == 'SRATIONAL' && $top > 2147483647) {
+ // make the number signed instead of unsigned
$top = $top - 4294967296;
}
- //Latitude, Longitude
- if ($tag=="0002" || $tag=="0004") {
+ switch ($tag) {
+ case '0002':
+ case '0004':
+ //Latitude, Longitude
if ($intel == 1) {
- $seconds = self::_rational(substr($data, 0, 16), $intel);
- $hour = self::_rational(substr($data, 32, 16), $intel);
+ $seconds = $this->_rational(substr($data, 0, 16), $intel);
+ $hour = $this->_rational(substr($data, 32, 16), $intel);
} else {
- $hour = self::_rational(substr($data, 0, 16), $intel);
- $seconds = self::_rational(substr($data, 32, 16), $intel);
+ $hour = $this->_rational(substr($data, 0, 16), $intel);
+ $seconds = $this->_rational(substr($data, 32, 16), $intel);
}
- $minutes = self::_rational(substr($data, 16, 16), $intel);
+ $minutes = $this->_rational(substr($data, 16, 16), $intel);
$data = array($hour, $minutes, $seconds);
- } elseif ($tag == "0007") { //Time
- $seconds = self::_rational(substr($data, 0, 16), $intel);
- $minutes = self::_rational(substr($data, 16, 16), $intel);
- $hour = self::_rational(substr($data, 32, 16), $intel);
- $data = $hour . ":" . $minutes . ":" . $seconds;
- } else {
+ break;
+
+ case '0007':
+ //Time
+ $seconds = $this->_rational(substr($data, 0, 16), $intel);
+ $minutes = $this->_rational(substr($data, 16, 16), $intel);
+ $hour = $this->_rational(substr($data, 32, 16), $intel);
+ $data = $hour . ':' . $minutes . ':' . $seconds;
+ break;
+
+ default:
if ($bottom != 0) {
$data = $top / $bottom;
} elseif ($top == 0) {
$data = 0;
} else {
- $data = $top . "/" . $bottom;
+ $data = $top . '/' . $bottom;
}
- if ($tag == "0006") {
+ if ($tag == '0006') {
$data .= 'm';
}
+ break;
}
- } elseif ($type == "USHORT" || $type == "SSHORT" || $type == "ULONG" ||
- $type == "SLONG" || $type == "FLOAT" || $type == "DOUBLE") {
+ break;
+ case 'USHORT':
+ case 'SSHORT':
+ case 'ULONG':
+ case 'SLONG':
+ case 'FLOAT':
+ case 'DOUBLE':
$data = bin2hex($data);
if ($intel == 1) {
$data = Horde_Image_Exif::intel2Moto($data);
}
$data = hexdec($data);
- } elseif ($type == "UNDEFINED") {
- } elseif ($type == "UBYTE") {
+ break;
+
+ case 'UNDEFINED':
+ break;
+
+ case 'UBYTE':
$data = bin2hex($data);
if ($intel == 1) {
$num = Horde_Image_Exif::intel2Moto($data);
}
- if ($tag == "0000") { // VersionID
- $data = hexdec(substr($data, 0, 2))
- . '.' . hexdec(substr($data, 2, 2))
- . '.' . hexdec(substr($data, 4, 2))
- . '.'. hexdec(substr($data, 6, 2));
- } elseif ($tag == "0005") { // Altitude Reference
- if ($data == "00000000") {
+ switch ($tag) {
+ case '0000':
+ // VersionID
+ $data = hexdec(substr($data, 0, 2))
+ . '.' . hexdec(substr($data, 2, 2))
+ . '.' . hexdec(substr($data, 4, 2))
+ . '.'. hexdec(substr($data, 6, 2));
+ break;
+ case '0005':
+ // Altitude Reference
+ if ($data == '00000000') {
$data = 'Above Sea Level';
- } elseif ($data == "01000000") {
+ } elseif ($data == '01000000') {
$data = 'Below Sea Level';
}
+ break;
}
- } else {
+ break;
+
+ default:
$data = bin2hex($data);
if ($intel == 1) {
$data = Horde_Image_Exif::intel2Moto($data);
}
+ break;
}
return $data;
/**
* GPS Special data section
- * Useful websites
- * http://drewnoakes.com/code/exif/sampleOutput.html
- * http://www.geosnapper.com
+ *
+ * @see http://drewnoakes.com/code/exif/sampleOutput.html
+ * @see http://www.geosnapper.com
*/
- static public function parse($block,&$result,$offset,$seek, $globalOffset)
+ public function parse($block, &$result, $offset, $seek, $globalOffset)
{
- if ($result['Endien'] == "Intel") {
+ if ($result['Endien'] == 'Intel') {
$intel = 1;
} else {
$intel = 0;
}
- //offsets are from TIFF header which is 12 bytes from the start of the file
+ //offsets are from TIFF header which is 12 bytes from the start of the
+ //file
$v = fseek($seek, $globalOffset + $offset);
if ($v == -1) {
$result['Errors'] = $result['Errors']++;
if ($intel == 1) {
$tag = Horde_Image_Exif::intel2Moto($tag);
}
- $tag_name = self::_lookupTag($tag);
+ $tag_name = $this->_lookupTag($tag);
//2 byte datatype
$type = bin2hex(substr($block, $place, 2));
if ($intel == 1) {
$type = Horde_Image_Exif::intel2Moto($type);
}
- self::_lookupType($type, $size);
+ $this->_lookupType($type, $size);
//4 byte number of elements
$count = bin2hex(substr($block, $place, 4));
if ($intel == 1) {
$value = Horde_Image_Exif::intel2Moto($value);
}
- //offsets are from TIFF header which is 12 bytes from the start of the file
+ //offsets are from TIFF header which is 12 bytes from the start
+ //of the file
$v = fseek($seek, $globalOffset + hexdec($value));
if ($v == 0) {
$data = fread($seek, $bytesofdata);
$result['Errors'] = $result['Errors']++;
}
}
- $result['GPS' . $tag_name] = self::_formatData($type, $tag, $intel, $data);
+ $result['GPS' . $tag_name] = $this->_formatData($type, $tag, $intel, $data);
}
}
-
}
<?php
/**
- * @author Michael J. Rubinsky <mrubinsk@horde.org>
+ * @author Michael J. Rubinsky <mrubinsk@horde.org>
+ * @author Jan Schneider <jan@horde.org>
* @category Horde
- * @package Horde_Image
+ * @package Image
*/
-/*
- Exifer
- Extracts EXIF information from digital photos.
-
- Copyright � 2003 Jake Olefsky
- http://www.offsky.com/software/exif/index.php
- jake@olefsky.com
-
- Please see exif.php for the complete information about this software.
-
- ------------
-
- This program is free software; you can redistribute it and/or modify it under the terms of
- the GNU General Public License as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
- without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- See the GNU General Public License for more details. http://www.gnu.org/copyleft/gpl.html
-*/
+/**
+ * Exifer
+ * Extracts EXIF information from digital photos.
+ *
+ * Copyright © 2003 Jake Olefsky
+ * http://www.offsky.com/software/exif/index.php
+ * jake@olefsky.com
+ *
+ * ------------
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details. http://www.gnu.org/copyleft/gpl.html
+ */
class Horde_Image_Exif_Parser_Nikon extends Horde_Image_Exif_Parser_Base
{
/**
* @param $model
* @return unknown_type
*/
- static protected function _lookupTag($tag,$model)
+ protected function _lookupTag($tag, $model)
{
- if($model==0) {
+ switch ($model) {
+ case 0:
switch($tag) {
- case "0003": $tag = "Quality";break;
- case "0004": $tag = "ColorMode";break;
- case "0005": $tag = "ImageAdjustment";break;
- case "0006": $tag = "CCDSensitivity";break;
- case "0007": $tag = "WhiteBalance";break;
- case "0008": $tag = "Focus";break;
- case "0009": $tag = "Unknown2";break;
- case "000a": $tag = "DigitalZoom";break;
- case "000b": $tag = "Converter";break;
-
- default: $tag = "unknown:".$tag;break;
+ case '0003': $tag = 'Quality'; break;
+ case '0004': $tag = 'ColorMode'; break;
+ case '0005': $tag = 'ImageAdjustment'; break;
+ case '0006': $tag = 'CCDSensitivity'; break;
+ case '0007': $tag = 'WhiteBalance'; break;
+ case '0008': $tag = 'Focus'; break;
+ case '0009': $tag = 'Unknown2'; break;
+ case '000a': $tag = 'DigitalZoom'; break;
+ case '000b': $tag = 'Converter'; break;
+ default: $tag = 'unknown: ' . $tag; break;
}
- } else if($model==1) {
+ break;
+
+ case 1:
switch($tag) {
- case "0002": $tag = "ISOSetting";break;
- case "0003": $tag = "ColorMode";break;
- case "0004": $tag = "Quality";break;
- case "0005": $tag = "Whitebalance";break;
- case "0006": $tag = "ImageSharpening";break;
- case "0007": $tag = "FocusMode";break;
- case "0008": $tag = "FlashSetting";break;
- case "0009": $tag = "FlashMode";break;
- case "000b": $tag = "WhiteBalanceFine";break;
- case "000f": $tag = "ISOSelection";break;
- case "0013": $tag = "ISOSelection2";break;
- case "0080": $tag = "ImageAdjustment";break;
- case "0081": $tag = "ToneCompensation";break;
- case "0082": $tag = "Adapter";break;
- case "0083": $tag = "LensType";break;
- case "0084": $tag = "LensInfo";break;
- case "0085": $tag = "ManualFocusDistance";break;
- case "0086": $tag = "DigitalZoom";break;
- case "0087": $tag = "FlashUsed";break;
- case "0088": $tag = "AFFocusPosition";break;
- case "008d": $tag = "ColorMode";break;
- case "0090": $tag = "LightType";break;
- case "0094": $tag = "Saturation";break;
- case "0095": $tag = "NoiseReduction";break;
- case "0010": $tag = "DataDump";break;
-
- default: $tag = "unknown:".$tag;break;
+ case '0002': $tag = 'ISOSetting'; break;
+ case '0003': $tag = 'ColorMode'; break;
+ case '0004': $tag = 'Quality'; break;
+ case '0005': $tag = 'Whitebalance'; break;
+ case '0006': $tag = 'ImageSharpening'; break;
+ case '0007': $tag = 'FocusMode'; break;
+ case '0008': $tag = 'FlashSetting'; break;
+ case '0009': $tag = 'FlashMode'; break;
+ case '000b': $tag = 'WhiteBalanceFine'; break;
+ case '000f': $tag = 'ISOSelection'; break;
+ case '0013': $tag = 'ISOSelection2'; break;
+ case '0080': $tag = 'ImageAdjustment'; break;
+ case '0081': $tag = 'ToneCompensation'; break;
+ case '0082': $tag = 'Adapter'; break;
+ case '0083': $tag = 'LensType'; break;
+ case '0084': $tag = 'LensInfo'; break;
+ case '0085': $tag = 'ManualFocusDistance'; break;
+ case '0086': $tag = 'DigitalZoom'; break;
+ case '0087': $tag = 'FlashUsed'; break;
+ case '0088': $tag = 'AFFocusPosition'; break;
+ case '008d': $tag = 'ColorMode'; break;
+ case '0090': $tag = 'LightType'; break;
+ case '0094': $tag = 'Saturation'; break;
+ case '0095': $tag = 'NoiseReduction'; break;
+ case '0010': $tag = 'DataDump'; break;
+ default: $tag = 'unknown: ' . $tag; break;
}
+ break;
}
return $tag;
* @param $data
* @return unknown_type
*/
- static protected function _formatData($type,$tag,$intel,$model,$data)
+ protected function _formatData($type, $tag, $intel, $model, $data)
{
- if ($type != "ASCII" && ($type=="URATIONAL" || $type=="SRATIONAL")) {
+ switch ($type) {
+ case 'URATIONAL':
+ case 'SRATIONAL':
$data = bin2hex($data);
- if($intel==1) $data = Horde_Image_Exif::intel2Moto($data);
- $top = hexdec(substr($data,8,8));
- $bottom = hexdec(substr($data,0,8));
- if($bottom!=0) $data=$top/$bottom;
- else if($top==0) $data = 0;
- else $data=$top."/".$bottom;
-
- if($tag=="0085" && $model==1) { //ManualFocusDistance
- $data=$data." m";
- }
- if($tag=="0086" && $model==1) { //DigitalZoom
- $data=$data."x";
+ if ($intel) {
+ $data = Horde_Image_Exif::intel2Moto($data);
}
- if($tag=="000a" && $model==0) { //DigitalZoom
- $data=$data."x";
+ $top = hexdec(substr($data, 8, 8));
+ $bottom = hexdec(substr($data, 0, 8));
+ if ($bottom != 0) {
+ $data = $top / $bottom;
+ } elseif ($top == 0) {
+ $data = 0;
+ } else {
+ $data = $top . '/' . $bottom;
}
- } else if($type=="USHORT" || $type=="SSHORT" || $type=="ULONG" || $type=="SLONG" || $type=="FLOAT" || $type=="DOUBLE") {
- $data = bin2hex($data);
- if($intel==1) $data = Horde_Image_Exif::intel2Moto($data);
- $data=hexdec($data);
-
- if($tag=="0003" && $model==0) { //Quality
- if($data == 1) $data = _("VGA Basic");
- else if($data == 2) $data = _("VGA Normal");
- else if($data == 3) $data = _("VGA Fine");
- else if($data == 4) $data = _("SXGA Basic");
- else if($data == 5) $data = _("SXGA Normal");
- else if($data == 6) $data = _("SXGA Fine");
- else $data = _("Unknown").": ".$data;
+
+ if ($tag == '0085' && $model == 1) {
+ //ManualFocusDistance
+ $data = $data . ' m';
}
- if($tag=="0004" && $model==0) { //Color
- if($data == 1) $data = _("Color");
- else if($data == 2) $data = _("Monochrome");
- else $data = _("Unknown").": ".$data;
+ if ($tag == '0086' && $model == 1) {
+ //DigitalZoom
+ $data = $data . 'x';
}
- if($tag=="0005" && $model==0) { //Image Adjustment
- if($data == 0) $data = _("Normal");
- else if($data == 1) $data = _("Bright+");
- else if($data == 2) $data = _("Bright-");
- else if($data == 3) $data = _("Contrast+");
- else if($data == 4) $data = _("Contrast-");
- else $data = _("Unknown").": ".$data;
+ if ($tag == '000a' && $model == 0) {
+ //DigitalZoom
+ $data = $data . 'x';
}
- if($tag=="0006" && $model==0) { //CCD Sensitivity
- if($data == 0) $data = "ISO-80";
- else if($data == 2) $data = "ISO-160";
- else if($data == 4) $data = "ISO-320";
- else if($data == 5) $data = "ISO-100";
- else $data = _("Unknown").": ".$data;
+ break;
+
+ case 'USHORT':
+ case 'SSHORT':
+ case 'ULONG':
+ case 'SLONG':
+ case 'FLOAT':
+ case 'DOUBLE':
+ $data = bin2hex($data);
+ if ($intel) {
+ $data = Horde_Image_Exif::intel2Moto($data);
}
- if($tag=="0007" && $model==0) { //White Balance
- if($data == 0) $data = _("Auto");
- else if($data == 1) $data = _("Preset");
- else if($data == 2) $data = _("Daylight");
- else if($data == 3) $data = _("Incandescense");
- else if($data == 4) $data = _("Flourescence");
- else if($data == 5) $data = _("Cloudy");
- else if($data == 6) $data = _("SpeedLight");
- else $data = _("Unknown").": ".$data;
+ $data = hexdec($data);
+ if ($model != 0) {
+ break;
}
- if($tag=="000b" && $model==0) { //Converter
- if($data == 0) $data = _("None");
- else if($data == 1) $data = _("Fisheye");
- else $data = _("Unknown").": ".$data;
+
+ switch ($tag) {
+ case '0003':
+ //Quality
+ switch ($data) {
+ case 1: $data = _("VGA Basic"); break;
+ case 2: $data = _("VGA Normal"); break;
+ case 3: $data = _("VGA Fine"); break;
+ case 4: $data = _("SXGA Basic"); break;
+ case 5: $data = _("SXGA Normal"); break;
+ case 6: $data = _("SXGA Fine"); break;
+ default: $data = _("Unknown") . ': ' . $data; break;
+ }
+ break;
+
+ case '0004':
+ //Color
+ switch ($data) {
+ case 1: $data = _("Color"); break;
+ case 2: $data = _("Monochrome"); break;
+ default: $data = _("Unknown") . ': ' . $data; break;
+ }
+ break;
+
+ case '0005':
+ //Image Adjustment
+ switch ($data) {
+ case 0: $data = _("Normal"); break;
+ case 1: $data = _("Bright+"); break;
+ case 2: $data = _("Bright-"); break;
+ case 3: $data = _("Contrast+"); break;
+ case 4: $data = _("Contrast-"); break;
+ default: $data = _("Unknown") . ': ' . $data; break;
+ }
+ break;
+
+ case '0006':
+ //CCD Sensitivity
+ switch ($data) {
+ case 0: $data = 'ISO-80'; break;
+ case 2: $data = 'ISO-160'; break;
+ case 4: $data = 'ISO-320'; break;
+ case 5: $data = 'ISO-100'; break;
+ default: $data = _("Unknown") . ': ' . $data; break;
+ }
+ break;
+
+ case '0007':
+ //White Balance
+ switch ($data) {
+ case 0: $data = _("Auto"); break;
+ case 1: $data = _("Preset"); break;
+ case 2: $data = _("Daylight"); break;
+ case 3: $data = _("Incandescense"); break;
+ case 4: $data = _("Flourescence"); break;
+ case 5: $data = _("Cloudy"); break;
+ case 6: $data = _("SpeedLight"); break;
+ default: $data = _("Unknown") . ': ' . $data; break;
+ }
+ break;
+
+ case '000b':
+ //Converter
+ switch ($data) {
+ case 0: $data = _("None"); break;
+ case 1: $data = _("Fisheye"); break;
+ default: $data = _("Unknown") . ': ' . $data; break;
+ }
+ break;
}
- } else if($type=="UNDEFINED") {
- if($tag=="0001" && $model==1) { //Unknown (Version?)
- $data=$data/100;
+ case 'UNDEFINED':
+ if ($model != 1) {
+ break;
}
- if($tag=="0088" && $model==1) { //AF Focus Position
+
+ switch ($tag) {
+ case '0001':
+ $data = $data/100;
+ break;
+ case '0088':
+ //AF Focus Position
$temp = _("Center");
$data = bin2hex($data);
- $data = str_replace("01","Top",$data);
- $data = str_replace("02","Bottom",$data);
- $data = str_replace("03","Left",$data);
- $data = str_replace("04","Right",$data);
- $data = str_replace("00","",$data);
- if(strlen($data)==0) $data = $temp;
+ $data = str_replace('01', 'Top', $data);
+ $data = str_replace('02', 'Bottom', $data);
+ $data = str_replace('03', 'Left', $data);
+ $data = str_replace('04', 'Right', $data);
+ $data = str_replace('00', '', $data);
+ if (!strlen($data)) {
+ $data = $temp;
+ }
+ break;
}
+ break;
- } else {
+ default:
$data = bin2hex($data);
- if($intel==1) $data = Horde_Image_Exif::intel2Moto($data);
-
- if($tag=="0083" && $model==1) { //Lens Type
- $data = hexdec(substr($data,0,2));
- if($data == 0) $data = _("AF non D");
- else if($data == 1) $data = _("Manual");
- else if($data == 2) $data = "AF-D or AF-S";
- else if($data == 6) $data = "AF-D G";
- else if($data == 10) $data = "AF-D VR";
- else $data = _("Unknown").": ".$data;
+ if ($intel) {
+ $data = Horde_Image_Exif::intel2Moto($data);
}
- if($tag=="0087" && $model==1) { //Flash type
- $data = hexdec(substr($data,0,2));
- if($data == 0) $data = _("Did Not Fire");
- else if($data == 4) $data = _("Unknown");
- else if($data == 7) $data = _("External");
- else if($data == 9) $data = _("On Camera");
- else $data = _("Unknown").": ".$data;
+ if ($model != 1) {
+ break;
}
+
+ switch ($tag) {
+ case '0083':
+ //Lens Type
+ $data = hexdec(substr($data, 0, 2));
+ switch ($data) {
+ case 0: $data = _("AF non D"); break;
+ case 1: $data = _("Manual"); break;
+ case 2: $data = 'AF-D or AF-S'; break;
+ case 6: $data = 'AF-D G'; break;
+ case 10: $data = 'AF-D VR'; break;
+ default: $data = _("Unknown") . ': ' . $data; break;
+ }
+ break;
+
+ case '0087':
+ //Flash type
+ $data = hexdec(substr($data,0,2));
+ switch ($data) {
+ case 0: $data = _("Did Not Fire"); break;
+ case 4: $data = _("Unknown"); break;
+ case 7: $data = _("External"); break;
+ case 9: $data = _("On Camera"); break;
+ default: $data = _("Unknown") . ': ' . $data; break;
+ }
+ break;
+ }
+
+ break;
}
return $data;
* @param $result
* @return unknown_type
*/
- static public function parse($block,&$result)
+ public function parse($block, &$result)
{
- if($result['Endien']=="Intel") $intel=1;
- else $intel=0;
-
+ $intel = $result['Endien'] == 'Intel';
$model = $result['IFD0']['Model'];
//these 6 models start with "Nikon". Other models dont.
- if($model=="E700\0" || $model=="E800\0" || $model=="E900\0" || $model=="E900S\0" || $model=="E910\0" || $model=="E950\0") {
- $place=8; //current place
+ if ($model == "E700\0" ||
+ $model == "E800\0" ||
+ $model == "E900\0" ||
+ $model == "E900S\0" ||
+ $model == "E910\0" ||
+ $model == "E950\0") {
+ //current place
+ $place = 8;
$model = 0;
//Get number of tags (2 bytes)
- $num = bin2hex(substr($block,$place,2));$place+=2;
- if($intel==1) $num = Horde_Image_Exif::intel2Moto($num);
+ $num = bin2hex(substr($block, $place, 2));
+ $place += 2;
+ if ($intel) {
+ $num = Horde_Image_Exif::intel2Moto($num);
+ }
$result['SubIFD']['MakerNote']['MakerNoteNumTags'] = hexdec($num);
//loop thru all tags Each field is 12 bytes
- for($i=0;$i<hexdec($num);$i++) {
+ for ($i = 0; $i < hexdec($num); $i++) {
//2 byte tag
- $tag = bin2hex(substr($block,$place,2));$place+=2;
- if($intel==1) $tag = Horde_Image_Exif::intel2Moto($tag);
- $tag_name = self::_lookupTag($tag, $model);
+ $tag = bin2hex(substr($block, $place, 2));
+ $place += 2;
+ if ($intel) {
+ $tag = Horde_Image_Exif::intel2Moto($tag);
+ }
+ $tag_name = $this->_lookupTag($tag, $model);
//2 byte type
- $type = bin2hex(substr($block,$place,2));$place+=2;
- if($intel==1) $type = Horde_Image_Exif::intel2Moto($type);
- self::_lookupType($type,$size);
+ $type = bin2hex(substr($block, $place, 2));
+ $place += 2;
+ if ($intel) {
+ $type = Horde_Image_Exif::intel2Moto($type);
+ }
+ $this->_lookupType($type, $size);
//4 byte count of number of data units
- $count = bin2hex(substr($block,$place,4));$place+=4;
- if($intel==1) $count = Horde_Image_Exif::intel2Moto($count);
- $bytesofdata = $size*hexdec($count);
+ $count = bin2hex(substr($block, $place, 4));
+ $place += 4;
+ if ($intel) {
+ $count = Horde_Image_Exif::intel2Moto($count);
+ }
+ $bytesofdata = $size * hexdec($count);
//4 byte value of data or pointer to data
- $value = substr($block,$place,4);$place+=4;
+ $value = substr($block, $place, 4);
+ $place += 4;
//if tag is 0002 then its the ASCII value which we know is at 140 so calc offset
//THIS HACK ONLY WORKS WITH EARLY NIKON MODELS
- if($tag=="0002") $offset = hexdec($value)-140;
- if($bytesofdata<=4) {
+ if ($tag == '0002') {
+ $offset = hexdec($value) - 140;
+ }
+ if ($bytesofdata <= 4) {
$data = $value;
} else {
$value = bin2hex($value);
- if($intel==1) $value = Horde_Image_Exif::intel2Moto($value);
- $data = substr($block,hexdec($value)-$offset,$bytesofdata*2);
+ if ($intel) {
+ $value = Horde_Image_Exif::intel2Moto($value);
+ }
+ $data = substr($block, hexdec($value) - $offset, $bytesofdata * 2);
}
- $formated_data = self::_formatData($type,$tag,$intel,$model,$data);
+ $formated_data = $this->_formatData($type, $tag, $intel, $model, $data);
$result['SubIFD']['MakerNote'][$tag_name] = $formated_data;
}
-
} else {
- $place=0;//current place
+ //current place
+ $place = 0;
$model = 1;
- $nikon = substr($block,$place,8);$place+=8;
- $endien = substr($block,$place,4);$place+=4;
+ $nikon = substr($block, $place, 8);
+ $place += 8;
+ $endien = substr($block, $place, 4);
+ $place += 4;
//2 bytes of 0x002a
- $tag = bin2hex(substr($block,$place,2));$place+=2;
-
- //Then 4 bytes of offset to IFD0 (usually 8 which includes all 8 bytes of TIFF header)
- $offset = bin2hex(substr($block,$place,4));$place+=4;
- if($intel==1) $offset = Horde_Image_Exif::intel2Moto($offset);
- if(hexdec($offset)>8) $place+=$offset-8;
+ $tag = bin2hex(substr($block, $place, 2));
+ $place += 2;
+
+ //Then 4 bytes of offset to IFD0 (usually 8 which includes all 8
+ //bytes of TIFF header)
+ $offset = bin2hex(substr($block, $place, 4));
+ $place += 4;
+ if ($intel) {
+ $offset = Horde_Image_Exif::intel2Moto($offset);
+ }
+ if (hexdec($offset) > 8) {
+ $place += $offset - 8;
+ }
//Get number of tags (2 bytes)
- $num = bin2hex(substr($block,$place,2));$place+=2;
- if($intel==1) $num = Horde_Image_Exif::intel2Moto($num);
+ $num = bin2hex(substr($block, $place, 2));
+ $place += 2;
+ if ($intel) {
+ $num = Horde_Image_Exif::intel2Moto($num);
+ }
//loop thru all tags Each field is 12 bytes
- for($i=0;$i<hexdec($num);$i++) {
+ for ($i = 0; $i < hexdec($num); $i++) {
//2 byte tag
- $tag = bin2hex(substr($block,$place,2));$place+=2;
- if($intel==1) $tag = Horde_Image_Exif::intel2Moto($tag);
- $tag_name = self::_lookupTag($tag, $model);
+ $tag = bin2hex(substr($block, $place, 2));
+ $place += 2;
+ if ($intel) {
+ $tag = Horde_Image_Exif::intel2Moto($tag);
+ }
+ $tag_name = $this->_lookupTag($tag, $model);
//2 byte type
- $type = bin2hex(substr($block,$place,2));$place+=2;
- if($intel==1) $type = Horde_Image_Exif::intel2Moto($type);
- self::_lookupType($type,$size);
+ $type = bin2hex(substr($block, $place, 2));
+ $place += 2;
+ if ($intel) {
+ $type = Horde_Image_Exif::intel2Moto($type);
+ }
+ $this->_lookupType($type, $size);
//4 byte count of number of data units
- $count = bin2hex(substr($block,$place,4));$place+=4;
- if($intel==1) $count = Horde_Image_Exif::intel2Moto($count);
- $bytesofdata = $size*hexdec($count);
+ $count = bin2hex(substr($block, $place, 4));
+ $place += 4;
+ if ($intel) {
+ $count = Horde_Image_Exif::intel2Moto($count);
+ }
+ $bytesofdata = $size * hexdec($count);
//4 byte value of data or pointer to data
- $value = substr($block,$place,4);$place+=4;
+ $value = substr($block, $place, 4);
+ $place += 4;
- if($bytesofdata<=4) {
+ if ($bytesofdata <= 4) {
$data = $value;
} else {
$value = bin2hex($value);
- if($intel==1) $value = Horde_Image_Exif::intel2Moto($value);
- $data = substr($block,hexdec($value)+hexdec($offset)+2,$bytesofdata);
+ if ($intel) {
+ $value = Horde_Image_Exif::intel2Moto($value);
+ }
+ $data = substr($block, hexdec($value) + hexdec($offset) + 2, $bytesofdata);
}
- $formated_data = self::_formatData($type,$tag,$intel,$model,$data);
+ $formated_data = $this->_formatData($type, $tag, $intel, $model, $data);
$result['SubIFD']['MakerNote'][$tag_name] = $formated_data;
}
}
-
}
-
}
\ No newline at end of file
<?php
/**
- * @author Michael J. Rubinsky <mrubinsk@horde.org>
+ * @author Michael J. Rubinsky <mrubinsk@horde.org>
+ * @author Jan Schneider <jan@horde.org>
* @category Horde
- * @package Horde_Image
+ * @package Image
*/
-/*
- Exifer
- Extracts EXIF information from digital photos.
-
- Copyright � 2003 Jake Olefsky
- http://www.offsky.com/software/exif/index.php
- jake@olefsky.com
-
- Please see exif.php for the complete information about this software.
-
- ------------
-
- This program is free software; you can redistribute it and/or modify it under the terms of
- the GNU General Public License as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
- without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- See the GNU General Public License for more details. http://www.gnu.org/copyleft/gpl.html
-*/
+/**
+ * Exifer
+ * Extracts EXIF information from digital photos.
+ *
+ * Copyright © 2003 Jake Olefsky
+ * http://www.offsky.com/software/exif/index.php
+ * jake@olefsky.com
+ *
+ * ------------
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details. http://www.gnu.org/copyleft/gpl.html
+ */
class Horde_Image_Exif_Parser_Olympus extends Horde_Image_Exif_Parser_Base
{
/**
* @param $tag
* @return unknown_type
*/
- static protected function _lookupTag($tag)
+ protected function _lookupTag($tag)
{
switch($tag) {
- case "0200": $tag = "SpecialMode";break;
- case "0201": $tag = "JpegQual";break;
- case "0202": $tag = "Macro";break;
- case "0203": $tag = "Unknown1";break;
- case "0204": $tag = "DigiZoom";break;
- case "0205": $tag = "Unknown2";break;
- case "0206": $tag = "Unknown3";break;
- case "0207": $tag = "SoftwareRelease";break;
- case "0208": $tag = "PictInfo";break;
- case "0209": $tag = "CameraID";break;
- case "0f00": $tag = "DataDump";break;
-
- default: $tag = "unknown:".$tag;break;
+ case '0200': $tag = 'SpecialMode'; break;
+ case '0201': $tag = 'JpegQual'; break;
+ case '0202': $tag = 'Macro'; break;
+ case '0203': $tag = 'Unknown1'; break;
+ case '0204': $tag = 'DigiZoom'; break;
+ case '0205': $tag = 'Unknown2'; break;
+ case '0206': $tag = 'Unknown3'; break;
+ case '0207': $tag = 'SoftwareRelease'; break;
+ case '0208': $tag = 'PictInfo'; break;
+ case '0209': $tag = 'CameraID'; break;
+ case '0f00': $tag = 'DataDump'; break;
+ default: $tag = 'unknown: ' . $tag; break;
}
return $tag;
* @param $data
* @return unknown_type
*/
- static protected function _formatData($type,$tag,$intel,$data)
+ protected function _formatData($type, $tag, $intel, $data)
{
- if($type=="ASCII") {
+ switch ($type) {
+ case 'ASCII':
+ case 'UNDEFINED':
+ break;
- } else if($type=="URATIONAL" || $type=="SRATIONAL") {
+ case 'URATIONAL':
+ case 'SRATIONAL':
$data = bin2hex($data);
- if($intel==1) $data = Horde_Image_Exif::intel2Moto($data);
- $top = hexdec(substr($data,8,8));
- $bottom = hexdec(substr($data,0,8));
- if($bottom!=0) $data=$top/$bottom;
- else if($top==0) $data = 0;
- else $data=$top."/".$bottom;
-
- if($tag=="0204") { //DigitalZoom
- $data=$data."x";
+ if ($intel) {
+ $data = Horde_Image_Exif::intel2Moto($data);
}
- if($tag=="0205") { //Unknown2
- $data=$top."/".$bottom;
+ $top = hexdec(substr($data, 8, 8));
+ $bottom = hexdec(substr($data, 0, 8));
+ if ($bottom) {
+ $data = $top / $bottom;
+ } elseif (!$top) {
+ $data = 0;
+ } else {
+ $data = $top . '/' . $bottom;
}
- } else if($type=="USHORT" || $type=="SSHORT" || $type=="ULONG" || $type=="SLONG" || $type=="FLOAT" || $type=="DOUBLE") {
+
+ switch ($tag) {
+ case '0204':
+ //DigitalZoom
+ $data .= 'x';
+ break;
+ case '0205':
+ //Unknown2
+ $data = $top . '/' . $bottom;
+ break;
+ }
+ break;
+
+ case 'USHORT':
+ case 'SSHORT':
+ case 'ULONG':
+ case 'SLONG':
+ case 'FLOAT':
+ case 'DOUBLE':
$data = bin2hex($data);
- if($intel==1) $data = Horde_Image_Exif::intel2Moto($data);
- $data=hexdec($data);
-
- if($tag=="0201") { //JPEGQuality
- if($data == 1) $data = "SQ";
- else if($data == 2) $data = "HQ";
- else if($data == 3) $data = "SHQ";
- else $data = _("Unknown").": ".$data;
+ if ($intel) {
+ $data = Horde_Image_Exif::intel2Moto($data);
}
- if($tag=="0202") { //Macro
- if($data == 0) $data = "Normal";
- else if($data == 1) $data = "Macro";
- else $data = _("Unknown").": ".$data;
+ $data = hexdec($data);
+
+ switch ($tag) {
+ case '0201':
+ //JPEGQuality
+ switch ($data) {
+ case 1: $data = 'SQ'; break;
+ case 2: $data = 'HQ'; break;
+ case 3: $data = 'SHQ'; break;
+ default: $data = _("Unknown") . ': ' . $data; break;
+ }
+ break;
+ case '0202':
+ //Macro
+ switch ($data) {
+ case 0: $data = 'Normal'; break;
+ case 1: $data = 'Macro'; break;
+ default: $data = _("Unknown") . ': ' . $data; break;
+ }
+ break;
}
- } else if($type=="UNDEFINED") {
+ break;
- } else {
+ default:
$data = bin2hex($data);
- if($intel==1) $data = Horde_Image_Exif::intel2Moto($data);
+ if ($intel) {
+ $data = Horde_Image_Exif::intel2Moto($data);
+ }
+ break;
}
return $data;
* @param $globalOffset
* @return unknown_type
*/
- static public function parse($block, &$result, $seek, $globalOffset)
+ public function parse($block, &$result, $seek, $globalOffset)
{
- if($result['Endien']=="Intel") $intel = 1;
- else $intel = 0;
-
+ $intel = $result['Endien']=='Intel';
$model = $result['IFD0']['Model'];
- // New header for new DSLRs - Check for it because the
- // number of bytes that count the IFD fields differ in each case.
- // Fixed by Zenphoto 2/24/08
+ // New header for new DSLRs - Check for it because the number of bytes
+ // that count the IFD fields differ in each case. Fixed by Zenphoto
+ // 2/24/08
$new = false;
if (substr($block, 0, 8) == "OLYMPUS\x00") {
$new = true;
- } else if (substr($block, 0, 7) == "OLYMP\x00\x01"
- || substr($block, 0, 7) == "OLYMP\x00\x02") {
+ } elseif (substr($block, 0, 7) == "OLYMP\x00\x01" ||
+ substr($block, 0, 7) == "OLYMP\x00\x02") {
$new = false;
} else {
// Header does not match known Olympus headers.
// Get number of tags (1 or 2 bytes, depending on New or Old makernote)
$countfieldbits = $new ? 1 : 2;
- // New makernote repeats 1-byte value twice, so increment $place by 2 in either case.
- $num = bin2hex(substr($block, $place, $countfieldbits)); $place += 2;
- if ($intel == 1) $num = Horde_Image_Exif::intel2Moto($num);
+ // New makernote repeats 1-byte value twice, so increment $place by 2
+ // in either case.
+ $num = bin2hex(substr($block, $place, $countfieldbits));
+ $place += 2;
+ if ($intel) {
+ $num = Horde_Image_Exif::intel2Moto($num);
+ }
$ntags = hexdec($num);
$result['SubIFD']['MakerNote']['MakerNoteNumTags'] = $ntags;
//loop thru all tags Each field is 12 bytes
- for($i=0; $i < $ntags; $i++) {
+ for ($i = 0; $i < $ntags; $i++) {
//2 byte tag
- $tag = bin2hex(substr($block, $place,2));
+ $tag = bin2hex(substr($block, $place, 2));
$place += 2;
- if ($intel == 1) $tag = Horde_Image_Exif::intel2Moto($tag);
- $tag_name = self::_lookupTag($tag);
+ if ($intel) {
+ $tag = Horde_Image_Exif::intel2Moto($tag);
+ }
+ $tag_name = $this->_lookupTag($tag);
//2 byte type
- $type = bin2hex(substr($block, $place,2));
+ $type = bin2hex(substr($block, $place, 2));
$place += 2;
- if ($intel == 1) $type = Horde_Image_Exif::intel2Moto($type);
- self::_lookupType($type,$size);
+ if ($intel) {
+ $type = Horde_Image_Exif::intel2Moto($type);
+ }
+ $this->_lookupType($type, $size);
//4 byte count of number of data units
- $count = bin2hex(substr($block, $place,4));
- $place+=4;
- if ($intel == 1) $count = Horde_Image_Exif::intel2Moto($count);
+ $count = bin2hex(substr($block, $place, 4));
+ $place += 4;
+ if ($intel) {
+ $count = Horde_Image_Exif::intel2Moto($count);
+ }
$bytesofdata = $size * hexdec($count);
//4 byte value of data or pointer to data
- $value = substr($block, $place,4);
+ $value = substr($block, $place, 4);
$place += 4;
-
if ($bytesofdata <= 4) {
$data = $value;
} else {
$value = bin2hex($value);
- if($intel==1) $value = Horde_Image_Exif::intel2Moto($value);
- $v = fseek($seek,$globalOffset+hexdec($value)); //offsets are from TIFF header which is 12 bytes from the start of the file
+ if ($intel) {
+ $value = Horde_Image_Exif::intel2Moto($value);
+ }
+ //offsets are from TIFF header which is 12 bytes from the start
+ //of the file
+ $v = fseek($seek, $globalOffset + hexdec($value));
$result['Errors'] = $result['Errors']++;
$data = '';
-
}
- $formated_data = self::_formatData($type,$tag,$intel,$data);
+ $formated_data = $this->_formatData($type, $tag, $intel, $data);
$result['SubIFD']['MakerNote'][$tag_name] = $formated_data;
}
}
-
}
\ No newline at end of file
<?php
/**
- * @author Michael J. Rubinsky <mrubinsk@horde.org>
+ * @author Michael J. Rubinsky <mrubinsk@horde.org>
+ * @author Jan Schneider <jan@horde.org>
* @category Horde
- * @package Horde_Image
+ * @package Image
*/
/**
- * Exifer
- * Extracts EXIF information from digital photos.
+ * Exifer
+ * Extracts EXIF information from digital photos.
*
- * Copyright 2003 Jake Olefsky
- * http://www.offsky.com/software/exif/index.php
- * jake@olefsky.com
+ * Copyright © 2003 Jake Olefsky
+ * http://www.offsky.com/software/exif/index.php
+ * jake@olefsky.com
*
- * Please see exif.php for the complete information about this software.
+ * ------------
*
- * ------------
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
*
- * This program is free software; you can redistribute it and/or modify it under the terms of
- * the GNU General Public License as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- * See the GNU General Public License for more details. http://www.gnu.org/copyleft/gpl.html
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details. http://www.gnu.org/copyleft/gpl.html
*/
class Horde_Image_Exif_Parser_Panasonic extends Horde_Image_Exif_Parser_Base
{
/**
* Looks up the name of the tag for the MakerNote (Depends on Manufacturer)
*/
- static protected function _lookupTag($tag)
+ protected function _lookupTag($tag)
{
switch ($tag) {
case '0001': $tag = 'Quality'; break;
/**
* Formats Data for the data type
*/
- static protected function _formatData($type,$tag,$intel,$data)
+ protected function _formatData($type, $tag, $intel, $data)
{
- if ($type == 'UBYTE' || $type == 'SBYTE') {
+ switch ($type) {
+ case 'UBYTE':
+ case 'SBYTE':
$data = bin2hex($data);
- if ($intel == 1) {
+ if ($intel) {
$data = Horde_Image_Exif::intel2Moto($data);
}
$data = hexdec($data);
- if ($tag == '000f') { //AFMode
- if ($data == 256) {
+ if ($tag == '000f') {
+ //AFMode
+ switch ($data) {
+ case 256:
$data = _("9-area-focusing");
- } elseif ($data == 16) {
+ break;
+ case 16:
$data = _("1-area-focusing");
- } elseif ($data == 4096) {
+ break;
+ case 4096:
$data = _("3-area-focusing (High speed)");
- } elseif ($data == 4112) {
+ break;
+ case 4112:
$data = _("1-area-focusing (High speed)");
- } elseif ($data == 16) {
+ break;
+ case 16:
$data = _("1-area-focusing");
- } elseif ($data == 1) {
+ break;
+ case 1:
$data = _("Spot-focusing");
- } else {
+ break;
+ default:
$data = sprintf(_("Unknown (%s)"), $data);
+ break;
}
}
+ break;
- } elseif ($type == 'URATIONAL' || $type == 'SRATIONAL') {
+ case 'URATIONAL':
+ case 'SRATIONAL':
$data = bin2hex($data);
- if ($intel == 1) {
+ if ($intel) {
$data = Horde_Image_Exif::intel2Moto($data);
}
$top = hexdec(substr($data, 8, 8));
$bottom = hexdec(substr($data, 0, 8));
- if ($bottom!=0) {
+ if ($bottom != 0) {
$data = $top / $bottom;
} elseif ($top == 0) {
$data = 0;
} else {
$data = $top . '/' . $bottom;
}
+ break;
- } elseif ($type == 'USHORT' || $type == 'SSHORT' || $type == 'ULONG' ||
- $type == 'SLONG' || $type == 'FLOAT' || $type == 'DOUBLE') {
-
+ case 'USHORT':
+ case 'SSHORT':
+ case 'ULONG':
+ case 'SLONG':
+ case 'FLOAT':
+ case 'DOUBLE':
$data = bin2hex($data);
- if ($intel == 1) {
+ if ($intel) {
$data = Horde_Image_Exif::intel2Moto($data);
}
$data = hexdec($data);
- if ($tag == '0001') { //Image Quality
- if ($data == 2) {
+ switch ($tag) {
+ case '0001':
+ //Image Quality
+ switch ($data) {
+ case 2:
$data = _("High");
- } elseif ($data == 3) {
+ break;
+ case 3:
$data = _("Standard");
- } elseif ($data == 6) {
+ break;
+ case 6:
$data = _("Very High");
- } elseif ($data == 7) {
+ break;
+ case 7:
$data = _("RAW");
- } else {
+ break;
+ default:
$data = sprintf(_("Unknown (%s)"), $data);
+ break;
}
- }
- if ($tag == '0003') { //White Balance
- if ($data == 1) {
+ break;
+
+ case '0003':
+ //White Balance
+ switch ($data) {
+ case 1:
$data = _("Auto");
- } elseif ($data == 2) {
+ break;
+ case 2:
$data = _("Daylight");
- } elseif ($data == 3) {
+ break;
+ case 3:
$data = _("Cloudy");
- } elseif ($data == 4) {
+ break;
+ case 4:
$data = _("Halogen");
- } elseif ($data == 5) {
+ break;
+ case 5:
$data = _("Manual");
- } elseif ($data == 8) {
+ break;
+ case 8:
$data = _("Flash");
- } elseif ($data == 10) {
+ break;
+ case 10:
$data = _("Black and White");
- } elseif ($data == 11) {
+ break;
+ case 11:
$data = _("Manual");
- } else {
+ break;
+ default:
$data = sprintf(_("Unknown(%s)"), $data);
+ break;
}
- }
- if ($tag=='0007') { //Focus Mode
- if ($data == 1) {
+ break;
+
+ case '0007':
+ //Focus Mode
+ switch ($data) {
+ case 1:
$data = _("Auto");
- } elseif ($data == 2) {
+ break;
+ case 2:
$data = _("Manual");
- } elseif ($data == 4) {
+ break;
+ case 4:
$data = _("Auto, Focus button");
- } elseif ($data == 5) {
+ break;
+ case 5:
$data = _("Auto, Continuous");
- } else {
+ break;
+ default:
$data = sprintf(_("Unknown(%s)"), $data);
+ break;
}
- }
- if ($tag == '001a') { //Image Stabilizer
- if ($data == 2) {
+ break;
+
+ case '001a':
+ //Image Stabilizer
+ switch ($data) {
+ case 2:
$data = _("Mode 1");
- } elseif ($data == 3) {
+ break;
+ case 3:
$data = _("Off");
- } elseif ($data == 4) {
+ break;
+ case 4:
$data = _("Mode 2");
- } else {
+ break;
+ default:
$data = sprintf(_("Unknown(%s)"), $data);
+ break;
}
- }
- if ($tag == '001c') { //Macro mode
- if ($data == 1) {
+ break;
+
+ case '001c':
+ //Macro mode
+ switch ($data) {
+ case 1:
$data = _("On");
- } elseif ($data == 2) {
+ break;
+ case 2:
$data = _("Off");
- } else {
+ break;
+ default:
$data = sprintf(_("Unknown(%s)"), $data);
+ break;
}
- }
- if ($tag == '001f') { //Shooting Mode
- if ($data == 1) {
+ break;
+
+ case '001f':
+ //Shooting Mode
+ switch ($data) {
+ case 1:
$data = _("Normal");
- } elseif ($data == 2) {
+ break;
+ case 2:
$data = _("Portrait");
- } elseif ($data == 3) {
+ break;
+ case 3:
$data = _("Scenery");
- } elseif ($data == 4) {
+ break;
+ case 4:
$data = _("Sports");
- } elseif ($data == 5) {
+ break;
+ case 5:
$data = _("Night Portrait");
- } elseif ($data == 6) {
+ break;
+ case 6:
$data = _("Program");
- } elseif ($data == 7) {
+ break;
+ case 7:
$data = _("Aperture Priority");
- } elseif ($data == 8) {
+ break;
+ case 8:
$data = _("Shutter Priority");
- } elseif ($data == 9) {
+ break;
+ case 9:
$data = _("Macro");
- } elseif ($data == 11) {
+ break;
+ case 11:
$data = _("Manual");
- } elseif ($data == 13) {
+ break;
+ case 13:
$data = _("Panning");
- } elseif ($data == 14) {
+ break;
+ case 14:
$data = _("Simple");
- } elseif ($data == 18) {
+ break;
+ case 18:
$data = _("Fireworks");
- } elseif ($data == 19) {
+ break;
+ case 19:
$data = _("Party");
- } elseif ($data == 20) {
+ break;
+ case 20:
$data = _("Snow");
- } elseif ($data == 21) {
+ break;
+ case 21:
$data = _("Night Scenery");
- } elseif ($data == 22) {
+ break;
+ case 22:
$data = _("Food");
- } elseif ($data == 23) {
+ break;
+ case 23:
$data = _("Baby");
- } elseif ($data == 27) {
+ break;
+ case 27:
$data = _("High Sensitivity");
- } elseif ($data == 29) {
+ break;
+ case 29:
$data = _("Underwater");
- } elseif ($data == 33) {
+ break;
+ case 33:
$data = _("Pet");
- } else {
+ break;
+ default:
$data = sprintf(_("Unknown(%s)"), $data);
+ break;
}
- }
- if ($tag == '0020') { //Audio
- if ($data == 1) {
+ break;
+
+ case '0020':
+ //Audio
+ switch ($data) {
+ case 1:
$data = _("Yes");
- } elseif ($data == 2) {
+ break;
+ case 2:
$data = _("No");
- } else {
+ break;
+ default:
$data = sprintf(_("Unknown (%s)"), $data);
+ break;
}
- }
- if ($tag == '0023') { //White Balance Bias
+ break;
+
+ case '0023':
+ //White Balance Bias
$data = $data . ' EV';
- }
- if ($tag == '0024') { //Flash Bias
+ break;
+
+ case '0024':
+ //Flash Bias
$data = $data;
- }
- if ($tag == '0028') { //Colour Effect
- if ($data == 1) {
+ break;
+
+ case '0028':
+ //Colour Effect
+ switch ($data) {
+ case 1:
$data = _("Off");
- } elseif ($data == 2) {
+ break;
+ case 2:
$data = _("Warm");
- } elseif ($data == 3) {
+ break;
+ case 3:
$data = _("Cool");
- } elseif ($data == 4) {
+ break;
+ case 4:
$data = _("Black and White");
- } elseif ($data == 5) {
+ break;
+ case 5:
$data = _("Sepia");
- } else {
+ break;
+ default:
$data = sprintf(_("Unknown (%s)"), $data);
+ break;
}
- }
- if ($tag == '002a') { //Burst Mode
- if ($data == 0) {
+ break;
+
+ case '002a':
+ //Burst Mode
+ switch ($data) {
+ case 0:
$data = _("Off");
- } elseif ($data == 1) {
+ break;
+ case 1:
$data = _("Low/High Quality");
- } elseif ($data == 2) {
+ break;
+ case 2:
$data = _("Infinite");
- } else {
+ break;
+ default:
$data = sprintf(_("Unknown (%s)"), $data);
+ break;
}
- }
- if ($tag == '002c') { //Contrast
- if ($data == 0) {
+ break;
+
+ case '002c':
+ //Contrast
+ switch ($data) {
+ case 0:
$data = _("Standard");
- } elseif ($data == 1) {
+ break;
+ case 1:
$data = _("Low");
- } elseif ($data == 2) {
+ break;
+ case 2:
$data = _("High");
- } else {
+ break;
+ default:
$data = sprintf(_("Unknown (%s)"), $data);
+ break;
}
- }
- if ($tag == '002d') { //Noise Reduction
- if ($data == 0) {
+ break;
+
+ case '002d':
+ //Noise Reduction
+ switch ($data) {
+ case 0:
$data = _("Standard");
- } elseif ($data == 1) {
+ break;
+ case 1:
$data = _("Low");
- } elseif ($data == 2) {
+ break;
+ case 2:
$data = _("High");
- } else {
+ break;
+ default:
$data = sprintf(_("Unknown (%s)"), $data);
+ break;
}
- }
- if ($tag == '002e') { //Self Timer
- if ($data == 1) {
+ break;
+
+ case '002e':
+ //Self Timer
+ switch ($data) {
+ case 1:
$data = _("Off");
- } elseif ($data == 2) {
+ break;
+ case 2:
$data = _("10s");
- } elseif ($data == 3) {
+ break;
+ case 3:
$data = _("2s");
- } else {
+ break;
+ default:
$data = sprintf(_("Unknown (%s)"), $data);
+ break;
}
- }
- if ($tag == '0030') { //Rotation
- if ($data == 1) {
+ break;
+
+ case '0030':
+ //Rotation
+ switch ($data) {
+ case 1:
$data = _("Horizontal (normal)");
- } elseif ($data == 6) {
+ break;
+ case 6:
$data = _("Rotate 90 CW");
- } elseif ($data == 8) {
+ break;
+ case 8:
$data = _("Rotate 270 CW");
- } else {
+ break;
+ default:
$data = sprintf(_("Unknown (%s)"), $data);
+ break;
}
- }
- if ($tag == '0032') { //Color Mode
- if ($data == 0) {
+ break;
+
+ case '0032':
+ //Color Mode
+ switch ($data) {
+ case 0:
$data = _("Normal");
- } elseif ($data == 1) {
+ break;
+ case 1:
$data = _("Natural");
- } else {
+ break;
+ default:
$data = sprintf(_("Unknown (%s)"), $data);
+ break;
}
- }
- if ($tag == '0036') { //Travel Day
+ break;
+
+ case '0036':
+ //Travel Day
$data = $data;
+ break;
}
- } elseif ($type != "UNDEFINED") {
+ break;
+
+ case 'UNDEFINED':
+ break;
+
+ default:
$data = bin2hex($data);
- if ($intel == 1) {
+ if ($intel) {
$data = Horde_Image_Exif::intel2Moto($data);
}
+ break;
}
return $data;
/**
* Panasonic Special data section
*/
- static public function parse($block, &$result)
+ public function parse($block, &$result)
{
- $intel = 1;
+ $intel = true;
$model = $result['IFD0']['Model'];
- $place = 8; //current place
+ //current place
+ $place = 8;
$offset = 8;
$num = bin2hex(substr($block, $place, 4));
$place += 4;
- if ($intel == 1) {
+ if ($intel) {
$num = Horde_Image_Exif::intel2Moto($num);
}
$result['SubIFD']['MakerNote']['Offset'] = hexdec($num);
//Get number of tags (2 bytes)
$num = bin2hex(substr($block, $place, 2));
- $place+=2;
+ $place += 2;
- if ($intel == 1) {
+ if ($intel) {
$num = Horde_Image_Exif::intel2Moto($num);
}
$result['SubIFD']['MakerNote']['MakerNoteNumTags'] = hexdec($num);
//loop thru all tags Each field is 12 bytes
- for($i = 0; $i < hexdec($num); $i++) {
+ for ($i = 0; $i < hexdec($num); $i++) {
//2 byte tag
$tag = bin2hex(substr($block, $place, 2));
$place += 2;
- if ($intel == 1) {
+ if ($intel) {
$tag = Horde_Image_Exif::intel2Moto($tag);
}
- $tag_name = self::_lookupTag($tag);
+ $tag_name = $this->_lookupTag($tag);
//2 byte type
$type = bin2hex(substr($block, $place, 2));
$place += 2;
- if ($intel == 1) {
+ if ($intel) {
$type = Horde_Image_Exif::intel2Moto($type);
}
- self::_lookupType($type, $size);
+ $this->_lookupType($type, $size);
//4 byte count of number of data units
$count = bin2hex(substr($block, $place, 4));
$place += 4;
- if ($intel == 1) {
+ if ($intel) {
$count = Horde_Image_Exif::intel2Moto($count);
}
$bytesofdata = $size * hexdec($count);
$data = $value;
} else {
$value = bin2hex($value);
- if ($intel == 1) {
+ if ($intel) {
$value = Horde_Image_Exif::intel2Moto($value);
}
$data = substr($block, hexdec($value) - $offset, $bytesofdata * 2);
}
- $formated_data = self::_formatData($type, $tag, $intel, $data);
+ $formated_data = $this->_formatData($type, $tag, $intel, $data);
$result['SubIFD']['MakerNote'][$tag_name] = $formated_data;
}
-
}
-
}
\ No newline at end of file
<?php
/**
- * @author Michael J. Rubinsky <mrubinsk@horde.org>
+ * @author Michael J. Rubinsky <mrubinsk@horde.org>
+ * @author Jan Schneider <jan@horde.org>
* @category Horde
- * @package Horde_Image
+ * @package Image
*/
-/*
- Exifer
- Extracts EXIF information from digital photos.
-
- Copyright � 2003 Jake Olefsky
- http://www.offsky.com/software/exif/index.php
- jake@olefsky.com
-
- Please see exif.php for the complete information about this software.
-
- ------------
-
- This program is free software; you can redistribute it and/or modify it under the terms of
- the GNU General Public License as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
- without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- See the GNU General Public License for more details. http://www.gnu.org/copyleft/gpl.html
-*/
+/**
+ * Exifer
+ * Extracts EXIF information from digital photos.
+ *
+ * Copyright © 2003 Jake Olefsky
+ * http://www.offsky.com/software/exif/index.php
+ * jake@olefsky.com
+ *
+ * ------------
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details. http://www.gnu.org/copyleft/gpl.html
+ */
class Horde_Image_Exif_Parser_Sanyo extends Horde_Image_Exif_Parser_Base
{
/**
* @param $tag
* @return unknown_type
*/
- static protected function _lookupTag($tag)
+ protected function _lookupTag($tag)
{
switch($tag) {
- case "0200": $tag = "SpecialMode";break;
- case "0201": $tag = "Quality";break;
- case "0202": $tag = "Macro";break;
- case "0203": $tag = "Unknown";break;
- case "0204": $tag = "DigiZoom";break;
- case "0f00": $tag = "DataDump";break;
- default: $tag = "unknown:".$tag;break;
+ case '0200': $tag = 'SpecialMode'; break;
+ case '0201': $tag = 'Quality'; break;
+ case '0202': $tag = 'Macro'; break;
+ case '0203': $tag = 'Unknown'; break;
+ case '0204': $tag = 'DigiZoom'; break;
+ case '0f00': $tag = 'DataDump'; break;
+ default: $tag = 'unknown:' . $tag; break;
}
return $tag;
* @param $data
* @return unknown_type
*/
- static protected function _formatData($type,$tag,$intel,$data)
+ protected function _formatData($type, $tag, $intel, $data)
{
- if($type=="ASCII") {
-
+ switch ($type) {
+ case 'ASCII':
+ case 'UNDEFINED':
+ break;
- } else if($type=="URATIONAL" || $type=="SRATIONAL") {
+ case 'URATIONAL':
+ case 'SRATIONAL':
$data = bin2hex($data);
- if($intel==1) $data = Horde_Image_Exif::intel2Moto($data);
- $top = hexdec(substr($data,8,8));
- $bottom = hexdec(substr($data,0,8));
- if($bottom!=0) $data=$top/$bottom;
- else if($top==0) $data = 0;
- else $data=$top."/".$bottom;
-
-
- } else if($type=="USHORT" || $type=="SSHORT" || $type=="ULONG" || $type=="SLONG" || $type=="FLOAT" || $type=="DOUBLE") {
- $data = bin2hex($data);
- if($intel==1) $data = Horde_Image_Exif::intel2Moto($data);
- $data=hexdec($data);
-
- if($tag=="0200") { //SpecialMode
- if($data == 0) $data = _("Normal");
- else $data = _("Unknown").": ".$data;
+ if ($intel) {
+ $data = Horde_Image_Exif::intel2Moto($data);
}
- if($tag=="0201") { //Quality
- if($data == 2) $data = _("High");
- else $data = _("Unknown").": ".$data;
+ $top = hexdec(substr($data, 8, 8));
+ $bottom = hexdec(substr($data, 0, 8));
+ if ($bottom) {
+ $data = $top / $bottom;
+ } elseif (!$top) {
+ $data = 0;
+ } else {
+ $data = $top . '/' . $bottom;
}
- if($tag=="0202") { //Macro
- if($data == 0) $data = _("Normal");
- else $data = _("Unknown").": ".$data;
+ break;
+
+ case 'USHORT':
+ case 'SSHORT':
+ case 'ULONG':
+ case 'SLONG':
+ case 'FLOAT':
+ case 'DOUBLE':
+ $data = bin2hex($data);
+ if ($intel) {
+ $data = Horde_Image_Exif::intel2Moto($data);
}
- } else if($type=="UNDEFINED") {
-
-
+ $data = hexdec($data);
+
+ switch ($tag) {
+ case '0200':
+ //SpecialMode
+ $data = $data == 0 ? _("Normal") : _("Unknown") . ': ' . $data;
+ break;
+ case '0201':
+ //Quality
+ $data = $data == 2 ? _("High") : _("Unknown") . ': ' . $data;
+ break;
+ case '0202':
+ //Macro
+ $data = $data == 0 ? _("Normal") : _("Unknown") . ': ' . $data;
+ break;
+ }
+ break;
- } else {
+ default:
$data = bin2hex($data);
- if($intel==1) $data = Horde_Image_Exif::intel2Moto($data);
+ if ($intel) {
+ $data = Horde_Image_Exif::intel2Moto($data);
+ }
}
return $data;
* @param $globalOffset
* @return unknown_type
*/
- static public function parse($block,&$result,$seek, $globalOffset)
+ public function parse($block, &$result, $seek, $globalOffset)
{
- if($result['Endien']=="Intel") $intel=1;
- else $intel=0;
-
+ $intel = $result['Endien']=='Intel';
$model = $result['IFD0']['Model'];
-
- $place=8; //current place
- $offset=8;
-
- //Get number of tags (2 bytes)
- $num = bin2hex(substr($block,$place,2));$place+=2;
- if($intel==1) $num = Horde_Image_Exif::intel2Moto($num);
+ //current place
+ $place = 8;
+ $offset = 8;
+
+ //Get number of tags (2 bytes)
+ $num = bin2hex(substr($block, $place, 2));
+ $place += 2;
+ if ($intel) {
+ $num = Horde_Image_Exif::intel2Moto($num);
+ }
$result['SubIFD']['MakerNote']['MakerNoteNumTags'] = hexdec($num);
//loop thru all tags Each field is 12 bytes
- for($i=0;$i<hexdec($num);$i++) {
-
- //2 byte tag
- $tag = bin2hex(substr($block,$place,2));$place+=2;
- if($intel==1) $tag = Horde_Image_Exif::intel2Moto($tag);
- $tag_name = self::_lookupTag($tag);
-
- //2 byte type
- $type = bin2hex(substr($block,$place,2));$place+=2;
- if($intel==1) $type = Horde_Image_Exif::intel2Moto($type);
- self::_lookupType($type,$size);
+ for ($i = 0; $i < hexdec($num); $i++) {
+ //2 byte tag
+ $tag = bin2hex(substr($block, $place, 2));
+ $place += 2;
+ if ($intel) {
+ $tag = Horde_Image_Exif::intel2Moto($tag);
+ }
+ $tag_name = $this->_lookupTag($tag);
- //4 byte count of number of data units
- $count = bin2hex(substr($block,$place,4));$place+=4;
- if($intel==1) $count = Horde_Image_Exif::intel2Moto($count);
- $bytesofdata = $size*hexdec($count);
+ //2 byte type
+ $type = bin2hex(substr($block, $place, 2));
+ $place += 2;
+ if ($intel) {
+ $type = Horde_Image_Exif::intel2Moto($type);
+ }
+ $this->_lookupType($type, $size);
- //4 byte value of data or pointer to data
- $value = substr($block,$place,4);$place+=4;
+ //4 byte count of number of data units
+ $count = bin2hex(substr($block, $place, 4));
+ $place += 4;
+ if ($intel) {
+ $count = Horde_Image_Exif::intel2Moto($count);
+ }
+ $bytesofdata = $size * hexdec($count);
+ //4 byte value of data or pointer to data
+ $value = substr($block, $place, 4);
+ $place += 4;
- if($bytesofdata<=4) {
+ if ($bytesofdata <= 4) {
$data = $value;
} else {
$value = bin2hex($value);
- if($intel==1) $value = Horde_Image_Exif::intel2Moto($value);
- $v = fseek($seek,$globalOffset+hexdec($value)); //offsets are from TIFF header which is 12 bytes from the start of the file
- if($v==0) {
+ if ($intel) {
+ $value = Horde_Image_Exif::intel2Moto($value);
+ }
+ //offsets are from TIFF header which is 12 bytes from the start
+ //of the file
+ $v = fseek($seek, $globalOffset + hexdec($value));
+ if ($v == 0) {
$data = fread($seek, $bytesofdata);
- } else if($v==-1) {
+ } elseif ($v == -1) {
$result['Errors'] = $result['Errors']++;
}
}
- $formated_data = self::_formatData($type,$tag,$intel,$data);
+ $formated_data = $this->_formatData($type, $tag, $intel, $data);
$result['SubIFD']['MakerNote'][$tag_name] = $formated_data;
}
}
-
-}
\ No newline at end of file
+}