News:

cpg1.5.46 Security release - upgrade mandatory!The Coppermine development team is releasing a security update for Coppermine in order to counter recently discovered vulnerabilities. It is important that all users who run version cpg1.5.44 or older update to this latest version as soon as possible.[more]

AuthorTopic: Watermark on a per image basis (Read 152096 times)

Hopefully this is in the right place. gaugau suggested I post this in a thread so here goes. I am starting this off by saying this is bits and pieces of code from different hacks for watermarking with my add on for deciding which images get it and which do not.

First I made my watermark image and uploaded it to my main gallery directory. My file was called watermark.png

Then I created a file called logo.php and uploaded it to the main gallery directory with the following code

return 'logo.php?picturename='.$url_prefix[$pic_row['url_prefix']]. path2url($pic_row['filepath']. $pic_prefix[$mode]. $pic_row['filename']); }In the config section of your gallery set the "Custom fields for image description" Field 1 name to "Watermark".

Now is the optional part. If you want the watermark on by default (it is only on by default for images you upload after you make this change, the other images you will have to go through and turn it on one by one. I haven't found a way around that although I am sure there is a way to do it in one big batch) go to

I forgot to mention that you must have GD2 to make this particular watermark script work. The choosing which images it is on is separate from that.

Mine is 2 colors. I just kept it simple. But realistically you could use any of the actual watermark scripts listed on this site. DJ AXION's script on the old board will work great if you have used that before and it worked. The main important bit for the deciding which images it is on is the if statement in the include/functions.inc.php file and setting the "Custom fields for image description" Field 1 name to "Watermark" and putting "YES" in that field for each picture you want to carry the watermark. Once you have that value set to YES you can find the line that your watermark script replaces in the functions.inc.php file and add the if else conditional to it to get the same results. I hope I explained that well.

I was playing with the opecity option but can't really get it to work. I tried putting the original pic with transparency level of about 50% and changed the value in the logo.php file to 50 as well but it does not display it correctly.

I will attach my image here for you to play with if that will help. It doesn't actually have any transparency in it. It is just a two color image. Black is the color that I want to be transparent so I have the $transcolor variable set to match. Then change your $opacity variable to some different values to see the difference it makes on your site.

No, this is an on-th-fly system, which means it creates the image in memory and sends it directly to the browser.

Quote from: "Epsilon"

┐how about resources? it consumes a lot of?

Resource consumption depends on website/server traffic. If you have a small site with your own server, you will probably not even notice it. If you have a high traffic site/server, you might notice image serving delays if your hardware is not good enough to handle the increased CPU/memory demand.

Do any of the watermark mods posted around here work for you? I started with the one from DJ AXION and added to it. Maybe try those and see if you can get any of them to work, if yes then it is fairly easy to add on my yes/no part.

I modified Karri's code to hide the path to the albums and to make the script work with global_registers Off (it was the reason why it wasn't working for me). If you want to protect the albums folders, simply make a ".htaccess" file with "deny from all" written in it and it'll be protected.

Now the pictures will be loaded as: watermark.php?photo=blablabla.jpg! It is very easy to modify if you want something else than "?photo=*" you only have two words to change.

#############################################On the older board, there were a mod for watermark with GD that was allowing .gif and .png images to be watermarked, I didn't get it to work, anyone got it working with CPG 1.2.1?