Watermarking

Discussion corner for Developers of Serendipity.
Post Reply
bf
Regular
Posts: 8
Joined: Sat Apr 12, 2008 9:14 pm

Watermarking

Post by bf »

Downloaded Serendipity for the first time today and have to say it's a great piece of work. Thanks guys. I've dabbled with other similar blogging software but this suits my requirements much better. Having said that the only thing I found missing was the ability to add watermarks to images and this has been discussed a number of times throughout the forum. Based on garvinhicking's posting I thought I'd follow up his idea and have a tinker with modifying the code directly to accommodate watermarks.

The result I've posted below. It is very dirty code and obviously cannot be directly incorporated as it is but it might help others who require this functionallity or those who might be interested in developing it.

ImageMagick convert has to be enabled and for simplicity the watermark PNG is the same dimensions as any images to be uploaded.

In the file include/functions_images.inc.php at line 663 (Serendipity 1.3), for uploaded images, I've replaced

Code: Select all

                $cmd     = escapeshellcmd($serendipity['convert']) . ' -antialias -resize '. serendipity_escapeshellarg($newSize) .' '. serendipity_escapeshellarg($infile) .' '. serendipity_escapeshellarg($outfile);
with

Code: Select all

                $cmd     = escapeshellcmd('/usr/bin/composite /path/to/watermark/image/watermark.png ') . serendipity_escapeshellarg($infile) . ' miff:- | ' . escapeshellcmd($serendipity['convert']) . ' - -antialias -resize '. serendipity_escapeshellarg($newSize) .' '. serendipity_escapeshellarg($outfile);
Seems to do the trick.
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Watermarking

Post by garvinhicking »

Hi!

Thank you for posting this easy trick. It is a bit hacky, but this should work flawlessly :)

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Post Reply