Hi there,
I always used the watermarking hack from flex: http://forum.coppermine-gallery.net/index.php?topic=1467.0
Thank you flex for this hack!
This one did not work in coppermine version 1.4.3 anymore.
I looked through the code and I found the place where you should place the modifications. So here is the posting again with the modifications for 1.4.3
Step 1. includes/functions.inc.php
Find this line in the script:
(line 1985)
$filepathname = $url_prefix[$pic_row['url_prefix']]. path2url($pic_row['filepath']. $pic_prefix[$mode]. $pic_row['filename']);
And change it to this:
if((($mode == "normal") || ($mode == 'fullsize')) && ($CONFIG['thumb_method']=='im')){
// return the url to the wm script
$filepathname = "wm.php?pid=".$pic_row["pid"]."&mode=".$mode;
}else{
// it's a thumb, don't bother wm'ing
$filepathname = $url_prefix[$pic_row['url_prefix']]. path2url($pic_row['filepath']. $pic_prefix[$mode]. $pic_row['filename']);
}
Step 2. Create a new file in the coppermine root dir called wm.php:
<?
define('IN_COPPERMINE', true);
require('include/init.inc.php');
header('Content-Type: image/jpeg');
header('Content-Disposition: inline; filename=file.jpg');
$pid = $_REQUEST["pid"];
$mode = $_REQUEST["mode"];
$sql = "SELECT * FROM ".$CONFIG['TABLE_PREFIX']."pictures WHERE pid=$pid";
$db = mysql_connect($CONFIG['dbserver'], $CONFIG['dbuser'], $CONFIG['dbpass']);
mysql_select_db($CONFIG['dbname'], $db);
$result = mysql_query($sql, $db);
$row = mysql_fetch_array($result);
$pic_prefix = array(
'thumb' => $CONFIG['thumb_pfx'],
'normal' => $CONFIG['normal_pfx'],
'fullsize' => ''
);
$cmd = "{$CONFIG['impath']}composite -compose over -gravity SouthEast \"".realpath("./watermark.png")."\" \"".realpath('./'.$CONFIG["fullpath"].$row["filepath"].$pic_prefix[$mode].$row["filename"])."\" jpg:-";
passthru ($cmd, $output);
echo $output;
?>
Make sure you watch those line breaks when copying & pasting as it seems to have broken up some of them cos of page width etc.
Step 3. Get a copy of watermark.png
Get mine (or actually my girlfriend her watermark) from here:
http://www.vankalken.net/gallery/watermark.png
Remember to edit it first ;)
And put it in your root coppermine directory.
Remember I'm not a PHP programmer, I can read the code, but not create new code :P
Regards,
Emiel from the Netherlands
http://www.vankalken.net/gallery
Good Job, I used this on 1.3 and this works just as great.
Another useful and simple modification would be to have different watermarks for the intermediate and full sized pictures.
To do this simply change the functions.inc.php code to as follows:
if(($mode == "fullsize") && ($CONFIG['thumb_method']=='im')){
// return the url to the wm script
$filepathname = "wm.php?pid=".$pic_row["pid"]."&mode=".$mode;
}else if((($mode == "normal")) && ($CONFIG['thumb_method']=='im')){
// return the url to the wm script
$filepathname = "wm2.php?pid=".$pic_row["pid"]."&mode=".$mode;
}else{
// it's a thumb, don't bother wm'ing
$filepathname = $url_prefix[$pic_row['url_prefix']]. path2url($pic_row['filepath']. $pic_prefix[$mode]. $pic_row['filename']);
}
Then copy wm.php to wm2.php and change the filename of the png in wm2.php. And that's about it for my elite coding skills...
Hi all,
I found that while the MOD works awesome for images, it locks up video and audio from playing.
I've further modified the code. It excludes non-images from being unnecessarily watermarked.
if(($mode == "fullsize") && ($CONFIG['thumb_method']=='im') && ($mime_content['content'] == 'image' )){
// return the url to the wm script
$filepathname = "wm.php?pid=".$pic_row["pid"]."&mode=".$mode;
}else if((($mode == "normal")) && ($CONFIG['thumb_method']=='im') && ($mime_content['content'] == 'image')){
// return the url to the wm script
$filepathname = "wm2.php?pid=".$pic_row["pid"]."&mode=".$mode;
}else{
// it's a thumb, don't bother wm'ing
$filepathname = $url_prefix[$pic_row['url_prefix']]. path2url($pic_row['filepath']. $pic_prefix[$mode]. $pic_row['filename']);
}
well i tryed emielk step-by-step ... and watermark isnt showing... i even for test tryed to use his and notnig :< where did i go wrong :<
impossible to say without being able to look at your changes and not even a link to your site ::). Do you actually have ImageMagick? Did you try the (more popular) watermarking mod posted by Stramm (http://forum.coppermine-gallery.net/index.php?topic=29817.0)?
Will this work with 1.4.6?
It's marked 1.4.x, x meaning any number.
wm.php sets the image's filename to "file.jpg".
Is there any way to change this so that the original file name comes up when a user tries to save the image?
regards,
zenith.
Worked it out.
had to move the header section further down to after where $row is set. Then replace "file.jpg" with the variable $row["filename"].
Code now looks like this:
<?
define('IN_COPPERMINE', true);
require('include/init.inc.php');
$pid = $_REQUEST["pid"];
$mode = $_REQUEST["mode"];
$sql = "SELECT * FROM ".$CONFIG['TABLE_PREFIX']."pictures WHERE pid=$pid";
$db = mysql_connect($CONFIG['dbserver'], $CONFIG['dbuser'], $CONFIG['dbpass']);
mysql_select_db($CONFIG['dbname'], $db);
$result = mysql_query($sql, $db);
$row = mysql_fetch_array($result);
$pic_prefix = array(
'thumb' => $CONFIG['thumb_pfx'],
'normal' => $CONFIG['normal_pfx'],
'fullsize' => ''
);
header('Content-Type: image/jpeg');
header("Content-Disposition: inline; filename=".($row["filename"]).";");
$cmd = "{$CONFIG['impath']}composite -compose over -gravity SouthEast \"".realpath("./watermark.png")."\" \"".realpath('./'.$CONFIG
["fullpath"].$row["filepath"].$pic_prefix[$mode].$row["filename"])."\" jpg:-";
passthru ($cmd, $output);
echo $output;
?>
Hope it helps someone.
Zenith.
Quote".realpath("./watermark.png")
is that where I place thecomplete path to the watermark? anywhere else?
Anyone try this in 1.4.9? It seems to me that this is the only on-the-fly mod without touching the files. All other hacks modify the source.
Hi,
I am new here and would like to ask the experts: do I need ImageMagick for watermark the uploaded images? Is it possible to watermark the images something else?
Thanks ;)
this mod requires ImageMagick as you can read in the topics subject
Thankyou very much emielk.
I couldn't get Flex's original MOD to work because I think includes/functions.inc.php is quite different in later versions. i.e. the line that needs to be ammended is not at the end of the script.
So I can confirm that your version of this Watermark MOD works perfectly with:
Coppermine version 1.4.10.
ImageMagick-6.2.5.4
php-5.1.4-1
mysql-5.0.18-2.1
on Fedora Core 5
Thanks very much, Ben.
I love this mod...its cool and simple I have A problem though.
It only works with image magic.....
is there a way to get it to work with GD version 1 or 2??
When I have Image magic turned on it wont let me upload so I have to use GD.....
Please help!!
Ive been up for 16 hours triing to get this up and running smoothly.:o :o
Thanks!! ;D ;D
Im using coppermine 1.4.10 ..........and this is whats going on..... does anyone have a fix for it?
I can only upload images with images with GD, and with image magic it wont let me upload.....
is there a way to get this mod to work with GD version 1 or 2??
or is there a way I can upload using image magic.
this is the only mod I'm running....I don't know whats wrong?
can anyone help??
Either get imagemagick installed or rewrite the mod for GD2.
I have image magic installed......when I have it turned on and I try to upload a file I get this message....
The previous file could not be placed. You have successfully placed all the files. (so it wont let me upload).
It did work for a while but then started doing that..... while it was working the watermark mod worked great.
So I turn on GD version 1 or 2 in config so I could upload again(now I can upload without any probs)...but now the watermark mod doesnt work.....arrrrrg pulling my hair out!!!
can anyone help???
Im running version 1.4.10
Post on the upload troubleshooting board after reading the upload troubleshooting guide.
Hey.. im thinking of whis program to edit the .png in??
if i try edit it in paint the text is only a black line...
Thx.
Sry for my bad english..
Sebastian
(denmark)
Any desktop app capable of handling PNGs is fine. This thread doesn't cover desktop app support. You could try Paint.NET (http://www.getpaint.net/) for a start. Please do not clutter this thread with desktop app related questions nor remarks.
hmm... I love this mod.. but i found out that i got som problems with activ .gif images..
http://de2dumme.dk/galleri/displayimage.php?album=41&pos=0
how can i doo somthing about that???
You're probably refering to animated GIFs - see my reply http://forum.coppermine-gallery.net/index.php?topic=42473.msg201605#msg201605
Not related to this mod.
yes and no... i got som problems with the animated gif in FF yes...
but the wathermark kills all my animated gif in both FF and IE if you see my link
http://de2dumme.dk/galleri/displayimage.php?pos=-80
you vill see that the aniation doo not work and the wathermark make so of the pic black...
is there any way to ake the script not wathermark the gif images???
but thx for the thumb info
I have a problem with this mod:
when I use original version functions.inc.php I have not problem when try save file. Filname is ok. But when I changed to moded functions.inc.php file, then when I try save file in IE7, then I get Untitled.bmp filename. Why?
Stop spreading your issue over various threads! You already have asked this in a separate thread.