[ansel] EXIF thumbnail and user pref watermarking
Heath S. Hendrickson
heath at outerspaceconsultants.com
Fri Jan 9 22:58:18 PST 2004
Alright, I had a couple typos in that previous patch (I cleaned it prior
to creating the diff, but failed to check it... sorry).
here's the correct diff for /lib/Image.php ... but after playing with it
for a while, I'm not sure I'd recommend incorporating it. On my camera
the EXIF thumbnails have black bars above and below the main image
(making them 160x120 when the image should be 160x107). And I also
noticed that WinXP and/or Photoshop 7/8 clobbered my thumnails when I
had them rotate the images... So I guess it's a little flakey to be
trustworthy and easier to create the thumbs with GD.
BTW, if you change GD to use 'jpeg' instead of 'png', the file sizes are
a lot better. Modify the settings in the horde/lib/Image/gd.php file.
Anyone know whey PNG was set as the default or how to change it on a
per-user basis?
h
[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));
Heath S. Hendrickson wrote:
> 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