Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#25 2008-02-23 06:41:36

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,609
Website

Re: create watermark on the fly in PHP?

Bloke, it’d be nice if this technique (adding a copyright bar beneath the picture) would also be possible.


TXP Builders – finely-crafted code, design and txp

Offline

#26 2008-02-23 09:58:03

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,275
Website GitHub

Re: create watermark on the fly in PHP?

jakob wrote:

Bloke, it’d be nice if this technique (adding a copyright bar beneath the picture) would also be possible.

Interesting, thanks for the link. Certainly it’s achievable automatically — either by allowing a “text” copyright message to be supplied to the plugin (which it will do anyway) or a pre-rendered copyright image, and an option to tell it to “append” it instead of merging it with the image.

Assuming your image is in the TXP database its original width and height are known. As long as this width/height are used for the enclosing div the image will appear without the copyright message being visible. The trick is to specify options that tell the plugin to use the values somewhere other than the image. I’ll have a play with the technique.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#27 2012-04-20 20:19:17

stephan
Plugin Author
From: Bochum, Germany
Registered: 2004-07-26
Posts: 196
Website

Re: create watermark on the fly in PHP?

Stef, any news on converting this to a plugin? ;-)

Last edited by stephan (2012-04-20 20:20:50)


Yoko for Textpattern – A free blog themeMinimum Theme – If all you want to do is write.
Note: I am currently not actively using Textpattern, so I am not in the forums very often

Offline

#28 2012-04-21 08:09:02

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,609
Website

Re: create watermark on the fly in PHP?

Just thinking aloud: what if “this technique”:“PIFT”:http://dsandler.org/outgoing/powazek-image-footer-2.html was combined with an htaccess rule so that the copyright is added to the bottom of the image between txp and serving on the site (i.e. it’s not attached to the actual image in the database). Maybe a tick-box (watermark this image) or message rule (perhaps generated from the caption, or simply a pre-prepared image with a copyright message that gets tagged to the bottom…)


TXP Builders – finely-crafted code, design and txp

Offline

#29 2012-04-21 09:27:06

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,275
Website GitHub

Re: create watermark on the fly in PHP?

Darn I forgot about this again didn’t I? I can’t find the code I did ages ago which probably means I’ve lost it, but I’ll check the drive at work next week just in case.

From memory yes, the idea was to offer different levels of watermarking governed by options. One was to add the copyright block above/below the image so you could style it, hide it, reveal, it whatever. Another was to embed it in the image as it’s generated on-the-fly (which is expensive but results could be cached). Thirdly, the ability to have it applied on upload. That final option is trickier simply because it’s applied to all images, regardless of whether they’re destined for the website or a client image. The first two can be restricted to only operate on images in certain categories, but on upload the category is set after the upload callback fires so it’d need doing after the category has been chosen and alt/caption added, which is a bit of a messier workflow.

Things I never got round to doing involved scaling the image or text. The problem with any technique is down to the image sizes. If they’re consistent, everything works fine, but if the sizes vary greatly then the image/text watermark is either tiny in one corner or you only see a few giant letters. Technically, the contrast issue is easy to solve and I did it well so a light image has a dark watermark and vice versa. It’s just the size thing that scuppered development as it involved detecting an image size and scaling the watermark accordingly. Fairly simple with text, but more problematic with an image.

Ideas on a postcard to the usual address…

Last edited by Bloke (2012-04-21 09:27:59)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#30 2012-04-21 14:52:03

Pat64
Plugin Author
From: France
Registered: 2005-12-12
Posts: 1,615
GitHub Twitter

Re: create watermark on the fly in PHP?

Hi Steff ;)

I haven’t read all the previous posts but, long time ago, I used a very useful solution (forgot the script, can’t find it on Google):

/images directory was protected with an .htaccess file in oder to protect original images from downloads.

A script (placed in the same directory?) changed all images with new one (into a secret directory?): a watermark wrote in it on the fly. So if a visitor trying to access the source of the page, he could not find the original images (even in the cache).


Patrick.

Github | CodePen | Codier | Simplr theme | Wait Me: a maintenance theme | [\a mi.ni.ma]: a “Low Tech” simple Blog theme.

Offline

Board footer

Powered by FluxBB