forum.coppermine-gallery.net

No Support => Modifications/Add-Ons/Hacks => Mods: Watermarking & image manipulation => Topic started by: Karri on January 22, 2004, 02:15:46 am

Title: Watermark on a per image basis
Post by: Karri on January 22, 2004, 02:15:46 am
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
Code: [Select]
<?
//Most coding by semisphere
//http://gallery.menalto.com/index.php?name=PNphpBB2&file=viewtopic&t=4053&start=0
// A few lines by BY DJ AXION
// e-mail: DJ@the-expansion.com
// Enjoy this script!
 


######################################################################################################
## YOUR settings HERE
######################################################################################################
                                                                                                                                                                                       
        // watermark IMAGE settings
       
        $watermark_width        = 143;                                        // watermark wanted width
       
        $watermark_height        = 20;                                        // watermark wanted height
       
        /*
        NOTE
       
        If the watermark is resized, transparency may contain lines and spots of your transparency color.
        Try to put the right size from the beginning
       
        */
       
        $opacity                = 90;                                        // 0 completely invisible
       
        $margin_x                = 0.1;                                        // margin from the right in pixels (x axis)
       
        $margin_y                = 0.1;                                        // margin from the bottom in pixels (y axis)
       
        $quality                = 100;                                         // 100 is maximum quality
       
        $watermark_image        = "watermark.png";       
        // Full path to image
       
        $watermark_type                = "PNG";                                 // JPEG or PNG
       
        $transColor                = array(0, 0, 0);                 // transparency color index in rgb
       
######################################################################################################
## DON'T EDIT BELLOW THIS LINE
## well, if you want to, you won't be busted ;-) 
######################################################################################################


       
        // get the file we want to watermark
        $file                        = imagecreatefromjpeg($picturename);

        // get the image details and create an image
        $image_width                = imagesx($file);
        $image_height                = imagesy($file);
        $image                        = $file;








if (!preg_match("/thumb_/i", "$picturename"))
{

                // get the watermark details, and open it
                $watermark_info                = getImageSize($watermark_image);

                eval ("\$watermark = ImageCreateFrom$watermark_type(\$watermark_image);");

                // calculate scale of watermark and create scaled watermark
                $scaled_watermark         = imageCreateTrueColor($watermark_width, $watermark_height);

                // resize the watermark to the new scale
                imageCopyResampled($scaled_watermark, $watermark, 0, 0, 0, 0, $watermark_width, $watermark_height, $watermark_info[0], $watermark_info[1]);

                // set the transparent color ($transColor)
                $transparentColor        = imagecolorallocate ($scaled_watermark, $transColor[0],$transColor[1],$transColor[2]);

                imagecolortransparent($scaled_watermark, $transparentColor);

                // add the watermark to the image
                 ImageCopyMerge($image, $scaled_watermark, $image_width - $watermark_width - ($watermark_width * $margin_x), $image_height - $watermark_height - ($watermark_height * $margin_y), 0, 0, $watermark_info[0], $watermark_info[1], $opacity);


}


       


        // send out a header
        header("content-type:image/jpeg");

        // send the image
        imagejpeg($image,'',$quality);

        // clean up
        imagedestroy($image);

?>


Next in include/functions.inc.php find
Code: [Select]
        return $url_prefix[$pic_row['url_prefix']]. path2url($pic_row['filepath']. $pic_prefix[$mode]. $pic_row['filename']);
and change it to

Code: [Select]
if ($pic_row['user1']!="YES") {

return $url_prefix[$pic_row['url_prefix']]. path2url($pic_row['filepath']. $pic_prefix[$mode]. $pic_row['filename']);


} else {

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

include/picmgmt.inc.php and change

Code: [Select]
function add_picture($aid, $filepath, $filename, $title = '', $caption = '', $keywords = '', $user1 = '', $user2 = '', $user3 = '', $user4 = '', $category = 0, $raw_ip = '', $hdr_ip = '')
to

Code: [Select]
function add_picture($aid, $filepath, $filename, $title = '', $caption = '', $keywords = '', $user1 = 'YES', $user2 = '', $user3 = '', $user4 = '', $category = 0, $raw_ip = '', $hdr_ip = '')
The script looks for the  "YES" in the watermark field ($user1) so you can basically set it to anything other than YES and the watermark won't appear. 

I am sure this hack is pretty primitive so if anyone has a way to improve it, feel free.  :)  I hope someone finds this useful. :)


BTW: If you want to see it in action go to http://www.baileychase.com/Gallery/  most of the images have the watermark on check http://www.baileychase.com/Gallery/thumbnails.php?album=173 for a few that do not.

EDITED: Updated watermarking code to include the change Frank suggested for determining a thumbnail on page 3 of this thread
Title: Watermark on a per image basis
Post by: DefenceTalk.com on January 22, 2004, 04:57:43 pm
Hi, thanks for the "mod."

I tried but it shows red X intead of the pic.  :?  What resolution should the logo.png file be??? 256 color?
Title: Watermark on a per image basis
Post by: Karri on January 22, 2004, 05:27:12 pm
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.
Title: Watermark on a per image basis
Post by: DefenceTalk.com on January 22, 2004, 06:00:18 pm
Got it. I forgot to rename logo.png to watermark.png. :D ;)

Thanks it works great.
Title: Watermark on a per image basis
Post by: Karri on January 22, 2004, 06:02:29 pm
Very cool. :)  I am glad it worked for you. :)
Title: hello
Post by: invision on January 23, 2004, 03:21:00 pm
can you help me to make this :

here is the demo of this : http://www.vietphp.info/a2album/

you can see the random pictures is  black and white color ! but when you click to the pic ! and this will come to original color !

tell me how can i make it ? Thanks
Title: Watermark on a per image basis
Post by: DefenceTalk.com on January 23, 2004, 05:40:41 pm
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.  :(
Title: Watermark on a per image basis
Post by: Karri on January 23, 2004, 06:22:04 pm
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.  

(http://www.baileychase.com/Gallery/watermark.png)
Title: Some questions...
Post by: epsilon on January 23, 2004, 08:21:53 pm
I would know if this hack consumes resources extra of the server on having created the watermarks in the air...

How it works?

The hack Overwrites the original image or does it create a temporary image/photo to add the watermark?

Its possible select the albums where do you want add the watermark?
Title: Watermark on a per image basis
Post by: hyperion on January 24, 2004, 12:35:30 am
Re: Batch change for $user1 -

An uppdate command to the pictures table for the user1 field would accomplish this.  You could add where clauses to update specific albums, etc.

@Epsilon:

Server resources/Method: Yes, this is an on-the-fly watermark system.

Possible to select an album: Yes, you could turn $user1 into an album id value in db_input. Then you could modify the if statement to check for the album IDs that you want to auto watermark.
Title: Ok but..
Post by: epsilon on January 24, 2004, 09:58:57 am
¿It deletes the original non watermarked photos/imagens?

¿how about resources? it consumes a lot of?

Thnks (please an example with code of change $user1 to id of albums)
Title: Watermark on a per image basis
Post by: hyperion on January 24, 2004, 05:28:54 pm
Epsilon,

Quote from: "Epsilon"
¿It deletes the original non watermarked photos/imagens?


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.  

Quote from: "Epsilon"
Thnks (please an example with code of change $user1 to id of albums)


Make the following change to include/picmgmt.inc.php. Find:

Code: [Select]

// Add a picture to an album
function add_picture($aid, $filepath, $filename, $title = '', $caption = '', $keywords = '', $user1 = '', $user2 = '', $user3 = '', $user4 = '', $category = 0, $raw_ip = '', $hdr_ip = '')
{
    global $CONFIG, $ERROR, $USER_DATA, $PIC_NEED_APPROVAL;
    global $lang_errors;



Change it to:

Code: [Select]

// Add a picture to an album
function add_picture($aid, $filepath, $filename, $title = '', $caption = '', $keywords = '', $user1 = '', $user2 = '', $user3 = '', $user4 = '', $category = 0, $raw_ip = '', $hdr_ip = '')
{
    global $CONFIG, $ERROR, $USER_DATA, $PIC_NEED_APPROVAL;
    global $lang_errors;

    $user1 = $aid;


Then, take the following part of Karri's modification:

Code: [Select]

if ($pic_row['user1']!="YES") {

return $url_prefix[$pic_row['url_prefix']]. path2url($pic_row['filepath']. $pic_prefix[$mode]. $pic_row['filename']);


} else {

return 'logo.php?picturename='.$url_prefix[$pic_row['url_prefix']]. path2url($pic_row['filepath']. $pic_prefix[$mode]. $pic_row['filename']); }  


and change it to:

Code: [Select]

if ($pic_row['user1']=1 or $pic_row['user1']=2 or $pic_row['user1']=3 ) {

return 'logo.php?picturename='.$url_prefix[$pic_row['url_prefix']]. path2url($pic_row['filepath']. $pic_prefix[$mode]. $pic_row['filename']);

} else {

return $url_prefix[$pic_row['url_prefix']]. path2url($pic_row['filepath']. $pic_prefix[$mode]. $pic_row['filename']);

}  


You can determine which album ID numbers should go in the "or" list by looking at the albums table in your database, or by looking at the HTML source to the upload page.

Please note that I have not tested this.
Title: Watermark on a per image basis
Post by: hyperion on January 26, 2004, 07:05:47 am
Alternatively, one can forgo the use of the $user1 field and rely directly on the album id, like so:

Code: [Select]

if ($pic_row['aid']=1 or $pic_row['aid']=2 or $pic_row['aid']=3 ) {

return 'logo.php?picturename='.$url_prefix[$pic_row['url_prefix']]. path2url($pic_row['filepath']. $pic_prefix[$mode]. $pic_row['filename']);

} else {

return $url_prefix[$pic_row['url_prefix']]. path2url($pic_row['filepath']. $pic_prefix[$mode]. $pic_row['filename']);

}  
Title: hmm
Post by: klaws on January 26, 2004, 11:55:53 am
Cant seem to get it to work...
just get a red cross instead of the image.

i have installed it, made the fields, and put YES on one picture...

Maybe i'm missing something on the server?!?
running Linux, Apache, PHP4, GD + GD2, ImageMagick...

Any ideas :?:
Title: Watermark on a per image basis
Post by: ihorus on January 26, 2004, 04:07:24 pm
hi, Klaws i got the same problems that you have, the same red cross instead of the pic, if you found the solution, please let me know. Thanx.
Title: Watermark on a per image basis
Post by: Karri on January 26, 2004, 06:20:17 pm
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.
Title: Watermark on a per image basis
Post by: klaws on January 26, 2004, 06:37:04 pm
nope doesn't work either...

posted my problem here because the other post is getting toally
impossible to make anything out of now  :)

i think it's a server problem, but cant see what the problem is...
Title: Watermark on a per image basis
Post by: ihorus on January 26, 2004, 07:21:53 pm
ok,  i got it,!! now is working perfectly!! it was a studid "text document/Rich text format" error :lol:   Klaws, save your logo.php as a "text document" file not a "rich text format (rtf)" file.
Title: Watermark on a per image basis
Post by: klaws on January 30, 2004, 04:06:48 pm
Hmm... don't think that's my problem..

pasting the php code directly in "pico" in a shell.
And Linux certanly doesn't now what rtf is :)

-Klaws
Title: Watermark on a per image basis
Post by: Frank on February 01, 2004, 12:01:56 am
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.


In include/functions.inc.php:

Replace:
Code: [Select]
return 'watermark.php?picturename='.$url_prefix[$pic_row['url_prefix']]. path2url($pic_row['filepath']. $pic_prefix[$mode]. $pic_row['filename']);
By:
Code: [Select]
return 'watermark.php?photo='.$pic_prefix[$mode]. $pic_row['filename'];


In watermark.php:

Before:
Code: [Select]
   // get the file we want to watermark
    $file            = imagecreatefromjpeg($picturename);

Add:
Code: [Select]
   $picture = $_GET[photo];
    $picturename = 'albums/userpics/'. $picture;



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?
Title: Watermark on a per image basis
Post by: Frank on February 01, 2004, 02:40:50 am
I just thought about it... My galleries are user's galleries only, so the hack to hide the path to the pictures wouldn't work if someone is using public galleries (galleries non owned by users).

It would be easy to MOD it to make it work with both public and user's galleries. If anyone's interested I could take a look at it.


Frank
Title: Watermark on a per image basis
Post by: t3kn0byt3 on February 03, 2004, 04:18:16 am
I used phpMyAdmin to update all the oldpics in my gallery with the watermark without going image to image.  Here is my code
Code: [Select]
UPDATE `cpg11d_pictures` SET `user1` = 'YES';
Change the cpg11d to whatever your prefix is.
Title: Thank You!!!
Post by: almostaphotographer on February 17, 2004, 03:36:06 am
This worked great!!  Thank you!!

Now, I need to find somebody that can create a mod so I can add pedigrees to horse pictures!!

Tracey  :D
Title: Watermark on a per image basis
Post by: t3kn0byt3 on February 17, 2004, 05:41:50 pm
Quote
This worked great!! Thank you!!

Now, I need to find somebody that can create a mod so I can add pedigrees to horse pictures!!

Tracey


Try this thread:

http://forum.coppermine-gallery.net/index.php?topic=2526
Title: That's good, but need to add a table for extra fields
Post by: almostaphotographer on February 17, 2004, 07:15:54 pm
Yes, I've got that and printed it out, but am trying to figure out (not a PHP programmer, wish I were) how to add a table so that the additional fields will show up in the template where I want them too.  Perplexing.
Title: Watermark on a per image basis
Post by: SPyKoN on February 21, 2004, 04:41:43 pm
Quote from: "Frank"
I just thought about it... My galleries are user's galleries only, so the hack to hide the path to the pictures wouldn't work if someone is using public galleries (galleries non owned by users).

It would be easy to MOD it to make it work with both public and user's galleries. If anyone's interested I could take a look at it.


Frank


Yeah, would be nice if it also worked with public galleries!
Title: Watermark on a per image basis
Post by: t3kn0byt3 on February 21, 2004, 05:48:39 pm
Use this to update all images (including public) after they are uploaded.


Code:
UPDATE `cpg11d_pictures` SET `user1` = 'YES';

Change the cpg11d to whatever your prefix is.
Title: Watermark on a per image basis
Post by: Ravage on March 03, 2004, 07:36:04 pm
The mod works for me just fine but when in debug mode I get this error

Code: [Select]
Notice: Undefined index: user1 in /home/thomas/public_html/photos/include/functions.inc.php on line 1100

Line 1100 is
Code: [Select]
if ($pic_row['user1']!="") {

I took out the yes becuase I wanted all pics to be watermark.
Title: Watermark on a per image basis
Post by: hyperion on March 03, 2004, 07:46:29 pm
If you want all pics to be watermarked, simply use the original watermark mod, and save a custom field for something else.
Title: Watermark on a per image basis
Post by: Ravage on March 03, 2004, 08:05:13 pm
Inot sure which is the original. But couldn't use the other becuase no imagemagik installed.
Title: Watermark on a per image basis
Post by: Joachim Müller on March 04, 2004, 06:01:48 am
there are two Watermark mods: one for ImageMagick (http://forum.coppermine-gallery.net/index.php?topic=1467), one for GD (http://forum.coppermine-gallery.net/index.php?topic=77) on the old board. See if the "old" one works for you...

GauGau
Title: Watermark on a per image basis
Post by: enginyr on March 07, 2004, 12:56:02 pm
Well I see all these posts and such about a mod that can insert a watermark and such but I need someone to handle this for me.
I have a nuke php forum and need the gallery to automatically add the watermark img and resize the picture:

600x400 @ 70kb
       
     From

2100 x 1600 @ 1.5 megs

I need someone who has already done this (no time for experimenting).

This is not a request for free help.....you will be paid.

I also need the scrolling gallery add-on.

Thanks, Steve....
Title: Watermark on a per image basis
Post by: Joachim Müller on March 07, 2004, 08:33:52 pm
wrong board: nuke support has moved (see BOARD MOVED PLEASE READ THIS (http://forum.coppermine-gallery.net/index.php?topic=2277)).

GauGau
Title: Watermark on a per image basis
Post by: Frank on March 28, 2004, 06:47:14 pm
I did a small modification which will not show the watermark on any thumbnail. It'll work 100% of the time. I did it because of the current way the mod was working: some thumbnails could be larger than what could be listed as not being watermarked (default: 200 pixels wide) and it wasn't looking professionnal when one large thumbnail had a watermark in the thumbnails page, while all the other thumbnails didn't have the watermark on!


In logo.php:
Replace:
Code: [Select]
if ($image_width > 200)

With:
Code: [Select]
if (!preg_match("/thumb_/i", "$picturename"))

How it works? It cheks if there's a "thumb_" in the filename, if no, then it prints the picture with the watermark ;)


Have fun, Frank
Title: Watermark on a per image basis
Post by: Frank on March 29, 2004, 06:28:40 am
I forgot something: if the picture is quite small when it isn't a thumbnail then with the modification I posted right on top of this post, a small picture could have been watermarked, which is quite ugly IMO lol.

To leave small images out of watermarking, simply:

Replace:
Code: [Select]
if (!preg_match("/thumb_/i", "$picturename"))

With:
Code: [Select]
if ((!preg_match("/thumb_/i", "$picturename")) && ($image_width > 250))


Have fun! Frank
Title: Watermark on a per image basis
Post by: Karri on March 29, 2004, 05:44:39 pm
Quote from: "Frank"
I did a small modification which will not show the watermark on any thumbnail. It'll work 100% of the time. I did it because of the current way the mod was working: some thumbnails could be larger than what could be listed as not being watermarked (default: 200 pixels wide) and it wasn't looking professionnal when one large thumbnail had a watermark in the thumbnails page, while all the other thumbnails didn't have the watermark on!


Thanks for the addition!!!  I was never quite happy with how it determined a thumbnail. :)
Title: Watermark on a per image basis
Post by: yanola on April 07, 2004, 01:41:29 am
Quote from: "t3kn0byt3"
I used phpMyAdmin to update all the oldpics in my gallery with the watermark without going image to image.  Here is my code
Code: [Select]
UPDATE `cpg11d_pictures` SET `user1` = 'YES';
Change the cpg11d to whatever your prefix is.


Do I need to have phpMyAdmin installed in order to use this code?  How would I implement it?
Title: Watermark on a per image basis
Post by: Nibbler on April 07, 2004, 01:59:15 am
If you dont have access to phpmyadmin or similar, then just save the following into a php file, upload to your cpg dir and run it from your browser.

Code: [Select]

<?php
define
('IN_COPPERMINE'true);
require(
'include/init.inc.php');
echo 
mysql_query("UPDATE `cpg11d_pictures` SET `user1` = 'YES'") ? "Succeeded" mysql_error();
?>

Title: Watermark on a per image basis
Post by: yanola on April 07, 2004, 02:07:43 am
Quote from: "Nibbler"
If you dont have access to phpmyadmin or similar, then just save the following into a php file, upload to your cpg dir and run it from your browser.

Code: [Select]

<?php
define
('IN_COPPERMINE'true);
require(
'include/init.inc.php');
echo 
mysql_query("UPDATE `cpg11d_pictures` SET `user1` = 'YES'") ? "Succeeded" mysql_error();
?>



Thank you!!!

=edited=

Is there a way I can get the watermark to show up over the slideshow?
Title: Watermark on a per image basis
Post by: troublemaker on April 15, 2004, 07:19:09 am
:cry:
I'm really not this smart
anyone able to break this down for me?
 pm me if your shy of showing your tender side
Title: Re: Watermark on a per image basis
Post by: Spiderm@n(tm) on June 18, 2004, 09:52:40 am
I have made some edits in the code.
It now works with JPEG and PNG images, detects the type and the size of the watermark image automaticaly.
Code: [Select]
<?php
function get_ext($fname)
{
$arr explode(".",$fname);
return $arr[sizeof($arr)-1];
}

function 
wm_pos ($img_size$wm_size$margin$pos)
{
switch ($pos)
{
case 0$rpos $margin; break;
case 1$rpos $img_size/$wm_size/2; break;
case 2$rpos $img_size $margin $wm_size; break;
default: $rpos $img_size $margin $wm_size; break;
}
return $rpos;
}

//Most coding by semisphere
//http://gallery.menalto.com/index.php?name=PNphpBB2&file=viewtopic&t=4053&start=0
// A few lines by BY DJ AXION
// e-mail: DJ@the-expansion.com
// Enjoy this script!



######################################################################################################
## YOUR settings HERE
######################################################################################################

// watermark IMAGE settings

/*
NOTE

If the watermark is resized, transparency may contain lines and spots of your transparency color.
Try to put the right size from the beginning

*/

$position = array(22); // position of the watermark image (x, y)
// 0,0 | 0,1 | 0,2
// 1,0 | 1,1 | 1,2
// 2,0 | 2,1 | 2,2

$opacity 80; // 0 completely invisible

$margin_x 10; // margin from the right in pixels (x axis)

$margin_y 10; // margin from the bottom in pixels (y axis)

$quality 100; // 100 is maximum quality

$watermark_image "watermark.jpg"; // Full path to image 

$transColor = array(000); // transparency color index in rgb

######################################################################################################
## DON'T EDIT BELLOW THIS LINE
## well, if you want to, you won't be busted
######################################################################################################

if (get_ext($watermark_image) == ('jpg' || 'jpeg'))
$watermark_type "JPEG"; // JPEG
if (get_ext($watermark_image) == 'png')
$watermark_type "PNG"; // PNG

// get the file we want to watermark
$get $_GET["picturename"];
if (get_ext($get) == ('jpg' || 'jpeg'))
$image_type JPEG;
if (get_ext($get) == 'png')
$image_type PNG;

eval ("\$file = ImageCreateFrom$image_type(\$get);");

// get the image details and create an image
$image_width imagesx($file);
$image_height imagesy($file);
$image $file;







//if ((!preg_match("/thumb_/i", "$picturename")) && ($image_width > 250))
if ($image_width 250)
{

// get the watermark details, and open it
$watermark_info getImageSize($watermark_image);

eval ("\$watermark = ImageCreateFrom$watermark_type(\$watermark_image);");
$watermark_width imagesx($watermark);
$watermark_height imagesy($watermark);

// calculate scale of watermark and create scaled watermark
$scaled_watermark imageCreateTrueColor($watermark_width$watermark_height);

// resize the watermark to the new scale
imageCopyResampled($scaled_watermark$watermark0000$watermark_width$watermark_height$watermark_info[0], $watermark_info[1]);

// set the transparent color ($transColor)
$transparentColor imagecolorallocate ($scaled_watermark$transColor[0], $transColor[1], $transColor[2]);

imagecolortransparent($scaled_watermark$transparentColor);

// add the watermark to the image
// ImageCopyMerge($image, $scaled_watermark, wm_pos($image_width, $watermark_width, $margin_x, 0), wm_pos($image_height, $watermark_height, $margin_y, 0), 0, 0, $watermark_info[0], $watermark_info[1], $opacity); //Upper Left
// ImageCopyMerge($image, $scaled_watermark, wm_pos($image_width, $watermark_width, $margin_x, 0), wm_pos($image_height, $watermark_height, $margin_y, 1), 0, 0, $watermark_info[0], $watermark_info[1], $opacity); //Upper Center
// ImageCopyMerge($image, $scaled_watermark, wm_pos($image_width, $watermark_width, $margin_x, 0), wm_pos($image_height, $watermark_height, $margin_y, 2), 0, 0, $watermark_info[0], $watermark_info[1], $opacity); //Upper Right
// ImageCopyMerge($image, $scaled_watermark, wm_pos($image_width, $watermark_width, $margin_x, 1), wm_pos($image_height, $watermark_height, $margin_y, 0), 0, 0, $watermark_info[0], $watermark_info[1], $opacity); //Center Left
// ImageCopyMerge($image, $scaled_watermark, wm_pos($image_width, $watermark_width, $margin_x, 1), wm_pos($image_height, $watermark_height, $margin_y, 1), 0, 0, $watermark_info[0], $watermark_info[1], $opacity); //Center Center
// ImageCopyMerge($image, $scaled_watermark, wm_pos($image_width, $watermark_width, $margin_x, 1), wm_pos($image_height, $watermark_height, $margin_y, 2), 0, 0, $watermark_info[0], $watermark_info[1], $opacity); //Center Right
// ImageCopyMerge($image, $scaled_watermark, wm_pos($image_width, $watermark_width, $margin_x, 2), wm_pos($image_height, $watermark_height, $margin_y, 0), 0, 0, $watermark_info[0], $watermark_info[1], $opacity); //Lower Left
// ImageCopyMerge($image, $scaled_watermark, wm_pos($image_width, $watermark_width, $margin_x, 2), wm_pos($image_height, $watermark_height, $margin_y, 1), 0, 0, $watermark_info[0], $watermark_info[1], $opacity); //Lower Center
// ImageCopyMerge($image, $scaled_watermark, wm_pos($image_width, $watermark_width, $margin_x, 2), wm_pos($image_height, $watermark_height, $margin_y, 2), 0, 0, $watermark_info[0], $watermark_info[1], $opacity); //Lower Right

ImageCopyMerge($image, $scaled_watermark, wm_pos($image_width$watermark_width$margin_x$position[0]), wm_pos($image_height$watermark_height$margin_y$position[1]), 0, 0, $watermark_info[0], $watermark_info[1], $opacity); //Using the "wm_pos" function & "position" array

}





// send out a header
header("content-type:image/$image_type");

// send the image
eval ("image$image_type (\$image,'',\$quality);");

// clean up
imagedestroy($image);

?>

The opacy works onli when the watermark image is a PNG file.
Title: Re: Watermark on a per image basis
Post by: Karri on June 22, 2004, 07:45:08 pm
It should have already worked with PNG or JPG.  It didn't autodetect the type but when you were putting in the name of the watermark image, the very next line was for telling it what type of file it was.

$watermark_image        = "watermark.png";                               // Full path to image
       
       $watermark_type                = "PNG";                                 // JPEG or PNG
Title: Re: Watermark on a per image basis
Post by: Spiderm@n(tm) on June 23, 2004, 12:53:14 pm
I've got some more edits:
Code: [Select]
<?php
function get_ext($fname)
{
$arr explode(".",$fname);
return $arr[sizeof($arr)-1];
}

function 
wm_pos ($img_size$wm_size$margin$pos)
{
switch ($pos)
{
case 0$rpos $margin; break;
case 1$rpos $img_size/$wm_size/2; break;
case 2$rpos $img_size $margin $wm_size; break;
default: $rpos $img_size $margin $wm_size; break;
}
return $rpos;
}

//Most coding by semisphere
//http://gallery.menalto.com/index.php?name=PNphpBB2&file=viewtopic&t=4053&start=0
// A few lines by BY DJ AXION
// e-mail: DJ@the-expansion.com
// Enjoy this script!



######################################################################################################
## YOUR settings HERE
######################################################################################################

// watermark IMAGE settings

/*
NOTE

If the watermark is resized, transparency may contain lines and spots of your transparency color.
Try to put the right size from the beginning

*/

$position = array(22); // position of the watermark image (x, y)
// 0,0 | 0,1 | 0,2
// 1,0 | 1,1 | 1,2
// 2,0 | 2,1 | 2,2

$opacity 80; // 0 completely invisible

$margin_x 10; // margin from the right in pixels (x axis)

$margin_y 10; // margin from the bottom in pixels (y axis)

$quality 100; // 100 is maximum quality

$watermark_image "watermark.jpg"; // Full path to image 

$transColor = array(000); // transparency color index in rgb

######################################################################################################
## DON'T EDIT BELLOW THIS LINE
## well, if you want to, you won't be busted
######################################################################################################

if (get_ext($watermark_image) == ('jpg' || 'jpeg'))
$watermark_type "JPEG"; // JPEG
if (get_ext($watermark_image) == 'png')
$watermark_type "PNG"; // PNG

// get the file we want to watermark
$get $_GET["picturename"];
if (get_ext($get) == ('jpg' || 'jpeg'))
$image_type JPEG;
if (get_ext($get) == 'png')
$image_type PNG;

eval ("\$file = ImageCreateFrom$image_type(\$get);");

// get the image details and create an image
$image_width imagesx($file);
$image_height imagesy($file);
$image $file;







//if ((!preg_match("/thumb_/i", "$picturename")) && ($image_width > 250))
if ($image_width 250)
{

// get the watermark details, and open it
$watermark_info getImageSize($watermark_image);

eval ("\$watermark = ImageCreateFrom$watermark_type(\$watermark_image);");
$watermark_width imagesx($watermark);
$watermark_height imagesy($watermark);

// set the transparent color ($transColor)
$transparentColor imagecolorallocate ($watermark$transColor[0], $transColor[1], $transColor[2]);

imagecolortransparent($watermark$transparentColor);

// add the watermark to the image
// ImageCopyMerge($image, $watermark, wm_pos($image_width, $watermark_width, $margin_x, 0), wm_pos($image_height, $watermark_height, $margin_y, 0), 0, 0, $watermark_info[0], $watermark_info[1], $opacity); //Upper Left
// ImageCopyMerge($image, $watermark, wm_pos($image_width, $watermark_width, $margin_x, 0), wm_pos($image_height, $watermark_height, $margin_y, 1), 0, 0, $watermark_info[0], $watermark_info[1], $opacity); //Upper Center
// ImageCopyMerge($image, $watermark, wm_pos($image_width, $watermark_width, $margin_x, 0), wm_pos($image_height, $watermark_height, $margin_y, 2), 0, 0, $watermark_info[0], $watermark_info[1], $opacity); //Upper Right
// ImageCopyMerge($image, $watermark, wm_pos($image_width, $watermark_width, $margin_x, 1), wm_pos($image_height, $watermark_height, $margin_y, 0), 0, 0, $watermark_info[0], $watermark_info[1], $opacity); //Center Left
// ImageCopyMerge($image, $watermark, wm_pos($image_width, $watermark_width, $margin_x, 1), wm_pos($image_height, $watermark_height, $margin_y, 1), 0, 0, $watermark_info[0], $watermark_info[1], $opacity); //Center Center
// ImageCopyMerge($image, $watermark, wm_pos($image_width, $watermark_width, $margin_x, 1), wm_pos($image_height, $watermark_height, $margin_y, 2), 0, 0, $watermark_info[0], $watermark_info[1], $opacity); //Center Right
// ImageCopyMerge($image, $watermark, wm_pos($image_width, $watermark_width, $margin_x, 2), wm_pos($image_height, $watermark_height, $margin_y, 0), 0, 0, $watermark_info[0], $watermark_info[1], $opacity); //Lower Left
// ImageCopyMerge($image, $watermark, wm_pos($image_width, $watermark_width, $margin_x, 2), wm_pos($image_height, $watermark_height, $margin_y, 1), 0, 0, $watermark_info[0], $watermark_info[1], $opacity); //Lower Center
// ImageCopyMerge($image, $watermark, wm_pos($image_width, $watermark_width, $margin_x, 2), wm_pos($image_height, $watermark_height, $margin_y, 2), 0, 0, $watermark_info[0], $watermark_info[1], $opacity); //Lower Right

ImageCopyMerge($image, $watermark, wm_pos($image_width$watermark_width$margin_x$position[0]), wm_pos($image_height$watermark_height$margin_y$position[1]), 0, 0, $watermark_info[0], $watermark_info[1], $opacity); //Using the "wm_pos" function & "position" array

}





// send out a header
header("content-type:image/$image_type");

// send the image
eval ("image$image_type (\$image,'',\$quality);");

// clean up
imagedestroy($image);

?>


It should have already worked with PNG or JPG.  It didn't autodetect the type but when you were putting in the name of the watermark image, the very next line was for telling it what type of file it was.

$watermark_image        = "watermark.png";                               // Full path to image
       
       $watermark_type                = "PNG";                                 // JPEG or PNG

I was talking about the watermarkED image, not the watermark, I receave error when I try to watermark .PNG image
Title: Re: Watermark on a per image basis
Post by: skybax on August 08, 2004, 11:39:25 am
Does anyone have load stats from their servers when using this script. I like the idea and want to use it, but owners of a site I am building to use it on is projecting 10k-20k pics and a large visitor base. So if this would cause too much strain - should i go with an off server watermarking solution?
Title: Re: Watermark on a per image basis
Post by: Joachim Müller on August 08, 2004, 12:41:33 pm
I recommend going for a solution that applies a watermark once (during upload) to the pic. Applying watermarks "on the fly" each time the pic loads is way to resources-consuming and only meant for users running sites that don't get relevant traffic at all (who have never more than one user online at a time).
The best solution is applying a watermark to the pics on your client before uploading - faster, safer, not so resources-consuming.

GauGau
Title: Re: Watermark on a per image basis
Post by: PCGUY112887 on August 17, 2004, 04:04:21 am
Ok now i'm lost... I remember installing this when this post was first made... now I see a bunch of versions everywhere.  Now which code exactelly should I use, and what instructions?  Maybe we could make a final copy of this with instructions for a sticky?
Title: Re: Watermark on a per image basis
Post by: skybax on August 17, 2004, 03:42:31 pm
There are a slew of these mods running around. To pick one and single it out is not really a sticky solution. But I do agree simplify the posts... by singling out the strength of the different versions. Such as load times, server strain, ability to turn on/off per image....

-T  8)
Title: Re: Watermark on a per image basis
Post by: PCGUY112887 on August 19, 2004, 01:08:18 am
Well I just need something that works with ImageMagik... is easy to install (no editing a million files)... and does it to every file no matter what.  O and works with 1.3.2 :)
Any suggestinons on what to pick?
Title: Re: Watermark on a per image basis
Post by: skybax on August 19, 2004, 03:09:23 am
Well I just need something that works with ImageMagik... is easy to install (no editing a million files)... and does it to every file no matter what.  O and works with 1.3.2 :)
Any suggestinons on what to pick?

The only one I found is located here (http://forum.coppermine-gallery.net/index.php?topic=1467.0). It's for 1.2.1 but I think with a little modification it would work with 1.3.2 - I don't have imagemagik so I wouldn't have a way to test... But if you have that installed it would be fun to work on a project. I am currently working on a version compatiable with GD2.0 [1.3.x] and adding multiple features (right now it's in crashed mode on my version of CPG cause of all the features I'm adding to it.) But I hope to have it finished by the end of the month.

-T  8)
Title: Re: Watermark on a per image basis
Post by: Nekto63 on November 02, 2004, 12:47:00 pm
How it can be applied to CPG for PHPnuke/Postnuke (cpgnuke122b)?

Instead of a line    return $url_prefix[$pic_row['url_prefix']]. path2url($pic_row['filepath']. $pic_prefix[$mode]. $pic_row['filename']);
In a file  functions.inc.php    return path2url($pic_row['filepath'] . $pic_prefix[$mode] . $pic_row['filename']);
How to be?
Title: Re: Watermark on a per image basis
Post by: Joachim Müller on November 03, 2004, 05:48:23 am
there's no nuke support to be found here - simply because we don't know it. Please do not post nuke related posts on this board.

Joachim
Title: Re: Watermark on a per image basis
Post by: Thursday on January 29, 2005, 11:56:32 pm
Is it normal that after i've applied watermark on a image, when i click on to see the original picture it doesn't work?
I mean, i got only an X and if i check the directory of the image i got this directiry which seems to be correct:

Quote
.../logo.php?picturename=albums/France/Meilleures/C%E9r%EAt/014.jpg
I've remplaced my webhost name by periods ;)

Also, after applying watermark, if i change the watermark picture it stills display the old one... Is it my browser cookies?
Title: Re: Watermark on a per image basis
Post by: davidshook on February 23, 2005, 05:20:31 pm
I am sorry if this is answered somewhere in this thread allerady.
How exactly does this MOD work:
1) do all the batch uploaded pictures get watermarked?
-- or, do I get to chose if batch uploaded pictures get watermarked?

2)  do individual uploaded pictures get water marked?
-- do users/members (as opposed to admin level) have any control over the water marking process in this case.

3) what happens when a user uploads video, mp3, zip, pdf file?
-- does the upload faile?
-- does the file become unreadable?


The reason I am asking this is because I am designing a site that will have  a gallery that allows loged-in members to upload there own pictures/videos/documents. I want to have a watermark on the pictures that the users upload. The user should not be able to upload a picture without a water mark (although it is ok if they have a choice where to place the watermark on the picture)

The rest of the galleries are not for uploads by users. For these galleries I do the batch uploading and the pictures are already watermarked on my desktop pc prior to upload.

So, to some it up: all pictures that are uploaded via http/form need to be watermarked.
Batch files should not be watermarked.
Non-picture files should not be a problem (since I do not limit the file type to be uploaded)


I also think that anyone that thinks about using water marking should have these answers before going through the work of installing and testing the MOD's.

Please help, thank's in advance
Title: Re: Watermark on a per image basis
Post by: Nibbler on February 23, 2005, 05:40:15 pm
This is on-the-fly watermarking. It doesn't permanently alter the pics, it just puts a watermark on when the pic is displayed. How the pic is uploaded is irrelevent. There are other mods around for permanent watermarking. I don't know about non-pics, but if it makes problems it's only a 1 line fix to make it skip non images.
Title: Re: Watermark on a per image basis
Post by: nukeworker on March 02, 2005, 01:33:35 pm
[edit]deleted question, found answer[/edit]
Title: Re: Watermark on a per image basis
Post by: trued on April 02, 2005, 07:09:45 pm
i just registered to this forum only to say that this hack worked for me. I followed the instructions exactly and modified the settings in the logo.php file and voila! watermarked images. For those trying to create the watermark image :

on photoshop I  went to

file>new> choose transparent bg and set the size you want it to be.

type in the text or create the image you want to display and thats it. Save as a watermark.png and upload to the root folder.
I noticed that the edges were choppy so I just went back to photoshop and added a black stroke to the text. this hid the choppy edges on lighter backgrounds.

I also was able to update all the pictures i had uploaded before this hack by going into phpmyadmin and editing the table cpg_pictures. in the box just replace :   SELECT * FROM `cpg_pictures`  with  UPDATE `cpg_pictures` SET `user1` = 'YES';...   just as explained by t3kn0byt3 .thank you

of course change the cpg part of cpg_pictures to reflect your prefix.

Any questions you can reply to this and maybe i can help. I am running imagemagik and linux/unix .

thanx to Karri for this great hack!

Title: Re: Watermark on a per image basis
Post by: fedexx on April 29, 2005, 06:17:36 am
Hello im traying to modify the hack "Watermark on a per image basis " but i have a problem that cannot solve.
I add a option in a "albums options" that it allows to select if I want or not add a  watermark to the pics of the album.
I want to add another option that allows to select that image I want to use, and to be able to use different imagenes for different albums.
Here is the code of "logo.php" i add a conection to the database to obtain the watermark image name´s but that don't works
Code: [Select]
<?
//Most coding by semisphere
//http://gallery.menalto.com/index.php?name=PNphpBB2&file=viewtopic&t=4053&start=0
// A few lines by BY DJ AXION
// e-mail: DJ@the-expansion.com
// Enjoy this script!
define('IN_COPPERMINE', true);
require('include/init.inc.php');
global $CONFIG;

######################################################################################################
## YOUR settings HERE
######################################################################################################

        // watermark IMAGE settings

        $watermark_width        = 143;                                        // watermark wanted width

        $watermark_height        = 20;                                        // watermark wanted height

        /*
        NOTE

        If the watermark is resized, transparency may contain lines and spots of your transparency color.
        Try to put the right size from the beginning

        */

        $opacity                = 90;                                        // 0 completely invisible

        $margin_x                = 0.1;                                        // margin from the right in pixels (x axis)

        $margin_y                = 0.1;                                        // margin from the bottom in pixels (y axis)

        $quality                = 100;                                         // 100 is maximum quality

        // Full path to image
$album=$pic_row['aid'];
$consulta = db_query("SELECT watermarkdir FROM cpg132_albums WHERE aid = '1'");
$num_filas=mysql_num_rows($consulta);
$array_datos=mysql_fetch_array($consulta);
foreach ($array_datos as $watermark){
        $watermark_image        = "watermark/".$watermark;
}

        $watermark_type                = "PNG";                                 // JPEG or PNG

        $transColor                = array(0, 0, 0);                 // transparency color index in rgb

######################################################################################################
## DON'T EDIT BELLOW THIS LINE
## well, if you want to, you won't be busted ;-)
######################################################################################################



        // get the file we want to watermark
        $file                        = imagecreatefromjpeg($picturename);

        // get the image details and create an image
        $image_width                = imagesx($file);
        $image_height                = imagesy($file);
        $image                        = $file;








if (!preg_match("/thumb_/i", "$picturename"))
{

                // get the watermark details, and open it
                $watermark_info                = getImageSize($watermark_image);

                eval ("\$watermark = ImageCreateFrom$watermark_type(\$watermark_image);");

                // calculate scale of watermark and create scaled watermark
                $scaled_watermark         = imageCreateTrueColor($watermark_width, $watermark_height);

                // resize the watermark to the new scale
                imageCopyResampled($scaled_watermark, $watermark, 0, 0, 0, 0, $watermark_width, $watermark_height, $watermark_info[0], $watermark_info[1]);

                // set the transparent color ($transColor)
                $transparentColor        = imagecolorallocate ($scaled_watermark, $transColor[0],$transColor[1],$transColor[2]);

                imagecolortransparent($scaled_watermark, $transparentColor);

                // add the watermark to the image
                 ImageCopyMerge($image, $scaled_watermark, $image_width - $watermark_width - ($watermark_width * $margin_x), $image_height - $watermark_height - ($watermark_height * $margin_y), 0, 0, $watermark_info[0], $watermark_info[1], $opacity);


}

Title: Re: Watermark on a per image basis
Post by: seboter on May 25, 2005, 12:22:04 pm
I had some problems to get this hack to work, so I looked through the code and I found something which causes this error and maybe my version will solve other users problems.


So, here we go...

Here is the part of the original code:
Quote
      ######################################################################################################
      ## DON'T EDIT BELLOW THIS LINE
      ## well, if you want to, you won't be busted ;-)
      ######################################################################################################
       
        // get the file we want to watermark
        $file                        = imagecreatefromjpeg($picturename);

        // get the image details and create an image
        $image_width                 = imagesx($file);
        $image_height                = imagesy($file);
        $image                       = $file;

      if (!preg_match("/thumb_/i","$picturename"))
      {

But this will not run on my server!

Here is my version:
Quote
      ######################################################################################################
      ## DON'T EDIT BELLOW THIS LINE
      ## well, if you want to, you won't be busted ;-)
      ######################################################################################################
       
        // get the file we want to watermark
        $file                        = imagecreatefromjpeg($_GET['picturename']);

        // get the image details and create an image
        $image_width                 = imagesx($file);
        $image_height                = imagesy($file);
        $image                       = $file;

      if (!preg_match("/thumb_/i", $_GET['picturename']))
      {

After this changes this hack works without any problems and instead of the X, I saw before, there is now my picture with the watermark! ;)

Hope it helps you!
Title: Re: Watermark on a per image basis
Post by: pgrzegorc on June 12, 2005, 05:36:02 pm
Can I used a few watermarks during to upload picturees to my gallery??
for example I have a few categories, a few albums, about 20 person can upload to my gallery and I want during uploding files add to pictures different watermark for different users but I should make it???

Pawel
Title: Re: Watermark on a per image basis
Post by: Summi on July 13, 2005, 03:59:00 pm
Hi,

this mod is working fine, but I've got a question:

while uploading single files, i always have to type "YES" into the user-uield 1.

Could it be possible, that "YES" is automatically the default input to this field ??  (-> with the batch function "yes" is insert automaitcally)

Thanx,
Summi
Title: Re: Watermark on a per image basis
Post by: Stramm on July 24, 2005, 09:04:58 am
Can I used a few watermarks during to upload picturees to my gallery??
for example I have a few categories, a few albums, about 20 person can upload to my gallery and I want during uploding files add to pictures different watermark for different users but I should make it???

Pawel

you still need a solution for this?? I think it's easy to do
Title: Re: Watermark on a per image basis
Post by: sigepjedi on September 19, 2005, 05:06:14 pm
anyone get this to work on 1.4 yet?
Title: Re: Watermark on a per image basis
Post by: Joachim Müller on September 19, 2005, 10:47:33 pm
why don't you try to find it out and post your results? How else should we know unless someone tries, especially since cpg1.4.x goes currently unsupported. Be a giver as well instead of being only a taker.
same thing on this thread.
Title: Re: Watermark on a per image basis
Post by: sigepjedi on September 25, 2005, 03:45:15 am
try to find it out and post your results?

if i had figured it out, i assure you i would have posted.
My how 1.4 has really brought down the moral around here....
Title: Re: Watermark on a per image basis
Post by: artistsinhawaii on September 25, 2005, 05:05:03 am

if i had figured it out, i assure you i would have posted.
My how 1.4 has really brought down the moral around here....

? I'm thinking just the opposite.  If anything it has got me excited and I sense the same excitement in those that are working hard to complete the new version.  I'm very eager for the release of a stable version.  So much so that in the two months that I have been a member here (which is as long as my experience with Coppermine, HTML, PHP, Java, and such) I have contributed 239 posts in the hopes that my efforts here will give the devs more time to work the kinks out of 1.4x.  My experiences in the 1.4x Bugs boards with the Devs have been very positive and enlightening to my knowledge and understanding of Coppermine and PHP.

If those in the know would help deal with many of the smaller issues on the boards, I'm convinced that 1.4x would be released much sooner. 

Just a newbie,

Dennis   
OOPS... make that 240 posts in two months...including 1-mod update, 1 mini-mod, and I've even applied Casper's paypal mod to my 1.4, though the last hasn't been posted as I am currently working on a different approach for a client-based paypal mod for both 1.3x and 1.4x rooted to my mini mod.   
Title: Re: Watermark on a per image basis
Post by: 300zxtc on October 14, 2005, 06:43:31 am
I only have a pre GD2 release. What can I do?
Title: Re: Watermark on a per image basis
Post by: Karri on February 02, 2006, 11:03:06 pm
I am not really a php guru and I haven't done anything with this hack in forever but i noticed http://forum.coppermine-gallery.net/index.php?topic=26858.0 which will do basically the same thing as mine with a few modifications and works in 1.4.3.  Do everything he says to do which will set it to watermark all images.  To set it to pick which images are on and off just change

Code: [Select]
if((($mode == "normal") || ($mode == 'fullsize')) && ($CONFIG['thumb_method']=='im')){
in his hack instructions to

Quote
if((($mode == "normal") || ($mode == 'fullsize')) && ($CONFIG['thumb_method']=='im') && ($pic_row['user1']=="YES")){

then from my original post

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

include/picmgmt.inc.php and change

Code: [Select]
function add_picture($aid, $filepath, $filename, $position = 0, $title = '', $caption = '', $keywords = '', $user1 = '', $user2 = '', $user3 = '', $user4 = '', $category = 0, $raw_ip = '', $hdr_ip = '', $iwidth = 0, $iheight = 0)
[code]

to

[code]function add_picture($aid, $filepath, $filename, $position = 0, $title = '', $caption = '', $keywords = '', $user1 = 'YES', $user2 = '', $user3 = '', $user4 = '', $category = 0, $raw_ip = '', $hdr_ip = '', $iwidth = 0, $iheight = 0)

The script looks for the  "YES" in the watermark field ($user1) so if you don't want the watermark to appear just remove the YES from that field.[/code][/code]
Title: Re: Watermark on a per image basis
Post by: Dirk on March 14, 2006, 09:53:08 am
I tried the mod and got the following message:
Notice: Undefined index: user1 in /mnt/be2/03/314/00000016/htdocs/fotoarchiv/include/functions.inc.php on line 1279


link to the gallery:
http://www.dirk-thoelking.de/fotoarchiv/ (http://www.dirk-thoelking.de/fotoarchiv/)


This is line 1279:
if ($pic_row['user1']!="YES") {


Where did i go wrong? Is ist a problem if have the install die following mod too?
http://forum.coppermine-gallery.net/index.php?topic=3269.0 (http://forum.coppermine-gallery.net/index.php?topic=3269.0)


Many thanks!
Title: Re: Watermark on a per image basis
Post by: Joachim Müller on March 15, 2006, 06:56:46 am
disable notices if they don't mean anything to you.
Title: Re: Watermark on a per image basis
Post by: cryogen on March 15, 2006, 09:16:26 pm
Hi!

How can I place a watermark into thumbnails in Album listing using that hack?

Thanks
Title: Re: Watermark on a per image basis
Post by: thecave on May 29, 2006, 08:37:31 pm
Hey, works great. I'm still testing this out.
I noticed when I right-click the image in all sizes that the file save info says "logo.php". Is there anyway on the back-end to configure this prob so when you right-click and save the image it can show the actual filename or maybe even a custom file save name? Thanks.

Here's a watermark image in my gallery that I'm talking about.
http://www.z28cave.com/membergallery/displayimage.php?album=lastup&cat=10&pos=0 (http://www.z28cave.com/membergallery/displayimage.php?album=lastup&cat=10&pos=0)
Try saving the image and you'll see what I'm talking about.

I do not know php so that's why I ask for help, thanks.

:)
Title: Re: Watermark on a per image basis
Post by: elizabethh on February 10, 2007, 05:40:48 pm
hi, i am a new user to coppermine. i have done all these; what next? how can i turn on watermarking on the pictures?
Title: Re: Watermark on a per image basis
Post by: Victoryfan on March 16, 2007, 11:36:34 pm
Code: [Select]
        return $url_prefix[$pic_row['url_prefix']]. path2url($pic_row['filepath']. $pic_prefix[$mode]. $pic_row['filename']);
Can't find it! In what line is it?
Title: Re: Watermark on a per image basis
Post by: Nibbler on March 17, 2007, 12:20:37 am
Look for the get_pic_url function.
Title: Re: Watermark on a per image basis
Post by: Victoryfan on March 17, 2007, 12:25:16 am
Thank you sooo much!  :D