[Linpha-cvs] SF.net SVN: linpha: [4710] trunk/linpha2
Status: Inactive
Brought to you by:
bzrudi
From: <bz...@us...> - 2007-03-21 12:41:49
|
Revision: 4710 http://svn.sourceforge.net/linpha/?rev=4710&view=rev Author: bzrudi Date: 2007-03-21 05:41:45 -0700 (Wed, 21 Mar 2007) Log Message: ----------- Added basic IPTC write support Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/lib/classes/linpha.exiftool.class.php trunk/linpha2/lib/classes/linpha.metadata.class.php trunk/linpha2/lib/include/metadata_iptc_edit.php trunk/linpha2/templates/default/fragments.php Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2007-03-21 08:54:41 UTC (rev 4709) +++ trunk/linpha2/ChangeLog 2007-03-21 12:41:45 UTC (rev 4710) @@ -1,7 +1,14 @@ 2007-03-21 bzrudi * Prepared support for extracting the embedded thumbnail from the EXIF segment of the images as thumbnail. Currently disabled by default. - + * Added basic IPTC write support + TODO: Create all MetaData table columns with their right datatype defined + CHAR/TEXT/INT/VARCHAR and so on. + IPTC and XMP expect some data values with a defined length and + format, take good care of it or the data won't be written! + Take care of changed md5sum when writing IPTC/XMP! + Take care of encoding stuff! + 2007-03-20 bzrudi * Argh, after hours of boring debugging, AJAX stuff is working again when using exiftool instead of PJMT. The images were not showing due to an Modified: trunk/linpha2/lib/classes/linpha.exiftool.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.exiftool.class.php 2007-03-21 08:54:41 UTC (rev 4709) +++ trunk/linpha2/lib/classes/linpha.exiftool.class.php 2007-03-21 12:41:45 UTC (rev 4710) @@ -165,7 +165,7 @@ { if(array_key_exists($key, $lowerDataArray)) { - $str_columns .= $key . ', '; + $str_columns .= str_replace("_", "-", $key) . ', '; $str_values .= "'".HTML_UTF8_Escape(trim($lowerDataArray[$key]))."', "; } } @@ -331,7 +331,7 @@ 'state' => 'State', 'supplementalcategories' => 'Supplemental Categories', 'transmissionreference' => 'Transmission Reference', - 'urgency' => 'urgency' + 'urgency' => 'Urgency' ), @@ -351,21 +351,21 @@ 'specialinstructions' => 'Special Instructions', 'datecreated' => 'Date Created', 'timecreated' => 'Time Created', - 'byline' => 'By-line', - 'bylinetitle' => 'By-line Title', + 'by_line' => 'By-line', + 'by_linetitle' => 'By-line Title', 'city' => 'City', - 'sublocation' => 'Sub-location', + 'sub_location' => 'Sub-location', 'provincestate' => 'Province-State', - 'countryprimarylocationcode' => 'Country-Primary Location Code', - 'countryprimarylocationname' => 'Country-Primary Location Name', + 'country_primarylocationcode' => 'Country-Primary Location Code', + 'country_primarylocationname' => 'Country-Primary Location Name', 'originaltransmissionreference' => 'Original Transmission Reference', 'headline' => 'Headline', 'credit' => 'Credit', 'source' => 'Source', 'copyrightnotice' => 'Copyright Notice', 'contact' => 'Contact', - 'captionabstract' => 'Caption-Abstract', - 'writereditor' => 'Writer-Editor' + 'caption_abstract' => 'Caption-Abstract', + 'writer_editor' => 'Writer-Editor' ), //EXIF schema tags Modified: trunk/linpha2/lib/classes/linpha.metadata.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.metadata.class.php 2007-03-21 08:54:41 UTC (rev 4709) +++ trunk/linpha2/lib/classes/linpha.metadata.class.php 2007-03-21 12:41:45 UTC (rev 4710) @@ -413,31 +413,50 @@ && isset ($GLOBALS['linpha']->imgview->src_file) && file_exists($GLOBALS['linpha']->imgview->src_file)) { - global $new_ps_file_info_array; - $new_ps_file_info_array = $GLOBALS['_POST']; + global $iptc_array; + $iptc_array = $GLOBALS['_POST']; /** - * important! - * remove other POST data from this array, because pjmt just takes all values and this will generate unexpected results!!! - * we got problems because $_POST['linMetaField'] is an array and pjmt couldnt handle this + * Important! + * Remove other POST data from this array, because we just + * take all values and this will generate unexpected results!!! + * We got problems because $_POST['linMetaField'] is an array. */ - unset ($new_ps_file_info_array['linCmd']); - unset ($new_ps_file_info_array['linMetaField']); - unset ($new_ps_file_info_array['submit']); + unset ($iptc_array['linCmd']); + unset ($iptc_array['linMetaField']); + unset ($iptc_array['submit']); /** * if the backup went wrong, the saveModifiedMetaDataIptc() would most probably also fail */ - if (LinFilesys :: backupFile($GLOBALS['linpha']->imgview->src_file)) { - if (LinMetaDataModificate :: saveModifiedMetaDataIptc($new_ps_file_info_array, $GLOBALS['linpha']->imgview->src_file)) // error handling already done - { - /** - * force read data from file again if write was successful - */ - unset ($new_ps_file_info_array); - LinImport :: updateEntry($GLOBALS['linpha']->template->idCurrent, dirname($GLOBALS['linpha']->imgview->src_file), basename($GLOBALS['linpha']->imgview->src_file)); - } - } else { + if(LinFilesys::backupFile($GLOBALS['linpha']->imgview->src_file)) + { + $parameter = "-overwrite_original "; + + foreach($iptc_array AS $name => $value) + { + if(strlen(trim($value)) >= 1) + { + $name = str_replace("_", "-", $name); + $parameter .= "-iptc:$name='$value' "; + } + } + //echo '<pre>', print_r($iptc_array), '</pre>'; + + LinMetaData::__construct(); + $file = $GLOBALS['linpha']->imgview->src_file; + $exiftool = $this->objMetaTool->exiftool; + + exec("$exiftool $parameter $file"); + + /** + * force read data from file again if write was successful + */ + unset ($iptc_array); + LinImport :: updateEntry($GLOBALS['linpha']->template->idCurrent, dirname($GLOBALS['linpha']->imgview->src_file), basename($GLOBALS['linpha']->imgview->src_file)); + } + else + { linSysLog(sprintf(i18n("Error: Cannot create backup of: %s"), $GLOBALS['linpha']->imgview->src_file)); linLog(LOG_TYPE_META, LOG_ERR, 'meta_iptc', "Error: Cannot create backup of:" . ' ' . $GLOBALS['linpha']->imgview->src_file); } @@ -700,6 +719,7 @@ "(md5sum CHAR(32) NOT NULL, "; foreach ($array AS $key => $value) { + $value = str_replace("-", "_", strtolower($value)); $str .= LinSql::linAddslashes(strtolower($value))."VARCHAR(255), "; } $str .= "PRIMARY KEY (md5sum), "; @@ -711,6 +731,7 @@ "(md5sum CHAR(32) PRIMARY KEY NOT NULL, "; foreach ($array AS $key => $value) { + $value = str_replace("-", "_", strtolower($value)); $str .= strtolower($value) . " VARCHAR(255), "; } /** @@ -725,7 +746,8 @@ foreach ($array AS $key => $value) { - $str .= strtolower($value) . " TEXT, "; + $value = str_replace("-", "_", strtolower($value)); + $str .= "$value" . " TEXT, "; } /** Modified: trunk/linpha2/lib/include/metadata_iptc_edit.php =================================================================== --- trunk/linpha2/lib/include/metadata_iptc_edit.php 2007-03-21 08:54:41 UTC (rev 4709) +++ trunk/linpha2/lib/include/metadata_iptc_edit.php 2007-03-21 12:41:45 UTC (rev 4710) @@ -52,6 +52,8 @@ { $lower_array = array_change_key_case($file_data, CASE_LOWER); + $name = str_replace("_", "-", $name); + if(isset($lower_array[$name])) { $file_iptc = HTML_UTF8_Escape($lower_array[$name]); Modified: trunk/linpha2/templates/default/fragments.php =================================================================== --- trunk/linpha2/templates/default/fragments.php 2007-03-21 08:54:41 UTC (rev 4709) +++ trunk/linpha2/templates/default/fragments.php 2007-03-21 12:41:45 UTC (rev 4710) @@ -262,7 +262,7 @@ </table> <br> <br> - <p>Powered by: <a href="http://www.ozhiker.com/electronics/pjmt/" >PHP JPEG Metadata Toolkit version <?php echo $GLOBALS['Toolkit_Version'] ?>, Copyright (C) 2004 Evan Hunter</a></p> + <p>Powered by: <a href="http://owl.phy.queensu.ca/~phil/exiftool/" >ExifTool</a></p> <?php } else { echo i18n("Error: File not writable. Please check the file permissions."); /* @todo use unified language string */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |