[ansel] EXIF thumbnail and user pref watermarking

Heath S. Hendrickson heath at outerspaceconsultants.com
Fri Jan 9 21:48:33 PST 2004


Here's a working patch for the EXIF thumbnail.  It's set to only work 
for VFS types of 'file' due to limitations in the PHP exif_thumbnail 
function (and all exif_ functions, for that matter).  Otherwise it will 
process as normal.

Also included are patches for a user-pref configurable watermark.   I 
put it in the Display options pref for lack of a better place.

heath

--------- patch to /lib/Image.php ----------
[root at space lib]# cvs diff Image.php
Index: Image.php
===================================================================
RCS file: /usr/local/horde/cvs/ansel/lib/Image.php,v
retrieving revision 1.18
diff -r1.18 Image.php
19a20
 >     var $_vfsroot;
42a44,49
 >         // added for the EXIF thumbnail processing
 >         if($conf['vfs']['type']==file) {
 >             $this->_vfsroot = $conf['vfs']['params']['vfsroot'];
 >         } else {
 >             $this->_vfsroot = '';
 >         ]
117,120c124,139
<             $dimensions = $this->_image->getDimensions();
<             
$this->_image->resize(min($this->_gallery->get('thumbnail_width'), 
$dimensions['width']),
<                                   
min($this->_gallery->get('thumbnail_height'), $dimensions['height']),
<                                   true);
---
 >             // Modified to look for a thumbnail in the EXIF data -- 
only works if using 'file' VFS storage... :(
 >             if($this->_vfsroot!=='') {
 >                 $image = exif_thumbnail($this->_vfsroot . "/" . 
$this->_vfspath . "/" . $this->_id . '_full');
 >             } else {
 >                 $image = false;
 >             }
 >             if ($image==false) {
 >                // no thumbnail available, continue to create our own
 >                $dimensions = $this->_image->getDimensions();
 >                
$this->_image->resize(min($this->_gallery->get('thumbnail_width'), 
$dimensions['width']),
 >                                      
min($this->_gallery->get('thumbnail_height'), $dimensions['height']),
 >                                      true);
 >                $this->_data = $this->_image->raw();
 >             } else {
 >                $this->_data = $image;
 >             }
123d141
<             $this->_data = $this->_image->raw();
212a231
 >   global $prefs;
215c234,235
<         return $this->_image->watermark(sprintf(_("Watermarked by 
%s"), Auth::getAuth()));
---
 >         $watermark = $prefs->getValue('watermark');
 >         return $this->_image->watermark(sprintf(_("%s"),$watermark));
----------- end /lib/Image.php patch ----------------


------------- patch to /config/prefs.php ---------------------
[root at space config]# diff prefs.php prefs.php.dist
30c30
<     'members' => array('listtype', 'showdefaultimages', 
'imagesperrow', 'imagesperpage', 'watermark', 'auto_watermark')
---
 >     'members' => array('listtype', 'showdefaultimages', 
'imagesperrow', 'imagesperpage')
130,145d129
<
< $_prefs['watermark'] = array(
<     'value' => '',
<     'locked' => false,
<     'shared' => false,
<     'type' => 'text',
<     'desc' => _("Watermark to use for images")
< );
<
< $_prefs['auto_watermark'] = array(
<     'value' => false,
<     'locked' => false,
<     'shared' => false,
<     'type' => 'checkbox',
<     'desc' => _("Automatically watermark all images")
< );
------------- end /config/prefs.php patch -------------------



More information about the ansel mailing list