Works equally well with either the built in php exif functions (if PHP compiled with exif support), the Exiftool package (more complete but slower), or the bundled exif library. Copyright 2003-2014 Horde LLC (http://www.horde.org/)
Author: Michael J. Rubinsky (mrubinsk@horde.org)
Author: Chuck Hagenbuch (chuck@horde.org)
Exemplo n.º 1
0
 public function testDescriptionFields()
 {
     $descFields = Horde_Image_Exif::getDescriptionFields();
     $this->assertTrue(array_key_exists('ImageDescription', $descFields));
     $this->assertTrue(array_key_exists('Description', $descFields));
     $this->assertTrue(array_key_exists('Caption-Abstract', $descFields));
 }
Exemplo n.º 2
0
Arquivo: Base.php Projeto: horde/horde
 /**
  * Process the EXIF data.
  *
  * @param array $exif  Array of EXIF data.
  *
  * @return array  An array of processed EXIF data.
  */
 protected function _processData($exif)
 {
     if (!$exif) {
         return array();
     }
     $results = array();
     $fields = Horde_Image_Exif::getFields($this);
     foreach ($fields as $field => $data) {
         $value = isset($exif[$field]) ? $exif[$field] : '';
         // Don't store empty fields.
         if ($value === '') {
             continue;
         }
         /* Special handling of GPS data */
         if ($data['type'] == 'gps') {
             $value = $this->_parseGPSData($exif[$field]);
             if (!empty($exif[$field . 'Ref']) && in_array($exif[$field . 'Ref'], array('S', 'South', 'W', 'West'))) {
                 $value = -abs($value);
             }
         }
         /* Date fields are converted to a timestamp.*/
         if ($data['type'] == 'date') {
             @(list($ymd, $hms) = explode(' ', $value, 2));
             @(list($year, $month, $day) = explode(':', $ymd, 3));
             if (!empty($hms) && !empty($year) && !empty($month) && !empty($day)) {
                 $time = "{$month}/{$day}/{$year} {$hms}";
                 $value = strtotime($time);
             }
         }
         if ($data['type'] == 'array' || is_array($value)) {
             if (is_array($value)) {
                 $value = implode(',', $value);
             }
         }
         $results[$field] = $value;
     }
     return $results;
 }
Exemplo n.º 3
0
 /**
  * Get the image's EXIF data.
  *
  * @param string $image  The path to an image.
  *
  * @return array  The exif data.
  */
 public function getData($image)
 {
     // Request the full stream of meta data in JSON format.
     // -j option outputs in JSON, appending '#' to the -TAG prevents
     // screen formatting.
     $categories = Horde_Image_Exif::getCategories();
     $tags = '';
     foreach (array('EXIF', 'IPTC', 'XMP') as $category) {
         foreach ($categories[$category] as $field => $value) {
             $tags .= ' -' . $field . '#';
         }
     }
     foreach ($categories['COMPOSITE'] as $field => $value) {
         $tags .= ' -' . $field;
     }
     $command = '-j' . $tags . ' ' . $image;
     $this->_logDebug('Command executed by Exiftool: ' . $command);
     $results = json_decode($this->_execute($command));
     $this->_logDebug('Results of Exiftool command: ' . print_r($results, true));
     if (is_array($results)) {
         return $this->_processData((array) array_pop($results));
     }
     throw new Horde_Image_Exception('Unknown error running exiftool command');
 }
Exemplo n.º 4
0
 /**
  *
  * @param $block
  * @param $result
  * @param $seek
  * @param $globalOffset
  * @return unknown_type
  */
 public function parse($block, &$result, $seek, $globalOffset)
 {
     $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 = false;
     if (substr($block, 0, 8) == "OLYMPUS") {
         $new = true;
     } elseif (substr($block, 0, 7) == "OLYMP" || substr($block, 0, 7) == "OLYMP") {
         $new = false;
     } else {
         // Header does not match known Olympus headers.
         // This is not a valid OLYMPUS Makernote.
         return false;
     }
     // Offset of IFD entry after Olympus header.
     $place = 8;
     $offset = 8;
     // 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) {
         $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++) {
         //2 byte tag
         $tag = bin2hex(substr($block, $place, 2));
         $place += 2;
         if ($intel) {
             $tag = Horde_Image_Exif::intel2Moto($tag);
         }
         $tag_name = $this->_lookupTag($tag);
         //2 byte type
         $type = bin2hex(substr($block, $place, 2));
         $place += 2;
         if ($intel) {
             $type = Horde_Image_Exif::intel2Moto($type);
         }
         list($type, $size) = $this->_lookupType($type);
         //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) {
             $data = $value;
         } else {
             $value = bin2hex($value);
             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 = $this->_formatData($type, $tag, $intel, $data);
         $result['SubIFD']['MakerNote'][$tag_name] = $formated_data;
     }
 }
Exemplo n.º 5
0
 /**
  * Panasonic Special data section
  */
 public function parse($block, &$result)
 {
     $intel = true;
     $model = $result['IFD0']['Model'];
     //current place
     $place = 8;
     $offset = 8;
     $num = bin2hex(substr($block, $place, 4));
     $place += 4;
     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;
     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) {
             $tag = Horde_Image_Exif::intel2Moto($tag);
         }
         $tag_name = $this->_lookupTag($tag);
         //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 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) {
             $data = $value;
         } else {
             $value = bin2hex($value);
             if ($intel) {
                 $value = Horde_Image_Exif::intel2Moto($value);
             }
             $data = substr($block, hexdec($value) - $offset, $bytesofdata * 2);
         }
         $formated_data = $this->_formatData($type, $tag, $intel, $data);
         $result['SubIFD']['MakerNote'][$tag_name] = $formated_data;
     }
 }
Exemplo n.º 6
0
 /**
  *
  * @param $block
  * @param $result
  * @return unknown_type
  */
 public function parse($block, &$result)
 {
     $intel = $result['Endien'] == 'Intel';
     $model = $result['IFD0']['Model'];
     //these 6 models start with "Nikon".  Other models dont.
     if ($model == "E700" || $model == "E800" || $model == "E900" || $model == "E900S" || $model == "E910" || $model == "E950") {
         //current place
         $place = 8;
         $model = 0;
         //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) {
                 $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) {
                 $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) {
                 $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 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) {
                 $data = $value;
             } else {
                 $value = bin2hex($value);
                 if ($intel) {
                     $value = Horde_Image_Exif::intel2Moto($value);
                 }
                 $data = substr($block, hexdec($value) - $offset, $bytesofdata * 2);
             }
             $formated_data = $this->_formatData($type, $tag, $intel, $model, $data);
             $result['SubIFD']['MakerNote'][$tag_name] = $formated_data;
         }
     } else {
         //current place
         $place = 0;
         $model = 1;
         $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) {
             $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) {
             $num = Horde_Image_Exif::intel2Moto($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) {
                 $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) {
                 $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) {
                 $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) {
                 $data = $value;
             } else {
                 $value = bin2hex($value);
                 if ($intel) {
                     $value = Horde_Image_Exif::intel2Moto($value);
                 }
                 $data = substr($block, hexdec($value) + hexdec($offset) + 2, $bytesofdata);
             }
             $formated_data = $this->_formatData($type, $tag, $intel, $model, $data);
             $result['SubIFD']['MakerNote'][$tag_name] = $formated_data;
         }
     }
 }
Exemplo n.º 7
0
 /**
  * Get the image attributes from the backend.
  *
  * @return array  A hash of Exif fieldnames => values.
  */
 public function getAttributes()
 {
     $attributes = $GLOBALS['injector']->getInstance('Ansel_Storage')->getImageAttributes($this->id);
     $params = !empty($GLOBALS['conf']['exif']['params']) ? $GLOBALS['conf']['exif']['params'] : array();
     $params['logger'] = $GLOBALS['injector']->getInstance('Horde_Log_Logger');
     $exif = Horde_Image_Exif::factory($GLOBALS['conf']['exif']['driver'], $params);
     $fields = Horde_Image_Exif::getFields($exif);
     $output = array();
     foreach ($fields as $field => $data) {
         if (!isset($attributes[$field])) {
             continue;
         }
         $output[$field] = $value = Horde_Image_Exif::getHumanReadable($field, Horde_String::convertCharset($attributes[$field], $GLOBALS['conf']['sql']['charset'], 'UTF-8'));
     }
     return $output;
 }
Exemplo n.º 8
0
 /**
  * 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
  */
 public function parse($block, &$result, $seek, $globalOffset)
 {
     $place = 0;
     //current place
     if ($result['Endien'] == 'Intel') {
         $intel = 1;
     } else {
         $intel = 0;
     }
     $model = $result['IFD0']['Model'];
     //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 = $this->_lookupTag($tag);
         //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 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);
         if ($bytesofdata <= 0) {
             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
         $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);
             }
             //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);
             } elseif ($v == -1) {
                 $result['Errors'] = $result['Errors']++;
                 $data = '';
             } else {
                 $data = '';
             }
         }
         // 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;
     }
 }
Exemplo n.º 9
0
 /**
  * GPS Special data section
  *
  * @see http://drewnoakes.com/code/exif/sampleOutput.html
  * @see http://www.geosnapper.com
  */
 public function parse($block, &$result, $offset, $seek, $globalOffset)
 {
     if ($result['Endien'] == 'Intel') {
         $intel = 1;
     } else {
         $intel = 0;
     }
     //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']++;
     }
     $num = bin2hex(fread($seek, 2));
     if ($intel == 1) {
         $num = Horde_Image_Exif::intel2Moto($num);
     }
     $num = hexdec($num);
     $result['GPS']['NumTags'] = $num;
     $block = fread($seek, $num * 12);
     $place = 0;
     //loop thru all tags  Each field is 12 bytes
     for ($i = 0; $i < $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);
         //2 byte datatype
         $type = bin2hex(substr($block, $place, 2));
         $place += 2;
         if ($intel == 1) {
             $type = Horde_Image_Exif::intel2Moto($type);
         }
         $this->_lookupType($type, $size);
         //4 byte number of elements
         $count = bin2hex(substr($block, $place, 4));
         $place += 4;
         if ($intel == 1) {
             $count = Horde_Image_Exif::intel2Moto($count);
         }
         $bytesofdata = $size * hexdec($count);
         //4 byte value or pointer to value if larger than 4 bytes
         $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);
             }
             //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);
             } elseif ($v == -1) {
                 $result['Errors'] = $result['Errors']++;
             }
         }
         $result['GPS' . $tag_name] = $this->_formatData($type, $tag, $intel, $data);
     }
 }
Exemplo n.º 10
0
/* Note that for the following to work, your pref backend must support
   retrieving prefs for other users (such as the SQL backend) */
$_prefs['grouptitle'] = array('value' => '', 'type' => 'text', 'desc' => _("Custom text to display describing your galleries. This will be displayed in place of your username when grouping galleries by username."));
$_prefs['defaultview'] = array('value' => 'galleries', 'type' => 'enum', 'enum' => array('browse' => _("Browse"), 'galleries' => _("Galleries"), 'mygalleries' => _("My Galleries")), 'desc' => _("View to display by default"));
$_prefs['groupby'] = array('value' => 'none', 'type' => 'enum', 'enum' => array('owner' => _("Owner"), 'none' => _("None")), 'desc' => _("Group galleries by"));
// number of photos on each row in the gallery view
$_prefs['tilesperrow'] = array('value' => 3, 'type' => 'number', 'desc' => _("Number of tiles per row"));
$_prefs['tilesperpage'] = array('value' => 9, 'type' => 'number', 'desc' => _("Number of tiles per page"));
$_prefs['facesperpage'] = array('value' => '20', 'type' => 'number', 'desc' => _("Number of faces per page"), 'suppress' => function () {
    return empty($GLOBALS['conf']['faces']['driver']);
});
$_prefs['groupsperpage'] = array('value' => 9, 'type' => 'number', 'desc' => _("Number of groups per page"));
$_prefs['showexif'] = array('value' => false, 'type' => 'checkbox', 'desc' => _("Show EXIF data"));
$_prefs['myansel_layout'] = array('value' => 'a:1:{i:0;a:3:{i:0;a:4:{s:3:"app";s:5:"ansel";s:6:"height";i:1;s:5:"width";i:1;s:6:"params";a:2:{s:5:"type2";s:17:"ansel_Block_Cloud";s:6:"params";a:1:{s:5:"count";s:2:"20";}}}i:1;a:4:{s:3:"app";s:5:"ansel";s:6:"height";i:1;s:5:"width";i:1;s:6:"params";a:2:{s:5:"type2";s:23:"ansel_Block_MyGalleries";s:6:"params";a:1:{s:5:"limit";s:1:"0";}}}i:2;a:4:{s:3:"app";s:5:"ansel";s:6:"height";i:1;s:5:"width";i:1;s:6:"params";a:2:{s:5:"type2";s:25:"ansel_Block_RecentlyAdded";s:6:"params";a:2:{s:7:"gallery";s:3:"all";s:5:"limit";s:2:"10";}}}}}');
$_prefs['default_gallerystyle'] = array('value' => 'ansel_default');
$_prefs['default_gallerystyle_select'] = array('type' => 'special', 'handler' => 'Ansel_Prefs_Special_GalleryStyle');
$_prefs['show_actions'] = array('value' => 0);
$_prefs['show_othergalleries'] = array('value' => 0);
$_prefs['current_maplayer'] = array('value' => '');
$_prefs['watermark_text'] = array('value' => '', 'type' => 'text', 'desc' => _("Custom watermark to use for photos"));
$_prefs['watermark_horizontal'] = array('value' => 'left', 'type' => 'enum', 'enum' => array('left' => _("Left"), 'center' => _("Center"), 'right' => _("Right")), 'desc' => _("Horizontal Alignment"));
$_prefs['watermark_vertical'] = array('value' => 'bottom', 'type' => 'enum', 'enum' => array('top' => _("Top"), 'center' => _("Center"), 'bottom' => _("Bottom")), 'desc' => _("Vertical Alignment"));
$_prefs['watermark_font'] = array('value' => 'medium', 'type' => 'enum', 'enum' => array('tiny' => _("Tiny"), 'small' => _("Small"), 'medium' => _("Medium"), 'large' => _("Large"), 'giant' => _("Giant")), 'desc' => _("Font Size"));
$_prefs['watermark_auto'] = array('value' => 0, 'type' => 'checkbox', 'desc' => _("Automatically watermark photos?"));
$_prefs['default_download'] = array('value' => 'edit', 'type' => 'enum', 'enum' => array('all' => _("Anyone"), 'edit' => _("Users with edit permissions"), 'authenticated' => _("Authenticated users")), 'desc' => _("When a new gallery is created, what should the default be for allowing users to download original photos?"));
$_prefs['default_permissions'] = array('value' => 'read', 'type' => 'enum', 'enum' => array('none' => _("None"), 'read' => _("Read-only"), 'edit' => _("Read and write")), 'desc' => _("When a new gallery is created, what permissions should be given to authenticated users by default?"));
$_prefs['guest_permissions'] = array('value' => 'read', 'type' => 'enum', 'enum' => array('none' => _("None (Owner only)"), 'read' => _("Read-only")), 'desc' => _("When a new gallery is created, what permissions should be given to guests by default?"));
$_prefs['group_permissions'] = array('value' => 'none', 'type' => 'enum', 'enum' => array('none' => _("None"), 'read' => _("Read-only"), 'edit' => _("Read and write"), 'delete' => _("Read, write, and delete")), 'desc' => _("When a new gallery is created, what default permissions should be given to groups that the user is a member of?"));
$_prefs['exif_tags'] = array('value' => 'a:0:{}', 'type' => 'multienum', 'enum' => Horde_Image_Exif::getFields(array($GLOBALS['conf']['exif']['driver'], !empty($GLOBALS['conf']['exif']['params']) ? $GLOBALS['conf']['exif']['params'] : array()), true), 'desc' => _("Which metadata fields should we automatically add as image tags during upload?"));
$_prefs['exif_title'] = array('value' => '', 'type' => 'enum', 'enum' => array_merge(array('none' => _("None")), Horde_Image_Exif::getFields(array($GLOBALS['conf']['exif']['driver'], !empty($GLOBALS['conf']['exif']['params']) ? $GLOBALS['conf']['exif']['params'] : array()), true)), 'desc' => _("Should we automatically set the image title on upload if able? If so, choose the field to obtain the title from."));
$_prefs['force_old_uploader'] = array('value' => false, 'type' => 'checkbox', 'desc' => _("Do not use the ajax-enabled uploader? Select this if your browser is having trouble uploading images with the ajax uploader."));
Exemplo n.º 11
0
 /**
  *
  * @param $block
  * @param $result
  * @param $seek
  * @param $globalOffset
  * @return unknown_type
  */
 public function parse($block, &$result, $seek, $globalOffset)
 {
     $intel = $result['Endien'] == 'Intel';
     $model = $result['IFD0']['Model'];
     //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) {
             $tag = Horde_Image_Exif::intel2Moto($tag);
         }
         $tag_name = $this->_lookupTag($tag);
         //2 byte type
         $type = bin2hex(substr($block, $place, 2));
         $place += 2;
         if ($intel) {
             $type = Horde_Image_Exif::intel2Moto($type);
         }
         list($type, $size) = $this->_lookupType($type);
         //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) {
             $data = $value;
         } else {
             $value = bin2hex($value);
             if ($intel) {
                 $value = Horde_Image_Exif::intel2Moto($value);
             }
             //offsets are from TIFF header which is 12 bytes from the start
             //of the file
             if ($seek->seek($globalOffset + hexdec($value))) {
                 $data = $seek->substring(0, $bytesofdata);
             } else {
                 $result['Errors'] = $result['Errors']++;
             }
         }
         $formated_data = $this->_formatData($type, $tag, $intel, $data);
         $result['SubIFD']['MakerNote'][$tag_name] = $formated_data;
     }
 }
Exemplo n.º 12
0
 /**
  *
  * @param $type
  * @param $tag
  * @param $intel
  * @param $data
  * @return unknown_type
  */
 protected function _formatData($type, $tag, $intel, $data)
 {
     switch ($type) {
         case 'ASCII':
             // Search for a null byte and stop there.
             if (($pos = strpos($data, chr(0))) !== false) {
                 $data = substr($data, 0, $pos);
             }
             // Format certain kinds of strings nicely (Camera make etc.)
             if ($tag == '010f') {
                 $data = Horde_String::ucwords(Horde_String::lower(trim($data)));
             }
             break;
         case 'URATIONAL':
         case 'SRATIONAL':
             $data = bin2hex($data);
             if ($intel == 1) {
                 $data = Horde_Image_Exif::intel2Moto($data);
             }
             if ($intel == 1) {
                 // intel stores them bottom-top
                 $top = hexdec(substr($data, 8, 8));
             } else {
                 // motorola stores them top-bottom
                 $top = hexdec(substr($data, 0, 8));
             }
             if ($intel == 1) {
                 // intel stores them bottom-top
                 $bottom = hexdec(substr($data, 0, 8));
             } else {
                 // motorola stores them top-bottom
                 $bottom = hexdec(substr($data, 8, 8));
             }
             if ($type == 'SRATIONAL' && $top > 2147483647) {
                 // this makes the number signed instead of unsigned
                 $top = $top - 4294967296;
             }
             if ($bottom != 0) {
                 $data = $top / $bottom;
             } elseif ($top == 0) {
                 $data = 0;
             } else {
                 $data = $top . '/' . $bottom;
             }
             // Exposure Time
             if ($tag == '829a') {
                 if ($bottom != 0) {
                     $data = $top . '/' . $bottom;
                 } else {
                     $data = 0;
                 }
             }
             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);
             }
             if ($intel == 0 && ($type == 'USHORT' || $type == 'SSHORT')) {
                 $data = substr($data, 0, 4);
             }
             $data = hexdec($data);
             if ($type == 'SSHORT' && $data > 32767) {
                 // this makes the number signed instead of unsigned
                 $data = $data - 65536;
             }
             if ($type == 'SLONG' && $data > 2147483647) {
                 // this makes the number signed instead of unsigned
                 $data = $data - 4294967296;
             }
             break;
         case 'UNDEFINED':
             // ExifVersion,FlashPixVersion,InteroperabilityVersion
             if ($tag == '9000' || $tag == 'a000' || $tag == '0002') {
                 $data = sprintf(Horde_Image_Translation::t("version %d"), $data / 100);
             }
             break;
         default:
             $data = bin2hex($data);
             if ($intel == 1) {
                 $data = Horde_Image_Exif::intel2Moto($data);
             }
             break;
     }
     return $data;
 }