function getImageMetadata($event) { $medium = $event->getArgument('medium'); $data = array('headers' => null, 'exif' => null, 'xmp' => null, 'irb' => null, 'finfo' => null); $ext = $medium->getExtension(); $file = $medium->getAbsPath(); if (zmgFactory::getConfig()->get('plugins/jpeg_metadata/general/readwrite') && ($ext == "jpg" || $ext == "jpeg") && !ZMG_SAFEMODE_ON) { //import libs first (duh ;) ) $jmt_dir = "v" . str_replace('.', '_', ZMG_JMT_VERSION); zmgimport('org.zoomfactory.var.plugins.jpeg_metadata.' . $jmt_dir . '.EXIF'); //takes care of some deferred loading as well zmgimport('org.zoomfactory.var.plugins.jpeg_metadata.' . $jmt_dir . '.Photoshop_File_Info'); // Retreive the EXIF, XMP and Photoshop IRB information from // the existing file, so that it can be updated later on... $data['headers'] = get_jpeg_header_data($file); $data['exif'] = get_EXIF_JPEG($file); $data['xmp'] = read_XMP_array_from_text(get_XMP_text($data['headers'])); $data['irb'] = get_Photoshop_IRB($data['headers']); $data['finfo'] = get_photoshop_file_info($data['exif'], $data['xmp'], $data['irb']); // Check if there is a default for the date defined if (!array_key_exists('date', $data['finfo']) || array_key_exists('date', $data['finfo']) && $data['finfo']['date'] == '') { // No default for the date defined // figure out a default from the file // Check if there is a EXIF Tag 36867 "Date and Time of Original" if ($data['exif'] != false && array_key_exists(0, $data['exif']) && array_key_exists(34665, $data['exif'][0]) && array_key_exists(0, $data['exif'][0][34665]) && array_key_exists(36867, $data['exif'][0][34665][0])) { // Tag "Date and Time of Original" found - use it for the default date $data['finfo']['date'] = $data['exif'][0][34665][0][36867]['Data'][0]; $data['finfo']['date'] = preg_replace("/(\\d\\d\\d\\d):(\\d\\d):(\\d\\d)( \\d\\d:\\d\\d:\\d\\d)/", "\$1-\$2-\$3", $data['finfo']['date']); } elseif ($data['exif'] != false && array_key_exists(0, $data['exif']) && array_key_exists(34665, $data['exif'][0]) && array_key_exists(0, $data['exif'][0][34665]) && array_key_exists(36868, $data['exif'][0][34665][0])) { // Check if there is a EXIF Tag 36868 "Date and Time when Digitized" // Tag "Date and Time when Digitized" found - use it for the default date $data['finfo']['date'] = $data['exif'][0][34665][0][36868]['Data'][0]; $data['finfo']['date'] = preg_replace("/(\\d\\d\\d\\d):(\\d\\d):(\\d\\d)( \\d\\d:\\d\\d:\\d\\d)/", "\$1-\$2-\$3", $data['finfo']['date']); } else { if ($data['exif'] != false && array_key_exists(0, $data['exif']) && array_key_exists(306, $data['exif'][0])) { // Check if there is a EXIF Tag 306 "Date and Time" // Tag "Date and Time" found - use it for the default date $data['finfo']['date'] = $data['exif'][0][306]['Data'][0]; $data['finfo']['date'] = preg_replace("/(\\d\\d\\d\\d):(\\d\\d):(\\d\\d)( \\d\\d:\\d\\d:\\d\\d)/", "\$1-\$2-\$3", $data['finfo']['date']); } else { // Couldn't find an EXIF date in the image // Set default date as creation date of file $data['finfo']['date'] = date("Y-m-d", filectime($file)); } } } } return zmgJpeg_metadataPlugin::interpretImageData($data, $medium->filename); }
/** * mime_image_get_exif_data fetch meta data from uploaded image * * @param array $pUpload uploaded file data * @access public * @return array filled with exif goodies */ function mime_image_get_exif_data($pUpload) { $exifHash = array(); if (function_exists('exif_read_data') && !empty($pUpload['source_file']) && is_file($pUpload['source_file']) && preg_match("#/(jpe?g|tiff)#i", $pUpload['type'])) { // exif_read_data can be noisy due to crappy files, e.g. "Incorrect APP1 Exif Identifier Code" etc... $exifHash = @exif_read_data($pUpload['source_file'], 0, TRUE); // extract more information if we can find it if (ini_get('short_open_tag')) { require_once UTIL_PKG_PATH . 'jpeg_metadata_tk/JPEG.php'; require_once UTIL_PKG_PATH . 'jpeg_metadata_tk/JFIF.php'; require_once UTIL_PKG_PATH . 'jpeg_metadata_tk/PictureInfo.php'; require_once UTIL_PKG_PATH . 'jpeg_metadata_tk/XMP.php'; require_once UTIL_PKG_PATH . 'jpeg_metadata_tk/EXIF.php'; // Retrieve the header information from the JPEG file $jpeg_header_data = get_jpeg_header_data($pUpload['source_file']); // Retrieve EXIF information from the JPEG file $Exif_array = get_EXIF_JPEG($pUpload['source_file']); // Retrieve XMP information from the JPEG file $XMP_array = read_XMP_array_from_text(get_XMP_text($jpeg_header_data)); // Retrieve Photoshop IRB information from the JPEG file $IRB_array = get_Photoshop_IRB($jpeg_header_data); if (!empty($exifHash['IFD0']['Software']) && preg_match('/photoshop/i', $exifHash['IFD0']['Software'])) { require_once UTIL_PKG_PATH . 'jpeg_metadata_tk/Photoshop_File_Info.php'; // Retrieve Photoshop File Info from the three previous arrays $psFileInfo = get_photoshop_file_info($Exif_array, $XMP_array, $IRB_array); if (!empty($psFileInfo['headline'])) { $exifHash['headline'] = $psFileInfo['headline']; } if (!empty($psFileInfo['caption'])) { $exifHash['caption'] = $psFileInfo['caption']; } } } // only makes sense to store the GPS data if we at least have latitude and longitude if (!empty($exifHash['GPS'])) { // store GPS coordinates as deg decimal float $gpsConv = array('GPSLatitude', 'GPSDestLatitude', 'GPSLongitude', 'GPSDestLongitude'); foreach ($gpsConv as $conv) { if (!empty($exifHash['GPS'][$conv]) && is_array($exifHash['GPS'][$conv])) { $exifHash['GPS'][$conv] = mime_image_convert_exifgps($exifHash['GPS'][$conv]); } } } } return $exifHash; }
// Change: added as of version 1.11 // Check for operation modes 2 or 3 // i.e. $filename is defined, and $new_ps_file_info_array is not if (!isset($new_ps_file_info_array) && isset($filename) && is_string($filename)) { // Hide any unknown EXIF tags $GLOBALS['HIDE_UNKNOWN_TAGS'] = TRUE; // Accessing the existing file info for the specified file requires these includes include 'JPEG.php'; include 'XMP.php'; include 'Photoshop_IRB.php'; include 'EXIF.php'; include 'Photoshop_File_Info.php'; // Retrieve the header information from the JPEG file $jpeg_header_data = get_jpeg_header_data($filename); // Retrieve EXIF information from the JPEG file $Exif_array = get_EXIF_JPEG($filename); // Retrieve XMP information from the JPEG file $XMP_array = read_XMP_array_from_text(get_XMP_text($jpeg_header_data)); // Retrieve Photoshop IRB information from the JPEG file $IRB_array = get_Photoshop_IRB($jpeg_header_data); // Retrieve Photoshop File Info from the three previous arrays $new_ps_file_info_array = get_photoshop_file_info($Exif_array, $XMP_array, $IRB_array); // Check if there is an array of defaults available if (isset($default_ps_file_info_array) && is_array($default_ps_file_info_array)) { // There are defaults defined // Check if there is a default for the date defined if (!array_key_exists('date', $default_ps_file_info_array) || array_key_exists('date', $default_ps_file_info_array) && $default_ps_file_info_array['date'] == '') { // No default for the date defined // figure out a default from the file // Check if there is a EXIF Tag 36867 "Date and Time of Original" if ($Exif_array != FALSE && array_key_exists(0, $Exif_array) && array_key_exists(34665, $Exif_array[0]) && array_key_exists(0, $Exif_array[0][34665]) && array_key_exists(36867, $Exif_array[0][34665][0])) {
/** * extractMetaData extract meta data from images * * @param array $pParamHash * @param array $pFile * @access public * @return TRUE on success, FALSE on failure - mErrors will contain reason for failure * @deprecated deprecated since version 2.1.0-beta */ function extractMetaData(&$pParamHash, &$pFile) { //deprecated( "This method has been replaced by a method in LibertyMime. Please try to migrate your code." ); // Process a JPEG , jpeg_metadata_tk REQUIRES short_tags because that is the way it was written. feel free to fix something. XOXO spiderr if (ini_get('short_open_tag') && function_exists('exif_read_data') && !empty($pFile['tmp_name']) && strpos(strtolower($pFile['type']), 'jpeg') !== FALSE) { $exifHash = @exif_read_data($pFile['tmp_name'], 0, true); // Change: Allow this example file to be easily relocatable - as of version 1.11 require_once UTIL_PKG_PATH . 'jpeg_metadata_tk/JPEG.php'; require_once UTIL_PKG_PATH . 'jpeg_metadata_tk/JFIF.php'; require_once UTIL_PKG_PATH . 'jpeg_metadata_tk/PictureInfo.php'; require_once UTIL_PKG_PATH . 'jpeg_metadata_tk/XMP.php'; require_once UTIL_PKG_PATH . 'jpeg_metadata_tk/EXIF.php'; // Retrieve the header information from the JPEG file $jpeg_header_data = get_jpeg_header_data($pFile['tmp_name']); // Retrieve EXIF information from the JPEG file $Exif_array = get_EXIF_JPEG($pFile['tmp_name']); // Retrieve XMP information from the JPEG file $XMP_array = read_XMP_array_from_text(get_XMP_text($jpeg_header_data)); // Retrieve Photoshop IRB information from the JPEG file $IRB_array = get_Photoshop_IRB($jpeg_header_data); if (!empty($exifHash['IFD0']['Software']) && preg_match('/photoshop/i', $exifHash['IFD0']['Software'])) { require_once UTIL_PKG_PATH . 'jpeg_metadata_tk/Photoshop_File_Info.php'; // Retrieve Photoshop File Info from the three previous arrays $psFileInfo = get_photoshop_file_info($Exif_array, $XMP_array, $IRB_array); if (!empty($psFileInfo['headline'])) { if (empty($pParamHash['title'])) { $pParamHash['title'] = $psFileInfo['headline']; } elseif (empty($pParamHash['edit']) && !$this->getField('data') && $pParamHash['title'] != $psFileInfo['headline']) { $pParamHash['edit'] = $psFileInfo['headline']; } } if (!empty($psFileInfo['caption'])) { if (empty($pParamHash['title'])) { $pParamHash['title'] = $psFileInfo['caption']; } elseif (empty($pParamHash['edit']) && !$this->getField('data') && $pParamHash['title'] != $psFileInfo['caption']) { $pParamHash['edit'] = $psFileInfo['caption']; } } } if (!empty($exifHash['EXIF']['DateTimeOriginal'])) { $pParamHash['event_time'] = strtotime($exifHash['EXIF']['DateTimeOriginal']); } if (!empty($exifHash['IFD0']['ImageDescription'])) { if (empty($pParamHash['title'])) { $pParamHash['title'] = $exifHash['IFD0']['ImageDescription']; } elseif (empty($pParamHash['edit']) && !$this->getField('data') && $pParamHash['title'] != $exifHash['IFD0']['ImageDescription']) { $pParamHash['edit'] = $exifHash['IFD0']['ImageDescription']; } } } }
<BR> <HR> <BR> Output the Picture Info Text --> <?php echo Interpret_App12_Pic_Info_to_HTML($jpeg_header_data); ?> <BR> <HR> <BR> Output the EXIF Information --> <?php echo Interpret_EXIF_to_HTML(get_EXIF_JPEG($filename), $filename); ?> <BR> <HR> <BR> Output the XMP Information --> <?php echo Interpret_XMP_to_HTML(read_XMP_array_from_text(get_XMP_text($jpeg_header_data))); ?> <BR> <HR> <BR>
/** * Make a newly uploaded medium ready for use in the gallery. * * @param string $image * @param string $filename * @param string $filetype * @param string $keywords * @param string $name * @param string $descr * @param int $rotate * @param int $degrees * @param int $ignoresizes * @return boolean * @access public */ function processImage($image, $filename, $filetype, $keywords, $name, $descr, $rotate, $degrees = 0, $ignoresizes = 0) { global $mosConfig_absolute_path, $zoom; // reset script execution time limit (as set in MAX_EXECUTION_TIME ini directive)... // requires SAFE MODE to be OFF! if (ini_get('safe_mode') != 1) { set_time_limit(0); } $imagepath = $zoom->_CONFIG['imagepath']; $catdir = $zoom->_gallery->getDir(); $filename = urldecode($filename); // replace every space-character with a single "_" $filename = ereg_replace(" ", "_", $filename); $filename = stripslashes($filename); $filename = ereg_replace("'", "_", $filename); // Get rid of extra underscores $filename = ereg_replace("_+", "_", $filename); $filename = ereg_replace("(^_|_\$)", "", $filename); $zoom->checkDuplicate($filename, 'filename'); $filename = $zoom->_tempname; // replace space-characters in combination with a comma with 'air'...or nothing! $keywords = $zoom->cleanString($keywords); //$keywords = $zoom->htmlnumericentities($keywords); $name = $zoom->cleanString($name); //$name = $zoom->htmlnumericentities($name); //$descr = $zoom->cleanString($descr); //$descr = $zoom->htmlnumericentities($descr); if (empty($name)) { $name = $zoom->_CONFIG['tempName']; } $imgobj = new image(0); //create a new image object with a foo imgid $imgobj->setImgInfo($filename, $name, $keywords, $descr, $zoom->_gallery->_id, $zoom->currUID, 1, 1); $imgobj->getMimeType($filetype, $image); unset($filename, $name, $keywords, $descr); //clear memory, just in case... if (!$zoom->acceptableSize($image)) { // the file is simply too big, register this... $this->_err_num++; $this->_err_names[$this->_err_num] = $imgobj->_filename; $this->_err_types[$this->_err_num] = sprintf(_ZOOM_ALERT_TOOBIG, $zoom->_CONFIG['maxsizekb'] . 'kB'); return false; } /* IMPORTANT CHEATSHEET: * If we don't get useful data from that or its a type we don't * recognize, take a swing at it using the file name. if ($mimeType == 'application/octet-stream' || $mimeType == 'application/unknown' || GalleryCoreApi::convertMimeToExtension($mimeType) == null) { $extension = GalleryUtilities::getFileExtension($file['name']); $mimeType = GalleryCoreApi::convertExtensionToMime($extension); } */ if ($zoom->acceptableFormat($imgobj->getMimeType(), true)) { // File is an image/ movie/ document... $file = "{$mosConfig_absolute_path}/{$imagepath}{$catdir}/" . $imgobj->_filename; $desfile = "{$mosConfig_absolute_path}/{$imagepath}{$catdir}/thumbs/" . $imgobj->_filename; if (is_uploaded_file($image)) { if (!move_uploaded_file("{$image}", $file)) { // some error occured while moving file, register this... $this->_err_num++; $this->_err_names[$this->_err_num] = $imgobj->_filename; $this->_err_types[$this->_err_num] = _ZOOM_ALERT_MOVEFAILURE; return false; } } elseif (!$zoom->platform->copy("{$image}", $file) && !$zoom->platform->file_exists($file)) { // some error occured while moving file, register this... $this->_err_num++; $this->_err_names[$this->_err_num] = $imgobj->_filename; $this->_err_types[$this->_err_num] = _ZOOM_ALERT_MOVEFAILURE; return false; } @$zoom->platform->chmod($file, '0777'); $viewsize = $mosConfig_absolute_path . "/" . $imagepath . $catdir . "/viewsize/" . $imgobj->_filename; if ($zoom->acceptableFormat($imgobj->getMimeType(), true)) { if ($zoom->isImage($imgobj->getMimeType(), true)) { $imgobj->_size = $zoom->platform->getimagesize($file); // get image EXIF & IPTC data from file to save it in viewsize image and get a thumbnail... if ($zoom->_CONFIG['readEXIF'] && ($imgobj->_type === "jpg" || $imgobj->_type === "jpeg") && !(bool) ini_get('safe_mode')) { // Retreive the EXIF, XMP and Photoshop IRB information from // the existing file, so that it can be updated later on... $jpeg_header_data = get_jpeg_header_data($file); $EXIF_data = get_EXIF_JPEG($file); $XMP_data = read_XMP_array_from_text(get_XMP_text($jpeg_header_data)); $IRB_data = get_Photoshop_IRB($jpeg_header_data); $new_ps_file_info = get_photoshop_file_info($EXIF_data, $XMP_data, $IRB_data); // Check if there is a default for the date defined if (!array_key_exists('date', $new_ps_file_info) || array_key_exists('date', $new_ps_file_info) && $new_ps_file_info['date'] == '') { // No default for the date defined // figure out a default from the file // Check if there is a EXIF Tag 36867 "Date and Time of Original" if ($EXIF_data != FALSE && array_key_exists(0, $EXIF_data) && array_key_exists(34665, $EXIF_data[0]) && array_key_exists(0, $EXIF_data[0][34665]) && array_key_exists(36867, $EXIF_data[0][34665][0])) { // Tag "Date and Time of Original" found - use it for the default date $new_ps_file_info['date'] = $EXIF_data[0][34665][0][36867]['Data'][0]; $new_ps_file_info['date'] = preg_replace("/(\\d\\d\\d\\d):(\\d\\d):(\\d\\d)( \\d\\d:\\d\\d:\\d\\d)/", "\$1-\$2-\$3", $new_ps_file_info['date']); } elseif ($EXIF_data != FALSE && array_key_exists(0, $EXIF_data) && array_key_exists(34665, $EXIF_data[0]) && array_key_exists(0, $EXIF_data[0][34665]) && array_key_exists(36868, $EXIF_data[0][34665][0])) { // Check if there is a EXIF Tag 36868 "Date and Time when Digitized" // Tag "Date and Time when Digitized" found - use it for the default date $new_ps_file_info['date'] = $EXIF_data[0][34665][0][36868]['Data'][0]; $new_ps_file_info['date'] = preg_replace("/(\\d\\d\\d\\d):(\\d\\d):(\\d\\d)( \\d\\d:\\d\\d:\\d\\d)/", "\$1-\$2-\$3", $new_ps_file_info['date']); } else { if ($EXIF_data != FALSE && array_key_exists(0, $EXIF_data) && array_key_exists(306, $EXIF_data[0])) { // Check if there is a EXIF Tag 306 "Date and Time" // Tag "Date and Time" found - use it for the default date $new_ps_file_info['date'] = $EXIF_data[0][306]['Data'][0]; $new_ps_file_info['date'] = preg_replace("/(\\d\\d\\d\\d):(\\d\\d):(\\d\\d)( \\d\\d:\\d\\d:\\d\\d)/", "\$1-\$2-\$3", $new_ps_file_info['date']); } else { // Couldn't find an EXIF date in the image // Set default date as creation date of file $new_ps_file_info['date'] = date("Y-m-d", filectime($file)); } } } } // First, rotate the image (if that's mentioned in the 'job description')... if ($rotate) { $tmpdir = $mosConfig_absolute_path . "/" . $zoom->createTempDir(); $new_source = $tmpdir . "/" . $imgobj->_filename; if (!$this->rotateImage($file, $new_source, $degrees, $imgobj)) { $this->_err_num++; $this->_err_names[$this->_err_num] = $imgobj->_filename; $this->_err_types[$this->_err_num] = "Error rotating image"; return false; } else { @$zoom->platform->unlink($file); if ($zoom->platform->copy($new_source, $file)) { $imgobj->_size = $zoom->platform->getimagesize($file); } } } // resize to thumbnail... // 1-31-2006: fix #0000151 if (!$zoom->platform->file_exists($desfile)) { if (!$this->resizeImage($file, $desfile, $zoom->_CONFIG['size'], $imgobj)) { $this->_err_num++; $this->_err_names[$this->_err_num] = $imgobj->_filename; $this->_err_types[$this->_err_num] = _ZOOM_ALERT_IMGERROR; return false; } } // if the image size is greater than the given maximum: resize it! if (!$zoom->platform->file_exists($viewsize)) { //If the image is larger than the max size if (($imgobj->_size[0] > $zoom->_CONFIG['maxsize'] || $imgobj->_size[1] > $zoom->_CONFIG['maxsize']) && !$ignoresizes) { //Resizes the file. If successful, continue if ($this->resizeImage($file, $viewsize, $zoom->_CONFIG['maxsize'], $imgobj)) { //Watermark? if ((bool) $zoom->_CONFIG['wm_apply']) { //Watermark. Return errors if not successuful if (!$this->watermarkImage($viewsize, $viewsize, $imgobj)) { $this->_err_num++; $this->_err_names[$this->_err_num] = $imgobj->_filename; $this->_err_types[$this->_err_num] = _ZOOM_ALERT_WATERMARKERROR; return false; } } } else { $this->_err_num++; $this->_err_names[$this->_err_num] = $imgobj->_filename; $this->_err_types[$this->_err_num] = _ZOOM_ALERT_IMGERROR; return false; } } else { //Watermark? if ((bool) $zoom->_CONFIG['wm_apply']) { //Watermark. Return errors if not successuful if (!$this->watermarkImage($file, $file, $imgobj)) { $this->_err_num++; $this->_err_names[$this->_err_num] = $imgobj->_filename; $this->_err_types[$this->_err_num] = _ZOOM_ALERT_WATERMARKERROR; return false; } } } } } elseif ($zoom->isDocument($imgobj->getMimeType(), true)) { if ($zoom->isIndexable($imgobj->getMimeType(), true) && $this->_use_PDF) { if (!$this->indexDocument($file, $imgobj->_filename)) { $this->_err_num++; $this->_err_names[$this->_err_num] = $imgobj->_filename; $this->_err_types[$this->_err_num] = _ZOOM_ALERT_INDEXERROR; return false; } } else { if ($zoom->platform->copy($file, $viewsize)) { if ((bool) $zoom->_CONFIG['wm_apply']) { // put a watermark on the source image... if (!$this->watermarkImage($viewsize, $viewsize, $imgobj)) { $this->_err_num++; $this->_err_names[$this->_err_num] = $imgobj->_filename; $this->_err_types[$this->_err_num] = _ZOOM_ALERT_WATERMARKERROR; return false; } } } else { // some error occured while moving file, register this... $this->_err_num++; $this->_err_names[$this->_err_num] = $imgobj->_filename; $this->_err_types[$this->_err_num] = _ZOOM_ALERT_MOVEFAILURE; return false; } } } elseif ($zoom->isMovie($imgobj->getMimeType(), true)) { //if movie is 'thumbnailable' -> make a thumbnail then! if ($zoom->isThumbnailable($imgobj->_type) && $this->_use_FFMPEG) { if (!$this->createMovieThumb($file, $zoom->_CONFIG['size'], $imgobj->_filename)) { $this->_err_num++; $this->_err_names[$this->_err_num] = $imgobj->_filename; $this->_err_types[$this->_err_num] = _ZOOM_ALERT_IMGERROR; return false; } } } elseif ($zoom->isAudio($imgobj->getMimeType(), true)) { // TODO: indexing audio files (mp3-files, etc.) properties, e.g. id3vX tags... } if (!$imgobj->save()) { $this->_err_num++; $this->_err_names[$this->_err_num] = $imgobj->_filename; $this->_err_types[$this->_err_num] = "Database failure"; } } } else { //Not the right format, register this... $this->_err_num++; $this->_err_names[$this->_err_num] = $imgobj->_filename; $this->_err_types[$this->_err_num] = _ZOOM_ALERT_WRONGFORMAT_MULT; return false; } return true; }
function exif() { $file = $this->get(); //return exif_read_data(, 0, true); return get_EXIF_JPEG($file[6]); // $exif_s = ""; // foreach ($exif as $key => $section) { // foreach ($section as $name => $val) { // $exif_s .= htmlspecialchars($key) . "." . htmlspecialchars($name) . ": " . htmlspecialchars($val) . "<br />\n"; // } // } }
/** * match given array with exifdata from file * * @param string imageFileName * @param array tagnameArray * @return array * @access public * @since 7/28/05 */ function extractExifMetadata($imageFileName) { $metadataArrays = array(); $metadataArrays[] = get_EXIF_JPEG($imageFileName); $metadataArrays[] = get_Meta_JPEG($imageFileName); $metadataArrays[] = get_EXIF_TIFF($imageFileName); $results = array(); foreach ($metadataArrays as $metadataArray) { if (is_array($metadataArray)) { $exifArray = $metadataArray[0]['34665']['Data'][0]; if (is_array($exifArray)) { foreach ($exifArray as $array) { if ($array['Tag Name'] && $array['Text Value']) { $results[$array['Tag Name']] = $array['Text Value']; } } } } } return $results; }
/** * function to update image metadata */ function metadata_image($metadata_conf) { if (is_array($metadata_conf) && count($metadata_conf) > 0) { include_once 'metadata/Toolkit_Version.php'; error_reporting(0); include_once 'metadata/JPEG.php'; include_once 'metadata/XMP.php'; include_once 'metadata/Photoshop_IRB.php'; include_once 'metadata/EXIF.php'; include_once 'metadata/Photoshop_File_Info.php'; // Copy all of the HTML Posted variables into an array //$new_ps_file_info_array = $GLOBALS['HTTP_POST_VARS']; $new_ps_file_info_array = $metadata_conf; $filename = $new_ps_file_info_array['filename']; //echo $filename; // Protect against hackers editing other files $path_parts = pathinfo($filename); $array_extention = array('png', 'jpg'); if (strcasecmp($path_parts["extension"], "jpg") != 0) { //if (!in_array($path_parts["extension"], $array_extention)) #echo "Incorrect File Type - JPEG Only\n"; return array('status' => 'failed', 'message' => 'Incorrect File Type - JPEG Only'); exit; } // Change: removed limitation on file being in current directory - as of version 1.11 // Retrieve the header information $jpeg_header_data = get_jpeg_header_data($filename); // Retreive the EXIF, XMP and Photoshop IRB information from // the existing file, so that it can be updated $Exif_array = get_EXIF_JPEG($filename); $XMP_array = read_XMP_array_from_text(get_XMP_text($jpeg_header_data)); $IRB_array = get_Photoshop_IRB($jpeg_header_data); // Update the JPEG header information with the new Photoshop File Info $jpeg_header_data = put_photoshop_file_info($jpeg_header_data, $new_ps_file_info_array, $Exif_array, $XMP_array, $IRB_array); // Check if the Update worked if ($jpeg_header_data == FALSE) { //echo '$jpeg_header_data false'; return array('status' => 'failed', 'message' => 'Error - Failure update Photoshop File Info : ' . $filename); // Abort processing exit; } // Attempt to write the new JPEG file if (FALSE == put_jpeg_header_data($filename, $filename, $jpeg_header_data)) { //echo 'put_jpeg_header_data false'; return array('status' => 'failed', 'message' => 'Error - Failure to write new JPEG : ' . $filename); // Abort processing exit; } return array('status' => 'succes', 'message' => $filename . ' updated'); } }
function getExifTags($path, $name, $type) { $exif_data = array(); // Display additonal exif information if allowed. $JPEG_TOOLKIT = $serendipity['baseURL'] . 'plugins/serendipity_event_usergallery/JPEG_TOOLKIT/'; if (is_file($JPEG_TOOLKIT . 'EXIF.php')) { include_once $JPEG_TOOLKIT . 'EXIF.php'; if (strtolower($type) == 'jpeg' || strtolower($type) == 'jpg') { $filename = $name . '.' . $type; if ($exif = get_EXIF_JPEG($path . $filename)) { $exif_arr_num_1 = array(116 => 'Copyright Notice', 271 => 'Camera Make', 272 => 'Camera Model', 274 => 'Orientation', 296 => 'Resolution Unit', 282 => 'X Resolution', 283 => 'Y Resolution', 306 => 'Date and Time', 531 => 'YCbCr Positioning', 34665 => ''); $exif_arr_num_2 = array(33434 => 'Exposure Time', 33437 => 'Aperture', 34850 => 'Exposure Program', 34855 => 'ISO', 36864 => 'Exif Version', 36867 => 'Date (Original)', 36868 => 'Date (Digitized)', 37380 => 'APEX Exposure Bias', 37381 => 'APEX Max Aperture', 37383 => 'Metering Mode', 37384 => 'Light Source', 37385 => 'Flash', 37386 => 'FocalLength', 37510 => 'User Comment', 40960 => 'FlashPix Version', 40961 => 'Colour Space', 40962 => 'Pixel X Dimension', 40963 => 'Pixel Y Dimension', 41728 => 'File Source', 41985 => 'Special Processing', 41986 => 'Exposure Mode', 41987 => 'White Balance', 41988 => 'Digital Zoom Ratio', 41990 => 'Scene Capture Type', 41991 => 'Gain Control', 41992 => 'Contrast', 41993 => 'Saturation', 41994 => 'Sharpness', 37121 => 'Components Config'); foreach ($exif_arr_num_1 as $num1 => $value1) { if ($num1 != 34665) { if (isset($exif[0][$num1]['Text Value'])) { if ($exif[0][$num1]['Text Value'] == '') { $exif_data[$value1] = 'Unknown'; } else { $exif_data[$value1] = $exif[0][$num1]['Text Value']; } } } else { foreach ($exif_arr_num_2 as $num2 => $value2) { if (isset($exif[0][$num1]['Data'][0][$num2]['Text Value'])) { if ($exif[0][$num1]['Data'][0][$num2]['Text Value'] == '') { $exif_data[$value2] = 'Unknown'; } else { $exif_data[$value2] = $exif[0][$num1]['Data'][0][$num2]['Text Value']; } } } } } } else { $exif_data = array(); } } else { $exif_data = array(); } if (isset($exif_data['X Resolution']) && isset($exif_data['Resolution Unit'])) { $exif_data['X Resolution'] = $this->setResData($exif_data['X Resolution'], $exif_data['Resolution Unit']); } if (isset($exif_data['Y Resolution']) && isset($exif_data['Resolution Unit'])) { $exif_data['Y Resolution'] = $this->setResData($exif_data['Y Resolution'], $exif_data['Resolution Unit']); } if (isset($exif_data['Date and Time'])) { $exif_data['Date and Time'] = $this->changeExifDate($exif_data['Date and Time']); } if (isset($exif_data['Orientation'])) { $pos = explode(' ', $exif_data['Orientation']); $exif_data['Orientation'] = $pos[0] . ' ' . $pos[1] . ' ' . $pos[2] . ' ' . $pos[3]; } if (isset($exif_data['YCbCr Positioning'])) { $exif_data['YCbCr Positioning'] = str_replace('components', '', $exif_data['YCbCr Positioning']); } } else { $exif_data = array(); } return $exif_data; }
} //END IF zoom? if ($zoom->_CONFIG['properties']) { ?> <br /><br /> <!-- beginning of floating-box to hide details when the Slideshow has started... --> <div id="details"> <?php ZMG_Template_View::showPropertiesBox($zoom->_CONFIG['viewtype'], $img_path, $key); // Display a link which enables the user to view EXIF-readings of the image, if readEXIF is set // to TRUE. $empty_span = "<span> </span>"; if ($zoom->_CONFIG['readEXIF'] && $zoom->isImage($zoom->_gallery->_images[$key]->_type)) { // $exif = $zoom->_gallery->_images[$key]->exif_parse_file($img_loc); $prefix = ZMG_Template_View::createViewBlock(_ZOOM_EXIF_SHOWHIDE); $metadata_viewable = Interpret_EXIF_to_HTML(get_EXIF_JPEG($img_loc_org), $img_loc_org); if (!empty($metadata_viewable)) { echo $metadata_viewable; } else { echo $empty_span; } ZMG_Template_View::finishViewBlock($zoom->_CONFIG['meta_state'], $prefix); } // Do the same for the ID3 tag parser... if ($zoom->_CONFIG['readID3'] && $zoom->isAudio($zoom->_gallery->_images[$key]->_type)) { $prefix = ZMG_Template_View::createViewBlock(_ZOOM_ID3_SHOWHIDE); $id3_data = $zoom->_gallery->_images[$key]->_metadata; $metadata_viewable = $zoom->toolbox->interpret_ID3_to_HTML($id3_data); if (!empty($metadata_viewable)) { echo $metadata_viewable; } else {