Advanced search  

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]

Pages: 1 2 3 4 [5] 6 7 8 9 10   Go Down

Author Topic: Permanent Watermark with GD2  (Read 197634 times)

0 Members and 1 Guest are viewing this topic.

Hein Traag

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: nl
  • Offline Offline
  • Gender: Male
  • Posts: 2166
  • A, B, Cpg
    • Personal website - Spintires.nl
Re: Permanent Watermark with GD2
« Reply #80 on: December 24, 2004, 08:21:52 pm »

Right i applied all code changes, without wrecking the cpg (hooray for me) and now i wanted to apply the watermarking to
some albums as per test.

Went to Admin Tools and selected Add Watermarking, choosing both resized and original pictures.
Selected the album to apply the watermarking to and hit Submit. After some thinking on the serverside is displays a page which says all pics were update succesfully.

All ok so far.

Except for one thing. I don't see the watermarking appear on any of the pictures. I tried setting the intermediate picture size to a lower size, following the advice Sammy gave but with no result. The path to the images is in order, goes from /public_html/ all the way to logo.png so that should not be the problem.

Anybody got an idea where i might look for the answer ?

Thanks
Hein
Logged

TranzNDance

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Female
  • Posts: 6148
    • Take Thu! Gallery
Re: Permanent Watermark with GD2
« Reply #81 on: December 24, 2004, 08:23:05 pm »

Did you go through the error logs to make sure that the file path is interpreted correctly?
Logged

Hein Traag

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: nl
  • Offline Offline
  • Gender: Male
  • Posts: 2166
  • A, B, Cpg
    • Personal website - Spintires.nl
Re: Permanent Watermark with GD2
« Reply #82 on: December 24, 2004, 08:35:46 pm »

*removed debug list

If i read the whole thread correctly this should also work on pics that were already uploaded.

Has to be something to do with the path to logo.png

In a nutshell: Admin Tools - Add Watermarking (choose resized and normal) - choose album - hit Submit
That should add watermarking to a album that already was in the gallery right ?
Assuming the path to the images was correct in both config and mysql.

Tried it by uploading a picture thru upload.php.. again no result.

Past my bedtime and lack of coffee.. If someone can point me in the right direction its appreciated. For now it's bye bye  ;)
« Last Edit: December 24, 2004, 09:28:29 pm by Hein »
Logged

TranzNDance

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Female
  • Posts: 6148
    • Take Thu! Gallery
Re: Permanent Watermark with GD2
« Reply #83 on: December 24, 2004, 11:02:37 pm »

It should work on existing photos.

(This is when it is difficult to help people with different webhosts. )

For example, my full path to the .png is:
/home/username/public_html/galleryname/blahblah

If you're unsure of the absolute path, you should ask your host.
Logged

Hein Traag

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: nl
  • Offline Offline
  • Gender: Male
  • Posts: 2166
  • A, B, Cpg
    • Personal website - Spintires.nl
Re: Permanent Watermark with GD2
« Reply #84 on: December 25, 2004, 10:57:35 am »

Thanks TranzNDance that did it. Forgot to type full path  :o.

I did find a other option to add watermarking to pictures. I did some testing with WebDrive (http://www.webdrive.com/) which connects a ftp folder as a normal folder under Windows.
And then I used FastStone resizer/renamer to add watermarking. One drawback to some maybe that you need a decent internet connection.

Thanks for the help!
Logged

peezy

  • Coppermine newbie
  • Offline Offline
  • Posts: 3
Re: Permanent Watermark with GD2
« Reply #85 on: January 02, 2005, 07:06:14 am »

Ok, i've tried to re-install this mod like 5 times from scratch and have been working on it for a while and keep getting an error.

Code: [Select]
Warning: imagecreatefrompng(/your/full/path/to/logo.png): failed to open stream: No such file or directory in /home/club303/public_html/fp-photo/include/picmgmt.inc.php on line 303

Warning: imagesx(): supplied argument is not a valid Image resource in /home/club303/public_html/fp-photo/include/picmgmt.inc.php on line 304

Warning: imagesy(): supplied argument is not a valid Image resource in /home/club303/public_html/fp-photo/include/picmgmt.inc.php on line 305

Warning: imagecopy(): supplied argument is not a valid Image resource in /home/club303/public_html/fp-photo/include/picmgmt.inc.php on line 325
albums/userpics/10001/photocart.jpg updated succesfully!

Can anybody help me? anyone know where this problem might be?
Logged

TranzNDance

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Female
  • Posts: 6148
    • Take Thu! Gallery
Re: Permanent Watermark with GD2
« Reply #86 on: January 02, 2005, 07:13:01 am »

In Config, did you put the full path to the watermark file?

If this was in the actual error message (and you hadn't edited it when posting), then it is incorrect:
/your/full/path/to/logo.png

You can get the full path info in the rest of the error message which shows where the files are located.
Logged

peezy

  • Coppermine newbie
  • Offline Offline
  • Posts: 3
Re: Permanent Watermark with GD2
« Reply #87 on: January 02, 2005, 07:22:28 am »

nope, that didn't work either now it says

Code: [Select]
Watermarking images...

Warning: imagecreatefrompng(/home/club303/public_html/fp/watermark.png): failed to open stream: No such file or directory in /home/club303/public_html/fp-photo/include/picmgmt.inc.php on line 303

Warning: imagesx(): supplied argument is not a valid Image resource in /home/club303/public_html/fp-photo/include/picmgmt.inc.php on line 304

Warning: imagesy(): supplied argument is not a valid Image resource in /home/club303/public_html/fp-photo/include/picmgmt.inc.php on line 305

Warning: imagecopy(): supplied argument is not a valid Image resource in /home/club303/public_html/fp-photo/include/picmgmt.inc.php on line 325
albums/userpics/10001/photocart.jpg updated succesfully!

it says that for each picture in the album
Logged

TranzNDance

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Female
  • Posts: 6148
    • Take Thu! Gallery
Re: Permanent Watermark with GD2
« Reply #88 on: January 02, 2005, 07:25:36 am »

Is this correct:
/home/club303/public_html/fp/watermark.png

The rest of the error message say your files are in
/home/club303/public_html/fp-photo/

If you try to access the watermark file via browser, does it work? So you should be able to see it http://yourdomain.tld/fp/watermark.png if
/home/club303/public_html/fp/watermark.png
is correct.
Logged

peezy

  • Coppermine newbie
  • Offline Offline
  • Posts: 3
Re: Permanent Watermark with GD2
« Reply #89 on: January 02, 2005, 07:38:12 am »

aww man.... the file was kinda right, i didn't realize photoshop saved it watermark.PNG not watermark.png 

i hate it when it's case sensative!

Thanks for the help!
Logged

RGSMDNR

  • Coppermine newbie
  • Offline Offline
  • Posts: 2
Re: Permanent Watermark with GD2
« Reply #90 on: January 06, 2005, 05:28:20 am »

im getting this error...

Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 2412 bytes) in /home/virtual/site430/fst/var/www/html/coppermine/include/picmgmt.inc.php on line 226

it worked once (kinda, the watermark was fuzzy) but now i get that..

thoughts?
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47844
  • aka "GauGau"
    • gaugau.de
Logged

RGSMDNR

  • Coppermine newbie
  • Offline Offline
  • Posts: 2
Re: Permanent Watermark with GD2
« Reply #92 on: January 07, 2005, 05:05:41 pm »

ok, well it looks like ill have to live with it for now and get my users to upload non hi res pics.

now where in the code does it say how big the watermark image can be? is there a limit?

also on smaller pics, will it resize the watermark to fit?
Logged

partypics

  • Contributor
  • Coppermine novice
  • ***
  • Offline Offline
  • Posts: 24
Re: Permanent Watermark with GD2
« Reply #93 on: January 09, 2005, 04:51:25 pm »

Hello!
I used this mod and added an ability to choose between image watermark and a simple text watermark.
Text watermark may contain username and look like that, for example www.somesite.com/username/

This instruction is only valid if you have applied this mod before (cause it's not the full instruction).
In your lang file add this to Watermark section:

Code: [Select]
  array('Use text watermark instead of image', 'watermark_use_text', 1),
  array('Text to use for a watermark', 'watermark_text_pattern', 0),
  array('Watermark text color (r,g,b)', 'watermark_text_color', 0),
  array('Watermark text font size (points)', 'watermark_text_size', 0),

run this in phpMyAdmin or similar:

Code: [Select]
INSERT INTO `cpg132_config` VALUES ('watermark_text_pattern', 'test string');
INSERT INTO `cpg132_config` VALUES ('watermark_use_text', '0');
INSERT INTO `cpg132_config` VALUES ('watermark_text_color', '255,255,255');
INSERT INTO `cpg132_config` VALUES ('watermark_text_size', '10');

edit picmgmt.php , find
Code: [Select]
function watermark($src_file)and replace the whole function (not just that line) with this:

Code: [Select]
function watermark($src_file) {

global $CONFIG, $ERROR, $USER_DATA;
global $lang_errors;

$imginfo = getimagesize($src_file);
if ($imginfo == null)
    return false;
// GD can only handle JPG & PNG images
if ($imginfo[2] != GIS_JPG && $imginfo[2] != GIS_PNG)
{
$ERROR = $lang_errors['gd_file_type_err'];
return false;
}
// height/width
$srcWidth = $imginfo[0];
$srcHeight = $imginfo[1];

$destWidth = $srcWidth; //(int)($srcWidth / $ratio);
$destHeight = $srcHeight; //(int)($srcHeight / $ratio);

$dest_file = $src_file;

if (!function_exists('imagecreatefromjpeg'))
{
cpg_die(CRITICAL_ERROR, 'PHP running on your server does not support the GD image library, check with your webhost if ImageMagick is installed', __FILE__, __LINE__);
}
if (!function_exists('imagecreatetruecolor')) {
cpg_die(CRITICAL_ERROR, 'PHP running on your server does not support GD version 2.x, please switch to GD version 1.x on the config page', __FILE__, __LINE__);
}
if ($imginfo[2] == GIS_JPG)
$src_img = imagecreatefromjpeg($src_file);
else
$src_img = imagecreatefrompng($src_file);
if (!$src_img)
{
$ERROR = $lang_errors['invalid_image'];
return false;
}
$dst_img = imagecreatetruecolor($destWidth, $destHeight);
/*$dst_img =*/   ImageAlphaBlending($dst_img, true) or die ("Could not alpha blend"); // Enable when on GD 2+
imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $destWidth, (int)$destHeight, $srcWidth, $srcHeight);

//where is the watermark displayed...
$pos = $CONFIG['where_put_watermark'];
if (!$CONFIG['watermark_use_text'])  // if we are using image as a watermark
{
$logoImage = ImageCreateFromPNG($CONFIG['watermark_file']);
$logoW = ImageSX($logoImage);
$logoH = ImageSY($logoImage);

if ($pos == "topleft")
{
$src_x = 5;
$src_y = 5;
}
else if ($pos == "topright")
{
$src_x = $srcWidth - ($logoW + 5);
$src_y = 5;
}
else if ($pos == "bottomleft")
{
$src_x = 5;
$src_y = $srcHeight - ($logoH + 5);
}
    else if ($pos == "bottomright")
{
$src_x = $srcWidth - ($logoW + 5);
$src_y = $srcHeight - ($logoH + 5);
}

ImageCopy($dst_img,$logoImage,$src_x,$src_y,0,0,$logoW,$logoH); //$dst_x,$dst_y,0,0,$logoW,$logoH);
}
else // using text as watermark
{
if ($pos == "topleft")
{
$src_x = 5;
$src_y = 10;
}
else if ($pos == "topright")
{
$src_x = $srcWidth - 100;
$src_y = 10;
}
else if ($pos == "bottomleft")
{
$src_x = 5;
$src_y = $srcHeight - 5;
}
    else if ($pos == "bottomright")
{
$src_x = $srcWidth - 100;
$src_y = $srcHeight - 5;
}


$color_arr = explode(',',$CONFIG['watermark_text_color']);
$color = imagecolorallocate($dst_img, $color_arr[0], $color_arr[1], $color_arr[2]);
$wat_text = eval("return (\"$CONFIG[watermark_text_pattern]\");");
imagettftext($dst_img,$CONFIG['watermark_text_size'],0,$src_x,$src_y,$color,'path/to/your/font/arial.ttf', $wat_text) or die ('Error - could not add a text watermark!');

}

         
imagejpeg($dst_img, $src_file, $CONFIG['jpeg_qual']);
imagedestroy($src_img);
imagedestroy($dst_img);

// Set mode of uploaded picture
// We check that the image is valid
$imginfo = getimagesize($src_file);
if ($imginfo == null)
{
$ERROR = $lang_errors['resize_failed'];
@unlink($src_file);
return false;
}
else
{
return true;
}

}

Where "path/to/your/font/" is an absolute path to .ttf file on your server.
Now go to the config page and switch the option "use text watermark instead of image".

With this modification you are able to use such string in the "watermark text" field
Code: [Select]
www.$_SERVER[HTTP_HOST]/$USER_DATA[user_name]/and the watermark text will be something like
Code: [Select]
www.somesite.com/username/
where username is the name of the pic's uploader. You can use other global variables as well.
It may be not safe, because it uses eval() function, so, don't use it if you are not the only one admin of the gallery.
To avoid eval() the string can be hardcoded to the script, or you can delete eval()  if you are not going to use variables in your watermark.
If you place text watermark on the right side of an image - correct the line
Code: [Select]
else if ($pos == "topright")
{
$src_x = $srcWidth - 100;
$src_y = 10;
}

and change 100 to your suitable number, depending of your text length (and font size). But it's more convenient to place  variable-length text watermark on the left side of an image.
Again - it uses eval() and has no validation of values you enter in config page - use it at your own risk (or modify to be more safe  ;) )

Hope I didn't forget anything!

PS: found a typo(?) - in original code "topleft" is called "topleftt" (double "t") in lang and config files..
« Last Edit: January 10, 2005, 04:35:52 pm by partypics »
Logged

gab696

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 25
Re: Permanent Watermark with GD2
« Reply #94 on: January 19, 2005, 10:41:00 pm »

I have tried to install this Hack but when i try to change the watermarking in the config pannel.
The changes are not saved.  ???
I'am not sure to have correctly inserted the 4 lines in my base and the config.php (i'am a newbie  :-\\ )

Logged

partypics

  • Contributor
  • Coppermine novice
  • ***
  • Offline Offline
  • Posts: 24
Re: Permanent Watermark with GD2
« Reply #95 on: January 19, 2005, 10:53:16 pm »

This will work only if you have correctly applied the first part - image watermark. Try phpMyAdmin to insert sql statements.
Logged

biootik

  • Coppermine newbie
  • Offline Offline
  • Posts: 1
Re: Permanent Watermark with GD2
« Reply #96 on: January 21, 2005, 12:12:21 am »

hi all !

i've just installed "permanent Watermaking" on my 1.3.0 coppermine site ..

it works well by upload and by the util page too , but only on resized pics, on original pics it doesn't work at all .
well, it says that pics have been watermarked , but they are not.

any of u got this matter ?  ??? ??? ???

ps:i supposed it was my code copy which was bad  , but i've checked 3 times the code , and i did it well .

tks for answering..

bioo
Logged

romans815

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 26
Re: Permanent Watermark with GD2
« Reply #97 on: February 12, 2005, 03:01:45 am »

Am looking for any and all advise. I added everything and get this:

>>>>>>>>>>>>>>>>>>>>>>>>IN THE UPLOAD AND ASSIGN TO ALBUM SECTION

Warning: imagecreatefrompng(home/champ1/public_html/gallery/images/watermark.png): failed to open stream: No such file or directory in /home/champ1/public_html/gallery/include/picmgmt.inc.php on line 304

Warning: imagesx(): supplied argument is not a valid Image resource in /home/champ1/public_html/gallery/include/picmgmt.inc.php on line 305

Warning: imagesy(): supplied argument is not a valid Image resource in /home/champ1/public_html/gallery/include/picmgmt.inc.php on line 306

Warning: imagecopy(): supplied argument is not a valid Image resource in /home/champ1/public_html/gallery/include/picmgmt.inc.php on line 323

Warning: imagecreatefrompng(home/champ1/public_html/gallery/images/watermark.png): failed to open stream: No such file or directory in /home/champ1/public_html/gallery/include/picmgmt.inc.php on line 304

Warning: imagesx(): supplied argument is not a valid Image resource in /home/champ1/public_html/gallery/include/picmgmt.inc.php on line 305

Warning: imagesy(): supplied argument is not a valid Image resource in /home/champ1/public_html/gallery/include/picmgmt.inc.php on line 306

Warning: imagecopy(): supplied argument is not a valid Image resource in /home/champ1/public_html/gallery/include/picmgmt.inc.php on line 323


>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>IN THE ADMIN SECTION

Watermarking images...

Warning: imagecreatefrompng(home/champ1/public_html/gallery/images/watermark.png): failed to open stream: No such file or directory in /home/champ1/public_html/gallery/include/picmgmt.inc.php on line 304

Warning: imagesx(): supplied argument is not a valid Image resource in /home/champ1/public_html/gallery/include/picmgmt.inc.php on line 305

Warning: imagesy(): supplied argument is not a valid Image resource in /home/champ1/public_html/gallery/include/picmgmt.inc.php on line 306

Warning: imagecopy(): supplied argument is not a valid Image resource in /home/champ1/public_html/gallery/include/picmgmt.inc.php on line 323
albums/userpics/10001/normal_DSC00988.jpg updated succesfully!
Logged

PBas

  • Coppermine newbie
  • Offline Offline
  • Posts: 13
Re: Permanent Watermark with GD2
« Reply #98 on: February 16, 2005, 10:59:36 pm »

Well.... i've aplied the watermarking mod and it works perfectly. (had one error ... path ... but that was my problem, not the MOD)

The question:
Is it possible to have a smaller watermark pic for normal size pics? or working with %... i don't know.


Thanks!

(coppermine gallery since v1.2 - 1 year long - now updated to 1.3.2)
Logged

bibendum

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 51
Re: Permanent Watermark with GD2
« Reply #99 on: February 19, 2005, 09:06:36 pm »

Hi

Thanks for this wonderfull mod.

Is it possible to select wich pictures you want to apply Watermark with admin/utils ?

Because some of my pictures are copyrighted by their owrners and i don't want to apply my copyright !!!!

Even with pictures to be validated by admin, select yes/no to apply Watermark.

Thanks a lot



Logged
Pages: 1 2 3 4 [5] 6 7 8 9 10   Go Up
 

Page created in 0.025 seconds with 21 queries.