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); }
/** * Get parameters for createAsset * * @param mixed input * @return array * @access public * @since 7/20/05 */ function getSingleAssetInfo($input) { $assetInfo = array(); $headerData = get_jpeg_header_data($input); $photoshopIRB = get_Photoshop_IRB($headerData); $this->_photoshopIPTC = get_Photoshop_IPTC($photoshopIRB); // printpre($this->_photoshopIPTC); $assetInfo['description'] = ""; $assetInfo['displayName'] = basename($input); if (is_array($this->_photoshopIPTC)) { foreach ($this->_photoshopIPTC as $array) { switch ($array['RecName']) { case 'Caption/Abstract': case 'description': $assetInfo['description'] = $array['RecData']; break; case "Object Name (Title)": case "title": if (strlen(trim($array['RecData']))) { $assetInfo['displayName'] = trim($array['RecData']); } } } } // printpre($assetInfo); // exit; $mime = Services::getService("MIME"); $mimeType = $mime->getMimeTypeForFileName(basename($input)); $generalType = substr($mimeType, 0, strpos($mimeType, '/')); if ($generalType == "application" || !$generalType) { $assetInfo['type'] = new HarmoniType("Asset Types", "edu.middlebury", "Generic Asset"); } else { $assetInfo['type'] = new HarmoniType("Asset Types", "edu.middlebury", ucfirst($generalType)); } return $assetInfo; }
/** * 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; }
// 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])) { // Tag "Date and Time of Original" found - use it for the default date $default_ps_file_info_array['date'] = $Exif_array[0][34665][0][36867]['Data'][0]; $default_ps_file_info_array['date'] = preg_replace("/(\\d\\d\\d\\d):(\\d\\d):(\\d\\d)( \\d\\d:\\d\\d:\\d\\d)/", "\$1-\$2-\$3", $default_ps_file_info_array['date']); } else {
/** * 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']; } } } }
/** * 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; }
<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> Output the Photoshop IRB (including the IPTC-NAA info --> <?php echo Interpret_IRB_to_HTML(get_Photoshop_IRB($jpeg_header_data), $filename); ?> <BR> <HR> <BR> Output the Meta Information --> <?php echo Interpret_EXIF_to_HTML(get_Meta_JPEG($filename), $filename); ?> <BR> <HR> <BR>
/** * 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 read_copy_protection($filename) { $jpeg_header_data = get_jpeg_header_data($filename); return Interpret_IRB_to_HTML2(get_Photoshop_IRB($jpeg_header_data), $filename); }