Advanced search  

News:

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

Pages: 1 2 [3] 4   Go Down

Author Topic: Watermark on a per image basis  (Read 176486 times)

0 Members and 1 Guest are viewing this topic.

Spiderm@n(tm)

  • Coppermine newbie
  • Offline Offline
  • Gender: Male
  • Posts: 6
Re: Watermark on a per image basis
« Reply #40 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.
« Last Edit: June 18, 2004, 02:59:51 pm by Spiderm@n(tm) »
Logged
(http://www.danasoft.com/sig/Feredzhanov.jpg)

Karri

  • Contributor
  • Coppermine novice
  • ***
  • Offline Offline
  • Gender: Female
  • Posts: 44
    • The Fuselage
Re: Watermark on a per image basis
« Reply #41 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
Logged
Thanks,
Karri

Spiderm@n(tm)

  • Coppermine newbie
  • Offline Offline
  • Gender: Male
  • Posts: 6
Re: Watermark on a per image basis
« Reply #42 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
Logged
(http://www.danasoft.com/sig/Feredzhanov.jpg)

skybax

  • VIP
  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 180
    • SKYBAX Communications
Re: Watermark on a per image basis
« Reply #43 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?
Logged
(http://www.skybax.com/hotImage/post_footer.gif)
Don't contact me for support over PM or email unless I requested you to do so. Instead: post on the proper board.

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: Watermark on a per image basis
« Reply #44 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
Logged

PCGUY112887

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 52
Re: Watermark on a per image basis
« Reply #45 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?
Logged

skybax

  • VIP
  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 180
    • SKYBAX Communications
Re: Watermark on a per image basis
« Reply #46 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)
Logged
(http://www.skybax.com/hotImage/post_footer.gif)
Don't contact me for support over PM or email unless I requested you to do so. Instead: post on the proper board.

PCGUY112887

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 52
Re: Watermark on a per image basis
« Reply #47 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?
Logged

skybax

  • VIP
  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 180
    • SKYBAX Communications
Re: Watermark on a per image basis
« Reply #48 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. 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)
Logged
(http://www.skybax.com/hotImage/post_footer.gif)
Don't contact me for support over PM or email unless I requested you to do so. Instead: post on the proper board.

Nekto63

  • Coppermine newbie
  • Offline Offline
  • Posts: 1
Re: Watermark on a per image basis
« Reply #49 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?
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: Watermark on a per image basis
« Reply #50 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
Logged

Thursday

  • Coppermine newbie
  • Offline Offline
  • Posts: 1
Re: Watermark on a per image basis
« Reply #51 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?
Logged

davidshook

  • Coppermine newbie
  • Offline Offline
  • Posts: 14
Re: Watermark on a per image basis
« Reply #52 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
Logged

Nibbler

  • Guest
Re: Watermark on a per image basis
« Reply #53 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.
Logged

nukeworker

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Gender: Male
  • Posts: 83
  • Visit NukeWorker.com
    • Nuclear Jobs
Re: Watermark on a per image basis
« Reply #54 on: March 02, 2005, 01:33:35 pm »

[edit]deleted question, found answer[/edit]

trued

  • Coppermine newbie
  • Offline Offline
  • Posts: 10
Re: Watermark on a per image basis
« Reply #55 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!

Logged

fedexx

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 25
Re: Watermark on a per image basis
« Reply #56 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);


}

Logged

seboter

  • Coppermine newbie
  • Offline Offline
  • Gender: Male
  • Posts: 8
Re: Watermark on a per image basis
« Reply #57 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!
Logged
<a href="http://www.4edged.com" target="_blank">sebotronik image database</a>

pgrzegorc

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 45
Re: Watermark on a per image basis
« Reply #58 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
Logged

Summi

  • Coppermine newbie
  • Offline Offline
  • Posts: 15
Re: Watermark on a per image basis
« Reply #59 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
Logged
Pages: 1 2 [3] 4   Go Up
 

Page created in 0.037 seconds with 20 queries.