summaryrefslogtreecommitdiff
path: root/inc
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2005-07-31 18:35:54 +0200
committerAndreas Gohr <andi@splitbrain.org>2005-07-31 18:35:54 +0200
commit36df6fa3069d55db3c35724c4f465bde9c50b53a (patch)
treed462d09cf51c2732731eb6db4c7cd601c86df4c1 /inc
parent23a34783631a54703aa67aa0de81c404c59ef4ef (diff)
downloadrpg-36df6fa3069d55db3c35724c4f465bde9c50b53a.tar.gz
rpg-36df6fa3069d55db3c35724c4f465bde9c50b53a.tar.bz2
image metadata editor
This patch adds an meta data editor for JPEG files. Currently title, caption, artist, copyright and keywords can be saved. The data is saved to the apropriate IPTC fields. Additional fields can be added in the appropriate template. Compatibility testing with other programs is needed! darcs-hash:20050731163554-7ad00-dd936ec19549203dcf72de8774309c0b17d0b679.gz
Diffstat (limited to 'inc')
-rw-r--r--inc/JpegMeta.php58
-rw-r--r--inc/lang/en/lang.php3
-rw-r--r--inc/template.php13
3 files changed, 61 insertions, 13 deletions
diff --git a/inc/JpegMeta.php b/inc/JpegMeta.php
index b9f0908d4..408f34589 100644
--- a/inc/JpegMeta.php
+++ b/inc/JpegMeta.php
@@ -3,9 +3,10 @@
* JPEG metadata reader/writer
*
* @license PHP license 2.0 (http://www.php.net/license/2_02.txt)
- * @link
+ * @link http://www.zonageek.com/software/php/jpeg/index.php
* @author Sebastian Delmont <sdelmont@zonageek.com>
* @author Andreas Gohr <andi@splitbrain.org>
+ * @todo Add support for Maker Notes, Extend for GIF and PNG metadata
*/
// This class is a modified and enhanced version of the JPEG class by
@@ -164,6 +165,40 @@ class JpegMeta
}
/**
+ * Convinience function to set nearly all available Data
+ * through one function
+ *
+ * @author Andreas Gohr <andi@splitbrain.org>
+ */
+ function setField($field, $value)
+ {
+ if(strtolower(substr($field,0,5)) == 'iptc.'){
+ return $this->setIPTCField(substr($field,5),$value);
+ }elseif(strtolower(substr($field,0,5)) == 'exif.'){
+ return $this->setExifField(substr($field,5),$value);
+ }else{
+ return $this->setExifField($field,$value);
+ }
+ }
+
+ /**
+ * Convinience function to delete nearly all available Data
+ * through one function
+ *
+ * @author Andreas Gohr <andi@splitbrain.org>
+ */
+ function deleteField($field)
+ {
+ if(strtolower(substr($field,0,5)) == 'iptc.'){
+ return $this->deleteIPTCField(substr($field,5));
+ }elseif(strtolower(substr($field,0,5)) == 'exif.'){
+ return $this->deleteExifField(substr($field,5));
+ }else{
+ return $this->deleteExifField($field);
+ }
+ }
+
+ /**
* Return a date field
*
* @author Andreas Gohr <andi@splitbrain.org>
@@ -770,18 +805,19 @@ class JpegMeta
* Save changed Metadata
*
* @author Sebastian Delmont <sdelmont@zonageek.com>
+ * @author Andreas Gohr <andi@splitbrain.org>
*/
function save($fileName = "") {
- if ($fileName == "") {
- $tmpName = $this->_fileName . ".tmp";
- $this->_writeJPEG($tmpName);
- if (file_exists($tmpName)) {
- rename($tmpName, $this->_fileName);
- }
- }
- else {
- $this->_writeJPEG($fileName);
- }
+ if ($fileName == "") {
+ $tmpName = tempnam(dirname($this->_fileName),'_metatemp_');
+ $this->_writeJPEG($tmpName);
+ if (@file_exists($tmpName)) {
+ return rename($tmpName, $this->_fileName);
+ }
+ } else {
+ return $this->_writeJPEG($fileName);
+ }
+ return false;
}
/*************************************************************/
diff --git a/inc/lang/en/lang.php b/inc/lang/en/lang.php
index 16fc1b738..fcc4ed696 100644
--- a/inc/lang/en/lang.php
+++ b/inc/lang/en/lang.php
@@ -144,6 +144,9 @@ $lang['spell_noerr'] = 'No Mistakes found';
$lang['spell_nosug'] = 'No Suggestions';
$lang['spell_change']= 'Change';
+$lang['metaedit'] = 'Edit Metadata';
+$lang['metasaveerr'] = 'Writing metadata failed';
+$lang['metasaveok'] = 'Metadata saved';
$lang['img_backto'] = 'Back to';
$lang['img_title'] = 'Title';
$lang['img_caption'] = 'Caption';
diff --git a/inc/template.php b/inc/template.php
index 23123b452..b48a591f8 100644
--- a/inc/template.php
+++ b/inc/template.php
@@ -665,12 +665,21 @@ function tpl_mediafilelist(){
$t = $item['meta']->getField('IPTC.Headline');
if($t) print '<b>'.$t.'</b><br />';
- $t = $item['meta']->getField(array('IPTC.Caption','EXIF.UserComment','EXIF.TIFFImageDescription','EXIF.TIFFUserComment'));
+ $t = $item['meta']->getField(array('IPTC.Caption','EXIF.UserComment',
+ 'EXIF.TIFFImageDescription',
+ 'EXIF.TIFFUserComment'));
if($t) print $t.'<br />';
$t = $item['meta']->getField(array('IPTC.Keywords','IPTC.Category'));
if($t) print '<i>'.$t.'</i><br />';
+ //add edit button
+ if($AUTH >= AUTH_UPLOAD && $item['meta']->getField('File.Mime') == 'image/jpeg'){
+ print '<a href="'.DOKU_BASE.'lib/exe/media.php?edit='.urlencode($item['id']).'">';
+ print '<img src="'.DOKU_BASE.'lib/images/edit.gif" alt="'.$lang['metaedit'].'" title="'.$lang['metaedit'].'" />';
+ print '</a>';
+ }
+
ptln('</div>',6);
}else{
ptln ('('.filesize_h($item['size']).')',6);
@@ -771,7 +780,7 @@ function tpl_pagetitle($id=null){
* and _iptcTagNames() in inc/jpeg.php (You need to prepend IPTC
* to the names of the latter one)
*
- * Only allowed in: detail.php
+ * Only allowed in: detail.php, mediaedit.php
*
* @author Andreas Gohr <andi@splitbrain.org>
*/