![]() |
Watermarking made DEAD SIMPLE (tutorial )
People always ask about watermarking programs so i figured i would share a DEAD SIMPLE method for batch watermarking your images on the fly with php.
#1 reason to use php is because its flexible.. allowing you to offer different watermarks depending on who is viewing the pictures. for example it could be as simple as displaying different transparency of the logo if the picture is hotlinked than when on your own site (i.e. blatent logo when hotlinked , lighter logo when on your site ) or you could go clever and show random logos annd random large messages when the pictures are hotlinked. Ok so heres how it works, in this example your site will be called "www.yoursite.com" your secret folder the images will be kept will be called "secret" and the follder this script is in is called "script" so path to script would be yoursite.com/script/ secret path of images would be yoursite.com/script/secret/ first place a test jpg in the secret folder yoursite.com/script/secret/test.jpg like that then place your logo, name it "watermark.gif" in the script folder yoursite.com/script/watermark.gif like that then place a ttf file called font.ttf in the script folder yoursite.com/script/font.ttf like that (ttf is true type font , theres some in your windows font folder if you dont have one ) then copy and save the following as water.php and place it in the scripts folder yoursite.com/script/water.php like that Code:
<?php now copy and save the following as index.php and place in the scripts folder yoursite.com/script/index.php like that Code:
<?php Code:
RewriteEngine on yoursite.com/script/test.jpeg or bypassing htacces if its giving you troubles by pointing to yoursite.com/script/?stb=test the picture is really inside the secret folder. Now you should note that when you call the image you call it .jpeg not .jpg but the real images should be named .jpg Nobody will know the secret directory but the server. if perhaps someone does , you can easily just rename the secret folder ( and change the index.php to reflect the new path ) and pictures wont work but your pictures will still work fine without having to change all your exisiting img tags :) enjoy.. ill add a few tips in a moment. any questions feels free to ask |
gonna check this one out fo sure :-)
|
p.s. this requires gd to be installed on your server ( most hosts have this on by default ) although many hosts dont have gd that supports true type fonts. if this is the case you can take out the test writing funstion by simply commenting out the line
imagettftext($main_img_obj, $fontsize, $angle, $fr, $ft, $color, $font, $words ); like this // imagettftext($main_img_obj, $fontsize, $angle, $fr, $ft, $color, $font, $words ); |
in the example i didnt do anything tricky , just the same watermark for everyone. but its very easy to manipulate to check the referrer and do different things depepnding on if its hotlinked or not.
|
if you want to redirect all google images traffic you could do something like this ( add this to the first line of index.php )
Code:
$ref = $HTTP_REFERER ; |
fuck that.
too complicated. |
Quote:
Its much easier than doing it with a program and offers more than regular htaccess or any image editing program does |
Smokey,
Is this just a layer over the image or does it stamp the pic so when someone saves it, it remains on there? |
Quote:
I can watermark 1000's of photos with one click. |
Nice Script..bump for ya
|
I just use Arles, dead simple.
|
Quote:
|
Already got some thing like that very simple to use :thumbsup :winkwink: and if you download a pics my watermarks stay on pics
|
I love smokey's threads. very informative & always learn new tricks of the trade. I appreciate threads like this. :thumbsup :thumbsup
|
Quote:
example http://gfy.webspacemania.com/mark/?main=test |
Quote:
Sure you can do 1000 with one click ( well not really one , you have to open the program bring in the pics or folder thenset the watermark set the transparency etc etc .. ) Perhaps if you only ever watermarked a set of pics once it might work.. but if you do that every month or so my script beats it hands down and offers the ability to serve unwatermarked images to restricted areas like a members area without having to have sets of unwatermarked and watermakrked pics Lets say for example you have a set of 1 million pics you want on your website and watermarked , you have to bring them into your program set the watermark do the process etc etc then upload them.. all i gotta do is upload them.. |
Quote:
If you download pics with this script the watermark stays on , or it wouldnt be a watermark it would be an overlay.. this is a watermark |
nice little script :) would be better if it cache'd the image though... kind of wasteful to re-run per-image per surfer-load imo. Also u may want to add a imagedestroy call, but maybe that is not required.
|
To show you an example of how it can detect hotlink and only insert the watermark when hotlinked
http://gfy.webspacemania.com/mark/movie.html thats what the example pic i used looks when used on my site but if you try to hotlink it you will get a watermarked version |
Quote:
In what i was using it for space was a bit of a concern and i wanted to keep the ability to let my surfers see the pics without a watermark |
Great informative thread Smokey
|
Alrighty then, good stuff as always Smokey!!!
|
props on the thread smokey...
|
Does this work with videos? lol
|
Quote:
http://www.gofuckyourself.com/showthread.php?t=677225 |
Bookmarked!
thanks again Smokey. |
|
All times are GMT -7. The time now is 07:56 PM. |
Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc