Example #1
0
/**
 * mime_image_store_exif_data Process a JPEG and store its EXIF data as meta data.
 *
 * @param array $pFileHash file details.
 * @param array $pFileHash[upload] should contain a complete hash from $_FILES
 * @access public
 * @return TRUE on success, FALSE on failure
 */
function mime_image_store_exif_data($pFileHash)
{
    global $gBitSystem;
    if (!empty($pFileHash['upload'])) {
        $upload =& $pFileHash['upload'];
    }
    if (@BitBase::verifyId($pFileHash['attachment_id']) && ($exifHash = mime_image_get_exif_data($upload))) {
        // only makes sense to store the GPS data if we at least have latitude and longitude
        if (!empty($exifHash['GPS'])) {
            LibertyMime::storeMetaData($pFileHash['attachment_id'], 'GPS', $exifHash['GPS']);
        }
        if (!empty($exifHash['EXIF'])) {
            //			LibertyMime::storeMetaData( $pFileHash['attachment_id'], 'EXIF', $exifHash['EXIF'] );
        }
    }
    return TRUE;
}
Example #2
0
 function verifyImageData(&$pParamHash)
 {
     $pParamHash['content_type_guid'] = $this->getContentType();
     if (empty($pParamHash['purge_from_galleries'])) {
         $pParamHash['purge_from_galleries'] = FALSE;
     }
     if (!empty($pParamHash['resize'])) {
         $pParamHash['_files_override'][0]['max_height'] = $pParamHash['_files_override'][0]['max_width'] = $pParamHash['resize'];
     }
     // Make sure we know what to update
     if ($this->isValid()) {
         // these 2 entries will inform LibertyContent and LibertyMime that this is an update
         $pParamHash['content_id'] = $this->mContentId;
         if (!empty($this->mInfo['attachment_id'])) {
             $pParamHash['_files_override'][0]['attachment_id'] = $this->mInfo['attachment_id'];
         }
     }
     if (function_exists('mime_image_get_exif_data') && !empty($pParamHash['_files_override'][0]['tmp_name'])) {
         $exifFile['source_file'] = $pParamHash['_files_override'][0]['tmp_name'];
         $exifFile['type'] = $pParamHash['_files_override'][0]['type'];
         $exifHash = mime_image_get_exif_data($exifFile);
         // Set some default values based on the Exif data
         if (!empty($exifHash['IFD0']['ImageDescription'])) {
             if (empty($pParamHash['title'])) {
                 $exifTitle = trim($exifHash['IFD0']['ImageDescription']);
                 if (!empty($exifTitle)) {
                     $pParamHash['title'] = $exifTitle;
                 }
             } elseif (empty($pParamHash['edit']) && !$this->getField('data') && $pParamHash['title'] != $exifHash['IFD0']['ImageDescription']) {
                 $pParamHash['edit'] = $exifHash['IFD0']['ImageDescription'];
             }
         }
         // These come from Photoshop
         if (!empty($exifHash['headline'])) {
             if (empty($pParamHash['title'])) {
                 $pParamHash['title'] = $exifHash['headline'];
             } elseif (empty($pParamHash['edit']) && !$this->getField('data') && $pParamHash['title'] != $exifHash['headline']) {
                 $pParamHash['edit'] = $exifHash['headline'];
             }
         }
         if (!empty($exifFile['caption'])) {
             if (empty($pParamHash['title'])) {
                 $pParamHash['title'] = $exifFile['caption'];
             } elseif (empty($pParamHash['edit']) && !$this->getField('data') && $pParamHash['title'] != $exifFile['caption']) {
                 $pParamHash['edit'] = $exifFile['caption'];
             }
         }
         if (empty($pParamHash['event_time']) && !$this->getField('event_time') && !empty($exifHash['EXIF']['DateTimeOriginal'])) {
             $pParamHash['event_time'] = strtotime($exifHash['EXIF']['DateTimeOriginal']);
         }
     }
     // let's add a default title if we still don't have one or the user has chosen to use filename over exif data
     if ((empty($pParamHash['title']) || !empty($_REQUEST['use_filenames'])) && !empty($pParamHash['_files_override'][0]['name'])) {
         if (preg_match('/^[A-Z]:\\\\/', $pParamHash['_files_override'][0]['name'])) {
             // MSIE shit file names if passthrough via gigaupload, etc.
             // basename will not work - see http://us3.php.net/manual/en/function.basename.php
             $tmp = preg_split("[\\\\]", $pParamHash['_files_override'][0]['name']);
             $defaultName = $tmp[count($tmp) - 1];
             $pParamHash['_files_override'][0]['name'] = $defaultName;
         } else {
             $defaultName = $pParamHash['_files_override'][0]['name'];
         }
         if (strpos($pParamHash['_files_override'][0]['name'], '.')) {
             list($defaultName, $ext) = explode('.', $pParamHash['_files_override'][0]['name']);
         }
         $pParamHash['title'] = str_replace('_', ' ', $defaultName);
     }
     if (count($this->mErrors) > 0) {
         parent::verify($pParamHash);
     }
     return count($this->mErrors) == 0;
 }