That is one of the best articles I have read in watermarking. Excellent resource. Thank you very much.

system
—
2004-09-08T11:10:22Z —
#5

its not that amazing! great article...also interesting to try with TTF fonts for dynamic text.

system
—
2004-09-08T11:23:12Z —
#6

Can anyone that has had success with the above please advise what version of GD and what version of libpng you are running..?

Great tutorial btw, shame i cant get it working because my version of libpng is incompattible.

Thanks

dopefish
—
2004-09-08T12:52:36Z —
#7

For larger or more heavily trafficked sites, I imagine this could begin to take a toll on performance if a watermarked image is reassembled every time it's requested.

The next step for this script would be to write the assembled image to a cache directory, similar to how some weblog apps write static copies of their entries. Could be called as a cron job or upon uploading a new image or etc...

Nice script, I'd been contemplating doing something like this both for watermarks and borders.

Chillijam
—
2004-09-08T14:59:17Z —
#8

This is great, but I have a question.

I would like to use a png with a transparent bg as my watermark image, but the result is black pixels where the watermark's transparency should be. Is this a feature of my version of GD/PHP/whatever, or is it a limitation of the basic script source (as supplied)?

TIA

vek
—
2004-09-08T19:21:49Z —
#9

Chillijam said:

This is great, but I have a question.

I would like to use a png with a transparent bg as my watermark image, but the result is black pixels where the watermark's transparency should be. Is this a feature of my version of GD/PHP/whatever, or is it a limitation of the basic script source (as supplied)?

Hi Brock, great article, but I was not able to get it to work. Bear with me as I am not very knowlagble with php..

but from your article, I assume we have to save the script (e.g. image.php) and then call the image to be watermarked as image.php?image=pic.jpg

but when i do this i get this error:

<br /><b>Warning</b>: imagecopymerge(): supplied argument is not a valid Image resource in <b>/home/httpd/vhosts/domain.com/httpdocs/image.php</b> on line <b>13</b><br /><br /><b>Warning</b>: imagejpeg(): supplied argument is not a valid Image resource in <b>/home/httpd/vhosts/domain.com/httpdocs/image.php</b> on line <b>14</b><br /><br /><b>Warning</b>: imagedestroy(): supplied argument is not a valid Image resource in <b>/home/httpd/vhosts/domain.com/httpdocs/image.php</b> on line <b>15</b><br />

all the files are in the same folder. Any idea what i am doing wrong?

ToolboxTech
—
2004-09-11T04:10:10Z —
#12

The default way the script works is by giving the $GET['src'] variable (?src=value] with value being the complete path to the file (/home/user/publichtml/images/file.jpg for example).

Infamia
—
2004-09-11T20:38:25Z —
#13

Heh, I just thinking about watermarking some images of my site that are getting heavily linked to, and voila, where's a quick script.

But this is just a first step. What I really want to do, is develop this script so that it looks at the requests and determines is it from somewhere outside the website? Or is from within? Referrer value is what I want know.

If it's from within, I would rather not "stain" the pictures with my "url" and copy write information. But if it's an external link, well, I'd like to at least let them know from where the picture their viewing, came from.

Any thoughts on this?

Thanx

SlappyAss
—
2004-09-12T08:47:46Z —
#14

In The PHP Anthology, HarryF deals with the hot-linking issue using sessions. Good book and base classes to build on, if you do the whole oop php thing. Still having trouble with 5 though (install that is).

I have used this class as a base to what i ended up making an overly robust thumbnail generation monstrosity....but it was fun.

system
—
2004-09-15T16:55:59Z —
#15

In your code:

$image = imagecreatetruecolor($watermark_width, $watermark_height);

$image = imagecreatefromjpeg($_GET['src']);

Why are you doing both these lines one after the other? Isn't that just a waist of CPU time as the $image created in the 1st line is overwritten by the next call?

sseiter
—
2004-09-17T16:56:39Z —
#16

This works all fine and dandy, but why doesn't it work when you use it in a html table?

system
—
2004-10-05T11:03:31Z —
#17

Why does everyone always use pngs in these tutorials, why would I want to use that format when every image I have is either a jpeg or gif! My digital camera only outputs jpeg..... just some food for thought

sseiter
—
2004-10-05T12:32:09Z —
#18

You can use jpegs to create images on the fly. The png is only used as the watermark on your image. This is generally due to the transparent background. This looks nice on images

system
—
2004-10-06T07:28:45Z —
#19

This script actually doesn't work for me. I'm not sure if Photoshop created .png files have terrible transparency or what, but the watermark uses white where it should be transparent. I have GD2.0+. Any suggestions?

DocDave
—
2004-10-06T14:55:50Z —
#20

Great Article. I love the ability to watermark in PHP. I have been using it for a while now. Works great! Here is an example of the output is creates:The logo and Copyright info is the Watermark.