forum.coppermine-gallery.net

No Support => Modifications/Add-Ons/Hacks => Mods: Watermarking & image manipulation => Topic started by: flex on November 10, 2003, 11:50:10 pm

Title: Watermarking hack (w/ ImageMagick)
Post by: flex on November 10, 2003, 11:50:10 pm
Hi there,

I just knocked up a quick hack to use water marking for coppermine. Check it out here: http://www.jvcam.co.uk/coppermine/

It doesn't alter any image on the server, just overlays the image every time a fullsize or normal image is requested (on-the-fly). It uses the 'composite' function of imagemagick but i think you can use a few of the others too to do the same thing. I'm no imagemagick expert.

The watermark image itself is a PNG file created in photoshop with alpha-layer transparency, you can find the one i use here: http://www.jvcam.co.uk/coppermine/watermark.png

If anyone's interested in the code, I'll try tidy it up and make it work for other people too.

I'm guessing that configuration could be put into coppermine to specify where the watermark is placed etc.

Before I tidy up the code, the imagemagick command I use is:

Code: [Select]
composite -compose over -gravity Southeast '".realpath("./watermark.png")."' '/home/users/jonny/www.jvcam.co.uk/html/coppermine/albums/$p' jpg:-

Obviously that's somewhat specific to my server cos I've not used any of the config includes from coppermine yet.

Anyways, enjoy :)

[edit]
It uses the full path of the image to pass to wm.php to get the image, but really this should use the db pid of the picture else it's not exactly secure.. but this is just a quick hack, i'll change it before i post the code ;)
[/edit]
Title: Re: Watermarking hack
Post by: moorey on November 11, 2003, 02:33:00 am
Quote from: "flex"

If anyone's interested in the code, I'll try tidy it up and make it work for other people too.


That would be great! Excellent work.
Title: Watermarking hack (w/ ImageMagick)
Post by: DefenceTalk.com on November 11, 2003, 04:10:02 am
Who isn't interested in watermarking tool? I am!! I tried this another php based watermark tool... but i couldn't make it work!  :cry:

Only works with imagemagic???
Title: Watermarking hack (w/ ImageMagick)
Post by: flex on November 11, 2003, 12:59:05 pm
ok here it is, it'll probably need some fixes. I've listed the known issues at the bottom:


Step 1. includes/functions.inc.php

Find this line right at the bottom of the script:
Code: [Select]

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


And change it to this:

Code: [Select]

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

                // return the url to the wm script
                return "wm.php?pid=".$pic_row["pid"]."&mode=".$mode;

        }else{
                // it's a thumb, don't bother wm'ing
                return $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:

Code: [Select]
<?
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 my one from here:
http://www.jvcam.co.uk/coppermine/watermark.png

And put it in your root coppermine directory.

Known Issues
1. Images stored on other servers, I've not even looked at how coppermine handles this but I know it does from looking at the code, but this doesn't support that and I'm not sure it would be possible for imagemagick to do it anyway with remote images.. Thinking it would take some php code to retrieve the image, wm it and then display it - I guess it's possible.

2. GD. GD implementation I've not even looked at yet, I don't know if it's possible but I'll try have a look in the next couple of days and see if it's possible. That said, if you're using GD, then it shouldn't effect the way you use coppermine, it just won't watermark the images.

3. At present there's no way to turn it on or off through the config screen, this is something the other dev's can do easily I'm sure, I didn't get stuck into the config stuff. The only way you can turn it off is to remove the altered script lines. Also, it watermarks both 'normal' and 'fullsize' images, there's no option to turn either one on/off yet.

4. Versions. It should work in anything greater than coppermine 1.1, since that's what I tested it with and I checked the 1.2 code and there's no changes in the lines I altered.

5. I'll try and produce a tutorial in creating the watermark images because it's not exactly straight forward and it has to be a png file. I couldn't get transparent gifs to work at all.

6. Server load. I've no idea how much server load it takes to wm an image every time it's requested as I don't have full access to the server I work on... Anyone who does have access and can check, I'd be interested to see how much load it creates.

I corrected it so that it doesn't pass the full url to the wm.php script, it now uses the pid of the image to find it and look it up in the db. This should somewhat stop people from stealing your images by finding the full path but it's not infallable.

I'm sure there's a few other issues too that I'm not aware of so I encourage people to try it out and see what happens and report back to this thread.

Last note, the wm image I use is this one http://www.jvcam.co.uk/coppermine/watermark.png
Those with photoshop can check it out to see how it works.

Good luck!

- Flex :D
Title: Watermarking hack (w/ ImageMagick)
Post by: moorey on November 12, 2003, 01:46:19 am
Thanks, flex!
FYI, moved this to the MOD section..
Title: Watermarking hack (w/ ImageMagick)
Post by: DJMaze on November 12, 2003, 03:49:16 am
Using GD is damn easy: http://www.php.net/manual/en/function.imagecopymerge.php

imagecopymerge combines 2 images and you can even setup a X and Y

And rotate it http://www.php.net/manual/en/function.imagerotate.php
Title: Watermarking hack (w/ ImageMagick)
Post by: flex on November 12, 2003, 12:42:42 pm
Yeh I had a look yesterday at GD but my server is playing up saying it's running out of memory when using createimagefromjpeg(), not sure what's up with that. Thought it was my code to start with but I tried switching coppermine to GD 1 or 2 and I get the same probs :\

Getting this error message:

Fatal error:  Allowed memory size of 8388608 bytes exhausted (tried to allocate 6400 bytes) in /home/users/jonny/www.jvcam.co.uk/html/coppermine/wm2.php on line 26
Title: Watermarking hack (w/ ImageMagick)
Post by: DJMaze on November 12, 2003, 01:11:29 pm
It seems a lot of servers have this problem.
A jpg is converted to a truecolor GD bitmap when imported.
It seems this uses a lot of memmory or is even a bug.

http://www.php.net/manual/en/function.memory-get-usage.php is a new function since php 4.3.2 check if you can use it and trace the allocated memsize for php tha will maybe give a solution.
Title: Watermarking hack (w/ ImageMagick)
Post by: flex on November 12, 2003, 01:24:31 pm
I used phpinfo() to check the memory allocation for PHP, and it's only 8mb. Which I'm guessing is not enough for the images I'm using to test watermarking, 1600 x 1200.

Unfortunately I can't change the amount of memory allocated for PHP as I don't have that kind of access to the server :\
Title: Watermarking hack (w/ ImageMagick)
Post by: DJMaze on November 12, 2003, 01:30:17 pm
well hack yeah that kind of image uses a lot of memory, try to reduce the color use when opening in GD the function is in image functions list of php.net
Title: Watermarking hack (w/ ImageMagick)
Post by: DJMaze on November 12, 2003, 07:21:47 pm
What i realy mentioned with the new memory_get_usage() function is:
Code: [Select]
echo memory_get_usage();
createfromjpeg();
echo memory_get_usage();


This way we can trace how much memory is actualy needed for the image.
Title: Watermarking hack (w/ ImageMagick)
Post by: flex on November 12, 2003, 08:41:21 pm
The thing is with the error, is that it's a fatal error message so nothing gets processed after imagecreatefromjpeg. So even trying echo memory_get_usage(); doesn't work :\

Is there an actual fix? Cos I don't see why GD should just fail on a image that size, it's not like it's that massive in terms of digital camera photos.
Title: Watermarking hack (w/ ImageMagick)
Post by: terrorhawk on November 13, 2003, 05:51:08 pm
Hi there..

i was trying to add the watermark hack but when it wants to open the pic in full size (so not the thumpnail) i get a X (image not found).
and i dont have any iedea what this could be.

please help..
if you need the files i changed just ask and i mail
Title: Watermarking hack (w/ ImageMagick)
Post by: flex on November 13, 2003, 07:37:51 pm
If you could email me your changed files then I can have a look, email them to jonny (at) jvcam (dot) co (dot) uk

I'll check them and see what's up with them. It could be possible that your installation of imagemagick on your server doesn't have the 'composite' command installed, but I don't think this is likely.

I await your email :)
Title: Watermarking hack (w/ ImageMagick)
Post by: hardlocke on November 14, 2003, 12:36:40 am
hi
i use the watermark-hack from "DJ AXION".... it's great!

- Link to Thread in the old board (http://coppermine.sourceforge.net/oldboard/viewtopic.php?t=961&postdays=0&postorder=asc&highlight=watermark&start=15)
- Sample (http://loosli.net/mymodules/coppermine/displayimage.php?album=57&pos=71)
Title: Watermarking hack (w/ ImageMagick)
Post by: terrorhawk on November 14, 2003, 10:00:40 am
Quote from: "flex"
It could be possible that your installation of imagemagick on your server doesn't have the 'composite' command installed, but I don't think this is likely.

I await your email :)


it is possible couse i run it at my own server. sow also i can check what the cpu load will be and memory load but it has to working first..

i will mail it today to you
Title: Watermarking hack (w/ ImageMagick)
Post by: flex on November 14, 2003, 11:27:13 am
Can you send me the link to your gallery too? I had a quick look at the code, doesn't seem to be anything wrong with it, but I can check the errors if I can see your gallery.
Title: Watermarking hack (w/ ImageMagick)
Post by: flex on November 14, 2003, 01:14:03 pm
ok all fixed up for working in windows as well now. Imagemagick in windows didn't like using single quotes around the filenames, changed them to double quotes.

Thanks to terrorhawk for letting me test on his server & helping me fix it!

I updated the source on my previous post to reflect.
Title: Watermarking hack (w/ ImageMagick)
Post by: gdn on November 20, 2003, 10:46:42 am
OK, I installed the hack and here's what I got:

Code: [Select]
Fatal error: Call to undefined function: get_pic_url() in /home/sites/site72/web/coppermine/index.php on line 462

 :?
Title: Watermarking hack (w/ ImageMagick)
Post by: gdn on November 21, 2003, 05:21:27 pm
Forget it... I used DJ Axion hack, and it runs OK.

The only problem I have is that I want to allow people to download the pics. And when you click right and click "save as", "logo.htm" is in the name field. I would like something like "file" or "image", just like in your hack. An idea about what I have to do?
Title: Watermarking hack (w/ ImageMagick)
Post by: flex on November 25, 2003, 10:57:48 am
Sorry I've not looked at DJ Axion's hack, so I don't know how you'd go about changing that - probably one to ask him!
Title: Watermarking hack (w/ ImageMagick)
Post by: Gaurav on December 26, 2003, 08:26:39 am
Quote from: "gdn"
Forget it... I used DJ Axion hack, and it runs OK.

The only problem I have is that I want to allow people to download the pics. And when you click right and click "save as", "logo.htm" is in the name field. I would like something like "file" or "image", just like in your hack. An idea about what I have to do?


I havent tried it, but I think if you change the name of the .php file and the .png file to image or file then it should work, also you will have to edit the functions.inc.php in the includes directory.


I have a question about DJ Axion's hack. I cant post there coz that thread is locked. here (http://coppermine.sourceforge.net/oldboard/viewtopic.php?t=961&postdays=0&postorder=asc&highlight=watermark&start=15) is the link to that hack.

Is it possible to add the logo in the pics that will be uploaded in the future? I have around 800 images in my gallery and I used to paste my logo on then using photoshop (silly me, didnt think of the watermark thingy :P ) Now if I add the logo to all the images then, it wont look good on already uploaded pix.

I will be happy if this is possible.
I am using coppermine 1.1D with a phpnuke portal (v 7.0)

Thanx a lot
Title: seems to be a problem
Post by: klaws on December 30, 2003, 01:11:09 pm
When i install the watermark hack for image magick,
the images wont show.

without the watermark if i right click the image and select properties it says the location is: http://home.fjas.dk/gallery/albums/wpw-99/IMGP0141.JPG

but with the watermark it says it's: http://home.fjas.dk/gallery/wm.php?pid=154&mode=fullsize
and i doesnt show any image, only the IE red cross.

i copy pasted the code directly from this thread (and yes i made the line breaks right :D )

any ideas?
Title: Watermarking hack (w/ ImageMagick)
Post by: Gaurav on December 31, 2003, 04:49:03 am
I think u have changed the name of the file to wm.php try renaming it to logo.php

Also if u want to change the name of the file then change it in functions.inc.php too.

Can someone answer my question too :(

thanx
Title: alpha-layer transparency
Post by: asdf on January 07, 2004, 07:36:15 pm
The watermark image itself is a PNG file created in photoshop with alpha-layer transparency

Hey all,
Anybody point me to a link about creating said "alpha-layer transparency"?  My photoshop skills are rudimentary and the googling I did seemed to say that png didn't have an alpha layer?  

Pls Help
thx
ej
Title: Re: alpha-layer transparency
Post by: moorey on January 12, 2004, 04:41:40 am
Quote from: "asdf"

Hey all,
Anybody point me to a link about creating said "alpha-layer transparency"?  My photoshop skills are rudimentary and the googling I did seemed to say that png didn't have an alpha layer?  


First link googled:
http://thesprayshop.net/tutorials/tut_photoshop_alpha.shtml

Just save as PNG instead of TIFF.
Title: Watermark question
Post by: mslino on January 16, 2004, 08:14:22 pm
Hi!

How can add a watermark for each user a have using gallery? Is it possible?
Title: gif
Post by: gmarik on January 18, 2004, 12:43:16 pm
does any of you had problems configuring Image Magick to read gif's - it just doent accepts them!
Title: Re: gif
Post by: Joachim Müller on January 18, 2004, 01:43:42 pm
Quote from: "gmarik"
does any of you had problems configuring Image Magick to read gif's - it just doent accepts them!
there's a legal issue with gifs, that's why they're not supported. Even if you get them to work, you'll have very large file sizes because the lzw compression can't be used (copyright issue). To find out more, search this board, or better still: go to the ImageMagick site!

GauGau

P.S. this thread deals with Watermarking, not server setup. Do not hijack other people's threads! :evil:
Title: Watermarking hack (w/ ImageMagick)
Post by: Trinity on January 19, 2004, 10:02:42 am
I get some photos not showing as well... it seems as if it loses them at times depending on how you move around.

Strange
Title: Watermarking hack (w/ ImageMagick)
Post by: Trinity on January 21, 2004, 06:15:54 am
Quote from: "flex"
ok here it is, it'll probably need some fixes. I've listed the known issues at the bottom:


Step 1. includes/functions.inc.php

Find this line right at the bottom of the script:
Code: [Select]

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


And change it to this:

Code: [Select]

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

                // return the url to the wm script
                return "wm.php?pid=".$pic_row["pid"]."&mode=".$mode;

        }else{
                // it's a thumb, don't bother wm'ing
                return $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:

Code: [Select]
<?
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 my one from here:
http://www.jvcam.co.uk/coppermine/watermark.png

And put it in your root coppermine directory.

Known Issues
1. Images stored on other servers, I've not even looked at how coppermine handles this but I know it does from looking at the code, but this doesn't support that and I'm not sure it would be possible for imagemagick to do it anyway with remote images.. Thinking it would take some php code to retrieve the image, wm it and then display it - I guess it's possible.

2. GD. GD implementation I've not even looked at yet, I don't know if it's possible but I'll try have a look in the next couple of days and see if it's possible. That said, if you're using GD, then it shouldn't effect the way you use coppermine, it just won't watermark the images.

3. At present there's no way to turn it on or off through the config screen, this is something the other dev's can do easily I'm sure, I didn't get stuck into the config stuff. The only way you can turn it off is to remove the altered script lines. Also, it watermarks both 'normal' and 'fullsize' images, there's no option to turn either one on/off yet.

4. Versions. It should work in anything greater than coppermine 1.1, since that's what I tested it with and I checked the 1.2 code and there's no changes in the lines I altered.

5. I'll try and produce a tutorial in creating the watermark images because it's not exactly straight forward and it has to be a png file. I couldn't get transparent gifs to work at all.

6. Server load. I've no idea how much server load it takes to wm an image every time it's requested as I don't have full access to the server I work on... Anyone who does have access and can check, I'd be interested to see how much load it creates.

I corrected it so that it doesn't pass the full url to the wm.php script, it now uses the pid of the image to find it and look it up in the db. This should somewhat stop people from stealing your images by finding the full path but it's not infallable.

I'm sure there's a few other issues too that I'm not aware of so I encourage people to try it out and see what happens and report back to this thread.

Last note, the wm image I use is this one http://www.jvcam.co.uk/coppermine/watermark.png
Those with photoshop can check it out to see how it works.

Good luck!

- Flex :D


Worked like a champ. I don't know sheit about this and it was smooth as silk.  I didn't know what the hell the alpha channel was for the watermark, but I figured it out in PS. Hust create the watermark and click on new channel at the bottom of the channels app. No sweat...

Thanks
Trin
Title: Watermarking hack (w/ ImageMagick)
Post by: fool on January 26, 2004, 01:33:27 pm
hello,

mod is working fine !!

thanks for your work!

greetings fool
Title: Watermarking hack (w/ ImageMagick)
Post by: elderban on February 01, 2004, 03:42:34 am
Got it to work great for me! Thanks for the hack!   :D
Title: Thumbnails too?
Post by: comic on February 03, 2004, 12:00:06 pm
Great working mod. in my case I would like to have my webaddress as a watermark in the thumbnails too. I tried to modify your mod by calling a new wmt.php especially for the thumbnails. This resulted in watermarked thumbnails indeed, except for the thumbnails in the albumlist. These thumbnails didn't show up because $pic_row["pid"] was empty in these cases.
As a workaround I changed the last bit of your code to:
Quote
}else{
// it's a thumb, don't bother wm'ing

 if ($pic_row["pid"] == ""){

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

 }else{

  return "wmt.php?pid=".$pic_row["pid"]."&mode=".$mode;

 }

Although this works, part of the thumnails still don't contain the watermark. As I'm no php expert can someone please help me out?

Thanks!,
Pieter

PS I also was wondering if the watermark could be scaled to the picture as well so it's not too big on small pictures and too small on big pictures.
Title: Re: Thumbnails too?
Post by: comic on February 10, 2004, 04:29:58 pm
Quote from: "comic"
. . . . This resulted in watermarked thumbnails indeed, except for the thumbnails in the albumlist. These thumbnails didn't show up because $pic_row["pid"] was empty in these cases.
. . . .
Although this works, part of the thumnails still don't contain the watermark. As I'm no php expert can someone please help me out?


Seeing lots of people reading my post, but not reponding, I presume it's either too hard to do or not interesting enough for most  :( .

So maybe someone could tell me how the watermark code could be used to add the watermark when creating thumnail and intermediate pictures on the server. :idea:  In that case even linking to the real file on the server (without coppermine) would display the watermarked picture!!!

To prevent users finding the original (fullsize) picture it would also be nice if the original could be prefixed on upload with some prefix that is not too obvious (i.e. fullpref_) or by moving it to another (sub)directory. Any idea's?

Thanks,
Pieter
Title: Watermarking hack (w/ ImageMagick)
Post by: doxx on February 15, 2004, 01:57:53 pm
hello, I applied the hack exactly as described (CP 1.1.0)
and this happens

Quote
Parse error: parse error in /var/www/html/photos/include/functions.inc.php on line 821


Category
Albums
Pictures

New York Street Photography
6
347

Tags
1
34

Objects/Various
1
25

Nature
1
9

415 pictures in 9 albums and 4 categories with 0 comments viewed 818 times


Fatal error: Call to undefined function: get_pic_url() in /var/www/html/photos/include/functions.inc.php on line 788


I'm totally clueless about php, any help would be appreciated
Title: Watermarking hack (w/ ImageMagick)
Post by: Joachim Müller on February 15, 2004, 02:03:04 pm
the parse error indicates that you didn't apply the mod as suggested, see faq: common php errors (http://coppermine.sourceforge.net/faq.php?q=commonPHPerrors#commonPHPerrors)

GauGau
Title: Move watermark
Post by: Trinity on February 16, 2004, 03:42:10 am
Hello guys... I would like to move the watermark around and find out where I want to place it. The bottom right is okay, but a little crop and it's gone. I would like to have it in the middle and centered or someplace else. Can you tell me where and how to move the placement of the watermark around the page?

I found one of my images cropped and used on another page. :(

Thanks
Title: Watermarking hack (w/ ImageMagick)
Post by: FreeMail on February 17, 2004, 02:19:14 pm
do we need to download the .png file or can we just make our own? the link to the .png file doesn't seem to work...


TIA!
Title: Watermarking hack (w/ ImageMagick)
Post by: flex on February 28, 2004, 03:28:34 pm
Sorry about that, I'm no longer using Coppermine (developing my own thing) but you can still grab the watermark image from here if you're applying this mod:

http://www.jvcam.co.uk/coppermine/watermark.png

Most people have got this working, and I'm not up to date on the latest developments with coppermine, but I'm sure watermarking will be included as standard eventually. Also, with what I'm developing I've added an extra field to the photos table which specifies whether that image should be watermarked or not. So you have complete control over which images you wish to be watermarked.

As for thumbnails, I didn't see much point in watermarking them since they are tiny and I can't imagine anyone would want to copy the thumbnail.

With regards to placement, the following line is what you need to change:

Code: [Select]

$cmd = "{$CONFIG['impath']}composite -compose over -gravity Southeast \"".realpath("./watermark.png")."\" \"".realpath('./'.$CONFIG["fullpath"].$row["filepath"].$pic_prefix[$mode].$row["filename"])."\" jpg:-";


The placement is determined by the '-gravity Southeast', you can change this to any of the eight points on a compass (north, northwest etc..) and it'll position the image there.

As for specific placement, you'll have to look into the finer workings of ImageMagick to sort that out...

Flex :)
Title: Watermarking hack (w/ ImageMagick)
Post by: comic on February 29, 2004, 05:47:54 pm
Quote from: "flex"
As for thumbnails, I didn't see much point in watermarking them since they are tiny and I can't imagine anyone would want to copy the thumbnail.


Well, I've two reasons to do so:

1) My watermark is a text with the siteaddress; I use the thumbnails on another site for publicity
2) When you look at the properties of a thumnail, it's far too easy to download the full non watermarked original . . . (just remove the "thumb_" part and load the rest of the url in your browser)

Hope you reconsider to take a look for me (I solved it partly as stated above, but the solution is incomplete).

thanks!,
pieter
Title: Watermarking hack (w/ ImageMagick)
Post by: flex on February 29, 2004, 05:59:25 pm
Well I understand the security point of view, and that has been on my mind since I created the watermark hack. The only way I can see round this is to place the whole album directory outside of the web root so it's impossible to access them via a browser, yet the scripts can still access them to watermark & output them.

Just thinking about this now, I have no idea what effect this would have on the rest of the coppermine code, I'm not entirely sure if it's as simple as setting up your config files/options and changing the location of the albums directory. However, I imagine that it is possible. Also, not all webhosts let you put things outside the web root.

But if you'd like thumbnails watermarked as well, just change this code:
Code: [Select]

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

      // return the url to the wm script
      return "wm.php?pid=".$pic_row["pid"]."&mode=".$mode;

   }else{
      // it's a thumb, don't bother wm'ing
      return $url_prefix[$pic_row['url_prefix']]. path2url($pic_row['filepath']. $pic_prefix[$mode]. $pic_row['filename']);

   }


to this:

Code: [Select]

     
if($CONFIG['thumb_method']=='im'){

    // return the url to the wm script
    return "wm.php?pid=".$pic_row["pid"]."&mode=".$mode;

}else{
    // ok so we're not using ImageMagick, so can't wm it...
    return $url_prefix[$pic_row['url_prefix']]. path2url($pic_row['filepath']. $pic_prefix[$mode]. $pic_row['filename']);

}


I've not tested that, but it should work as it's just taking out a couple of the if clauses. Test it and let me know.

I also looked into the possibility of using seperate watermark images for each of the 'normal', 'thumb' and 'fullsize' images since I think the wm should be scaled for each one of these... Let me know if you'd like me to look into that, shouldn't be difficult to do...

Cheers,
Flex :)
Title: Watermarking hack (w/ ImageMagick)
Post by: comic on February 29, 2004, 09:33:55 pm
Quote from: "flex"
. . . The only way I can see round this is to place the whole album directory outside of the web root so it's impossible to access them via a browser, yet the scripts can still access them to watermark & output them.


Interesting idea . . . anyone has experiance with this?

Quote from: "flex"

But if you'd like thumbnails watermarked as well, just change this code:
Code: [Select]

     
if($CONFIG['thumb_method']=='im'){

    // return the url to the wm script
    return "wm.php?pid=".$pic_row["pid"]."&mode=".$mode;

}else{
    // ok so we're not using ImageMagick, so can't wm it...
    return $url_prefix[$pic_row['url_prefix']]. path2url($pic_row['filepath']. $pic_prefix[$mode]. $pic_row['filename']);

}


I've not tested that, but it should work as it's just taking out a couple of the if clauses. Test it and let me know.

I also looked into the possibility of using seperate watermark images for each of the 'normal', 'thumb' and 'fullsize' images since I think the wm should be scaled for each one of these... Let me know if you'd like me to look into that, shouldn't be difficult to do...


I did a similar change before, but found that sometimes ($pic_row["pid"] == "") and therefore the wm.php didn't give a picture back. I modified the code for thumnails as follows:

Code: [Select]

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

// return the url to the wm script
 return "wm.php?pid=".$pic_row["pid"]."&mode=".$mode;

}else{
// it's a thumb, if possible do wmt'ing (wmt.php has the same code as wm.php, but calls smaller watermark)
 if ($pic_row["pid"] == ""){

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

  return $url_thmbnl;

 }else{

  return "wmt.php?pid=".$pic_row["pid"]."&mode=".$mode;

 }


Everyone wanting to use this, please note that my code doesn't check correctly for imagemagick (because I only use imagemagick ;))

Problem remains that in album list the pictures will not be watermarked and the properties still show the filename, so these files can still be downloaded. Here's and example: http://www.comictoys.info/cpg/index.php?cat=2 . Rightcliking gives the properties of these pictures. I know how to prevent rightclicking, but that will only hold off newbies. Now if you click on one of the pictures there, you will see that all other thumbnails ARE watermarked! This is because of the code I listed above.

Pieter
Title: Watermarking hack (w/ ImageMagick)
Post by: Joachim Müller on February 29, 2004, 09:34:17 pm
@comic: if you're the only one uploading to your gallery, why don't you attach the watermark client sided (before upload)? There are some good free programs out there that do this in no time.

GauGau
Title: Watermarking hack (w/ ImageMagick)
Post by: comic on February 29, 2004, 09:45:58 pm
Quote from: "gaugau"
@comic: if you're the only one uploading to your gallery, why don't you attach the watermark client sided (before upload)? There are some good free programs out there that do this in no time.


Every registered member, is allowed to upload . . .  :P

Besides . . . having coppermine do it for me, takes less time

but thanks anyway for trying to help
Title: Watermarking hack (w/ ImageMagick)
Post by: flex on February 29, 2004, 11:43:51 pm
I don't know why $pic_row["pid"] would ever return an empty string since every photo *should* (and is required by the database structure) to have a unique ID for each photo, pid.

The only reason why I'd think that you wouldn't get a returned watermark image is if the fullsize image has dimensions below what you specify as the intermediate image (which I don't think my script checks for). There are some alterations which I could do to the script to check for this...

Without looking at your gallery I can't say for sure...
Title: Watermarking hack (w/ ImageMagick)
Post by: comic on March 01, 2004, 12:45:39 am
Quote from: "flex"
I don't know why $pic_row["pid"] would ever return an empty string since every photo *should* (and is required by the database structure) to have a unique ID for each photo, pid.


I'm afraid it does and saw another script that tried to hide the url of the pictures do a check on the $pic_row["pid"]. That script also returned the real url for a thumbnail when it was empty.

Quote from: "flex"
The only reason why I'd think that you wouldn't get a returned watermark image is if the fullsize image has dimensions below what you specify as the intermediate image (which I don't think my script checks for). There are some alterations which I could do to the script to check for this...

Without looking at your gallery I can't say for sure...

The example I gave in my previous post only contains pictures with 1200x1600 resolution, while intermediate is 500 pixels. If you follow one of the pictures in the albumlist you'll notice the same thumbnail is in the gallery and that at that point the watermark DOES work! So I guess the check is not the solution. . .

Quote from: "Comic"
Problem remains that in album list the pictures will not be watermarked and the properties still show the filename, so these files can still be downloaded. Here's and example: http://www.comictoys.info/cpg/index.php?cat=2 . Rightcliking gives the properties of these pictures. I know how to prevent rightclicking, but that will only hold off newbies. Now if you click on one of the pictures there, you will see that all other thumbnails ARE watermarked! This is because of the code I listed above.
Title: Watermarking hack (w/ ImageMagick)
Post by: flex on March 01, 2004, 11:17:31 am
I think I might know what the problem is. I'll download the coppermine source again and take a second look. I'll post back here if/when I find the solution.

Flex :)
Title: Watermarking hack (w/ ImageMagick)
Post by: FreeMail on March 04, 2004, 12:18:58 pm
any tip on how to create our own watermark text or graphics?  via photoshop.


tia!
Title: Watermarking hack (w/ ImageMagick)
Post by: golf16vkr on March 04, 2004, 01:27:01 pm
Thanks this hack worked excellent for me
Title: Watermarking hack (w/ ImageMagick)
Post by: FreeMail on March 04, 2004, 02:37:22 pm
hi!  i have this problem, cant seem to find my INCLUDES folder on my Harddisk, but its on my WEBSERVER.  inside the INCLUDES folder is the functions.php file not the functions.inc.php as stated in the 1st post by FLEX.

please clarify, thanks!

TIA!
Title: Watermarking hack (w/ ImageMagick)
Post by: flex on March 04, 2004, 03:06:15 pm
I'm guessing that depends on what version of coppermine you're using. Anything above version 1.1 i think it'll be called functions.inc.php, but anything before that I don't know...

As for tips on creating the watermark image, it needs to be a png called watermark.png. If you want transparency then you'll need to create an alpha channel layer in photoshop to do this. I think you do this in the layer window, but I can't remember the exact process to do it. Maybe look in the photoshop help for 'alpha channels' or google it?

You can load my watermark (http://www.jvcam.co.uk/coppermine/watermark.png) into photoshop to see how mine looks and go from there?

Flex :)
Title: Watermarking hack (w/ ImageMagick)
Post by: flex on March 04, 2004, 03:13:03 pm
Ok I've created a generic coppermine watermark for those having trouble creating one in photoshop/paintshop pro and don't want to use the one I posted (obviously).

I'm still looking at the thumbnail watermark problem.. just takes a while for my head to get round the code again.

Here's the generic watermark:
http://www.jvcam.co.uk/coppermine/watermark-cpg.png

You'll need to rename it to watermark.png for it to work with the script.[/php]
Title: Watermarking hack (w/ ImageMagick)
Post by: FreeMail on March 04, 2004, 03:14:54 pm
i have both include and includes in my server.  the include folder is where i have functions.inc.php, thats the file i should edit?
Title: Watermarking hack (w/ ImageMagick)
Post by: flex on March 04, 2004, 03:19:02 pm
functions.inc.php is the file u should edit
Title: Watermarking hack (w/ ImageMagick)
Post by: FreeMail on March 04, 2004, 03:29:00 pm
ok, thanks a lot! wish me luck!
Title: Watermarking hack (w/ ImageMagick)
Post by: FreeMail on March 04, 2004, 03:33:27 pm
got this error message :(

Quote
Parse error: parse error in /home/ast/public_html/include/functions.inc.php on line 1109

Fatal error: Call to undefined function: get_pic_url() in /home/ast/public_html/index.php on line 462
Title: Watermarking hack (w/ ImageMagick)
Post by: flex on March 04, 2004, 03:39:07 pm
Umm, u did edit the file right? not just replace the contents of it with what the post says?
Title: Watermarking hack (w/ ImageMagick)
Post by: FreeMail on March 04, 2004, 03:46:12 pm
my index.php page is working already, but clicking the normal picutre give my a X.
Title: Watermark with text instead of PNG
Post by: bshrdr on March 05, 2004, 03:59:36 pm
Well, I took this cool little hack a step further.  Instead of creating a PNG offline (which was no real problem - it just didn't suit my needs), I wanted to just use plain old text.  So I came up with this, which creates a small PNG on the fly.  It puts out 2 layers of text - a foreground and a shadow offset by one pixel to the right and down, then mashes it to the requested image, as the original script did.

Just find this in wm.php:

Code: [Select]
$cmd = "{$CONFIG['impath']}composite -compose over -gravity Southeast \"".realpath("./watermark.png")."\" \"".realpath('./'.$CONFIG["fullpath"].$row["filepath"].$pic_prefix[$mode].$row["filename"])."\" jpg:-";


And replace it with this:
Code: [Select]


            $line1 = "Line One Text Here";
            $line2 = "Line Two Text Here";
            $home = "/full/path/to/CPG/home/";  #with trailing slash
            $im = imagecreate(180,35);     #Modify for size of image you wish
            $bg = imagecolorallocatealpha($im,255,255,255,127);  #sets background color as white & transparent
            $textcolor = imagecolorallocate($im,0,0,0);  #foreground text color
            $textcolor1 = imagecolorallocate($im,255,255,0);  #shadow text color
            imagestring($im,3,1,1,$line1,$textcolor1);
            imagestring($im,3,0,0,$line1,$textcolor);
            imagestring($im,5,2,13,$line2,$textcolor1);
            imagestring($im,5,1,12,$line2,$textcolor);
            imagepng($im,$home."wmark.png");

            $cmd = "{$CONFIG['impath']}composite -compose over -gravity Southeast \"".$home."wmark.png\" \"".realpath('./'.$CONFIG["fullpath"].$row["filepath"].$pic_prefix[$mode].$row["filename"])."\" jpg:-";


One caveat - you may need to create the temporary wmark.png file in the root CPG directory with 777 permissions prior to running the script.  Just create a zero length file, and the script will create it the first time it runs.

It's in use on my CPG site - http://photos.railfanzone.com (still in development, but almost there...)

Enjoy!
Tom
Title: Possitioning didnot work
Post by: djboxny on March 05, 2004, 05:29:04 pm
well tried to possition the watermark on the bottom of the pictures so i changed southeast to northwest but din't work at all.  it stays at the top left corner.  the link is www.djboxny.com/gallery1
Title: Watermarking hack (w/ ImageMagick)
Post by: flex on March 05, 2004, 06:00:04 pm
Northwest would be the top left corner of the picture anyway...

North = top
Northeast = top right
East = right
Southeast = bottom right
South = bottom
Southwest = bottom left
West = left
Northwest = top left
Title: Re: Watermark with text instead of PNG
Post by: flex on March 05, 2004, 06:05:02 pm
Quote from: "bshrdr"
Well, I took this cool little hack a step further.  Instead of creating a PNG offline (which was no real problem - it just didn't suit my needs), I wanted to just use plain old text.  So I came up with this, which creates a small PNG on the fly.  


Nice work! I had considered doing something similar but now there's no need! I think this would be a great way of putting watermarking into coppermine since you control it all from the control panel, instead of having to upload images etc.

The one thing I did look at was trying to use different fonts for the text, but I didn't get very far with the GD/Imagemagick functions for this...
Title: Still
Post by: djboxny on March 05, 2004, 06:42:36 pm
It is at southeast and still appears at the top left no matter to what i change it too.  this is the code i have inplemted
Code: [Select]
<?
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;
?>



is this correct
Title: Watermarking hack (w/ ImageMagick)
Post by: flex on March 05, 2004, 07:19:53 pm
Hmm that's very strange, it all looks ok to me... By default gravity is set to Northwest but I have no idea why it's not working when you set it to Southeast...

Any ideas what version of imagemagick you're using? I guess it could be a bug with an older version...
Title: Watermarking hack (w/ ImageMagick)
Post by: golf16vkr on March 05, 2004, 10:31:34 pm
Is it possible to but the logo's in for outside linking ?

I have searched the board but it's not quite clear to me.

I hope this is not seen as spamming and someone can help me out.

Thanks in advance
Title: Watermarking hack (w/ ImageMagick)
Post by: FreeMail on March 06, 2004, 05:03:31 pm
Quote from: "flex"
Ok I've created a generic coppermine watermark for those having trouble creating one in photoshop/paintshop pro and don't want to use the one I posted (obviously).

I'm still looking at the thumbnail watermark problem.. just takes a while for my head to get round the code again.

Here's the generic watermark:
http://www.jvcam.co.uk/coppermine/watermark-cpg.png

You'll need to rename it to watermark.png for it to work with the script.[/php]



i tried the watermark-cpg.png file but i get a X mark, any tip on how i can solve this?  :roll:

tia!
Title: Watermarking hack (w/ ImageMagick)
Post by: flex on March 07, 2004, 01:50:10 pm
Quote from: "FreeMail"

i tried the watermark-cpg.png file but i get a X mark, any tip on how i can solve this?  :roll:


Ok you can try editing wm.php to echo the imagemagick command to see if it's constructing it correctly.

Code: [Select]

<?  
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:-";  

echo $cmd;

//passthru ($cmd, $output);  

//echo $output;  
?>


Try that and then call the image directly on one of your images. I tried looking at your gallery but it seems your having a few account problems with it, so let me know when you've done the above editing and we'll try get this sorted out.

Flex :)
Title: Watermarking hack (w/ ImageMagick)
Post by: FreeMail on March 07, 2004, 01:59:37 pm
thanks for the tip!

my webhost got hacked by one of its subscriber! sigh!  :lol: everything wiped out according to the webhost!
Title: Hey
Post by: djboxny on March 07, 2004, 09:10:23 pm
Let us know what hosting company your are with so we don't go to that company and get hacked too :roll:
Title: hi
Post by: jamaman83 on March 10, 2004, 11:19:59 pm
I did all the stuff in the hack but i get X when viewing normal or full sized images, when i launch the wm script by itself with the correct options it just returns a value of 1.

Pleas help thanks
Title: Watermarking hack (w/ ImageMagick)
Post by: smidge on March 19, 2004, 07:36:12 pm
Hi Flex/Gaugau, I love the script, it works beautifully for me. I was just curious about a quick addition.

Is there a way to turn off the watermark if the image was uploaded by a user? Seems like it would just be a simple if-then statement in there but I don't know anything about php or the variables for the users.

I only ask because my brother got upset when he saw my watermark on his pictures.

And another nice feature would be to specify the watermark by which user the picture belongs to. But I don't really care about that for now.

If you don't have time, could you just give me the variable for users in general and I'll fool around with it? Thanks.

http://www.tedesigns.org
Title: Watermarking hack (w/ ImageMagick)
Post by: hyperion on March 19, 2004, 11:50:33 pm
This thread should give you some ideas.

http://forum.coppermine-gallery.net/index.php?topic=3269
Title: Slideshow and ecard
Post by: jerx on March 24, 2004, 06:36:48 pm
Hello,

I would like to use slideshow and ecard function, but those pictures have no watermark. I think you have to modify slideshow.inc.php and ecard.php. Can anybody help me?

Thank you in advance,

jerx
Title: Watermarking hack (w/ ImageMagick)
Post by: smidge on March 25, 2004, 01:29:36 am
Quote from: "hyperion"
This thread should give you some ideas.

http://forum.coppermine-gallery.net/index.php?topic=3269


Hi hyperion, thanks for the reference. I've actually already looked at that thread before but can't really make out anything. What does $user1, $user2 etc. refer to?

I don't want to implement that code because I would have to go through all of my pictures (almost 900) and individually add the watermark. I tend to batch upload large numbers of pictures at a time as well. If I could just get this code to check and see if the picture was uploaded by a user, that would be great.
Title: Change for VIDEO-hack
Post by: joko on April 01, 2004, 04:01:20 am
I have made some modify for VIDEO-hack.

Find in include/function.inc.php
Code: [Select]

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


replace with
Code: [Select]

                if (is_image($pic_row['filename'])) {
                        if((($mode == "normal") || ($mode == 'fullsize')) && ($CONFIG['thumb_method']=='im')){

                                 // return the url to the wm script
                                return "wm.php?pid=".$pic_row["pid"]."&mode=".$mode;
                        }else{
                                // it's a thumb, don't bother wm'ing
                                return $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']);
                }                


That's will ok for VIDEO-hack.

ps:I have test this with video-Full package.
Title: Re: Watermarking hack (w/ ImageMagick)
Post by: cem on May 28, 2004, 03:22:56 am
Hi there..

i was trying to add the watermark hack but when it wants to open the pic in full size (so not the thumpnail) i get a X (image not found).
and i dont have any iedea what this could be.

please help..
if you need the files i changed just ask and i mail

Same here and also noticed others have the same problem.. Did you manage to find/fix the problem??
Title: Re: Watermarking hack (w/ ImageMagick)
Post by: loudone on June 01, 2004, 06:12:53 am
This works great! It is just what I needed! Anyone have input on the slideshow view? It makes it load real slow now.
Title: Re: Watermarking hack (w/ ImageMagick)
Post by: shutiri on June 02, 2004, 09:55:18 pm
great...  it's working fine. thank you.

Does anyone knows how to center the wm just in the middle of the image ?

I saw this:
Quote
North = top
Northeast = top right
East = right
Southeast = bottom right
South = bottom
Southwest = bottom left
West = left
Northwest = top left

But I would like to have it just in the middle.

thank you.
shutiri.


Title: Re: Watermarking hack (w/ ImageMagick)
Post by: loudone on June 03, 2004, 04:27:55 am
When a user views a full size image, how would you make the watermark larger??  Fits perfect in intermediate view....


Thanks
Title: wm.php & hotlinking on windows
Post by: sigepjedi on June 16, 2004, 05:59:50 pm
Ive got the wm.php working 100%, and im also concerned about hotlinking to my images which is currently taking place.

Im on a windows box, so the .htacess doenst help me much. Ive read though all the postings about hotlinking and nothing really takes care of my issue.

Im wondering if the users cgi referer can be checked on the wm.php page, since this is driving all image calls. If the referer is contained in the allow list, allow the watermarking and images to be displayed. If it is not, then display either another image, or a more anoying watermarked image.

Is this possible?

Im not too familure with PHP, but this would be easy to do im ColdFusion.

I also found the following online regarding HTTP_REFERER, but cant get it to work. (again not php expert)

Code: [Select]
<?php
$referrer 
getenv"HTTP_REFERER" );
$imagedir"imx/";
$img $_GET[sid];
$myDomain "mysticalillusionz";
if (!
eregi($myDomain,$referrer)) {
  
$imagepath $imagedir $img
  
$imageinfo getimagesize$imagepath );
  if (
$imageinfo[2] == 1) {
    
$imagetype "gif" ;
  }elseif (
$imageinfo[2] == 2) {
  
$imagetype "jpeg" ;
  }elseif (
$imageinfo[2] == 3) {
  
$imagetype "png" ;
  }else {
  
header"HTTP/1.0 404 Not Found" );
  exit ;
  }
header"Content-type: image/$imagetype);
@
readfile$imagepath );
} else {
header"HTTP/1.0 404 Not Found" );
}
?>
Thanks in advance.

[edit GauGau]
added line breaks to code to increase readability
[/edit]
Title: Re: Watermarking hack (w/ ImageMagick)
Post by: chopperwire on June 24, 2004, 01:56:12 am
Help! I changed and added the new files like you mention and when I go to view my images ithey dont show up, all I get is the little white box with an x in it. What did I do wrong?
Title: Re: Watermarking hack (w/ ImageMagick)
Post by: JakeLM on June 26, 2004, 11:24:14 am
Hi  ;)
i have tried this hack and works fine!!!
Just a question: someone here knows how to place the watermark in the Border of the image ??
I need to place it just out the image; can i use those settings and option for imagemagick  http://www.imagemagick.org/www/ImageMagick.html ?
I think that the option " -geometry" probabily is the right solution... but can i use it with negative  value ???

Thx  ::)
Title: Re: Watermarking hack (w/ ImageMagick)
Post by: IIIBradIII on July 16, 2004, 08:12:12 pm
Anyone have this working properly on 1.3?
Title: Re: Watermarking hack (w/ ImageMagick)
Post by: MGSteve on July 18, 2004, 10:08:22 pm
I hate to ask, but why on earth would you do this per request and not simply watermark the images as they are uploaded, I mean, its not rocket science. Put this hack on a half busy server and you'd kill it.
Title: Re: Watermarking hack (w/ ImageMagick)
Post by: kiig on August 03, 2004, 10:30:39 am
Anyone with a working Watermark MOD for version 1.3 ?
I've tried for days without luck... I just thought my server or something was wrong, - but when I did the same thing on my 1.2.1 Coppermine machine, - everything worked.

So I have a problem getting it to work on version 1.3.1. I've no problem with 1.2.1

any ideas ?

Kim Igel
Title: Re: [CPG1.2.1 only]: Watermarking hack (w/ ImageMagick)
Post by: erroneus on August 04, 2004, 03:45:45 pm
I'm running coppermine 1.3.1 with GD2, and I tried Karri's hack but came out unsucessful. So I've just decided to wait until the next release which is supposed to have a built-in watermarking feature. This will be sweet. When should we expect the next release anyway?
Title: Re: [CPG1.2.1 only]: Watermarking hack (w/ ImageMagick)
Post by: Joachim Müller on August 04, 2004, 04:11:01 pm
the next release which is supposed to have a built-in watermarking feature.
Who told you so? I haven't heard from any dev working on watermarking being part of the coppermine core code.

When should we expect the next release anyway?
Same answer that is being repeated by open source coders of all projects: "It'll be released when it's ready"  ;).

GauGau
Title: Re: Watermarking hack (w/ ImageMagick)
Post by: kiig on September 21, 2004, 12:55:21 pm
Has anyone done the Imagemagick wtermarking 'hack' with Coppermine 1.3.2 ? It worked for me with 1.2.1, - but not since upgrading, - and I've just tried it again with a new installation of 1.3.2... no go...

?

Kim Igel.
Title: Re: Watermarking hack (w/ ImageMagick)
Post by: kiig on September 21, 2004, 11:54:08 pm
hmm.... a bit stubborn here, - so I ran through everything a couple of times. It turns out that in the wm.php file, - in the $cmd construction, - on my server, at least, it failed to resolve
realpath("./watermark.png")

Code: [Select]
$cmd = "{$CONFIG['impath']}composite -compose over -gravity Southeast \"".realpath("./watermark.png")."\" \"".realpath('./'.$CONFIG["fullpath"].$row["filepath"].$pic_prefix[$mode].$row["filename"])."\" jpg:-";

So I hardcoded it to read : (which obviously needs to be changed, - but it's a full path on the server directly)

Code: [Select]
$cmd = "{$CONFIG['impath']}composite -compose over -gravity Southeast \"/home/e-smith/files/ibays/foto/html/watermark.png\" \"".realpath('./'.$CONFIG["fullpath"].$row["filepath"].$pic_prefix[$mode].$row["filename"])."\" jpg:-";
and it works...


I worked for me, - so it's just a hint to everyone else having problems with this.

Kim Igel.
Title: Re: Watermarking hack (w/ ImageMagick)
Post by: kiig on September 22, 2004, 11:55:27 pm
but it only works when my language is set to English.... not 'danish'' which I prefer for this coppermine installation.

Does anyone have an idea why ?

Kim Igel.

Title: Re: Watermarking hack (w/ ImageMagick)
Post by: PCGUY112887 on September 25, 2004, 04:19:01 am
Does anyone know how to make this script not take effect to other things like Video's and ZIP's?  Right now I have a bunch of ZIP's uploaded and they are erroring because of this mod...
Title: Re: Watermarking hack (w/ ImageMagick)
Post by: kiig on September 25, 2004, 12:55:05 pm
Regarding the language problem, - someone suggested removing the trailing blank lines in danish.php (in another thread about batch image uploading), - and removing the empty lines made the batch uplad work (now showing the little icons), - and it also makes this Watermark mod work :-) in danish.
Title: Re: Watermarking hack (w/ ImageMagick)
Post by: PCGUY112887 on September 27, 2004, 05:04:30 am
There has to be a way to modify wm.php to not mess with things that aren't images... I would do it myself but I am not a php person!
Please help?  I really need watermarks but also need ZIP's to work!
Title: Re: Watermarking hack (w/ ImageMagick)
Post by: kegobeer on September 27, 2004, 05:19:51 am
There's already an easy way to determine the file type - media.functions.inc.php.  Just include it in wm.php and call the function is_image before the watermarking happens, like this: $whatisit = is_image($filename), where $filename has the path and filename of the file in question.  If it returns true it's an image.  You could wrap the watermarking code inside an if-then statement:

Code: [Select]
if ($whatisit)
{
  ... watermarking code
}
Title: Re: Watermarking hack (w/ ImageMagick)
Post by: PCGUY112887 on September 27, 2004, 05:43:42 am
:) Thanks
As I was reading your post trying to figure out exactelly what you wanted me to do (me and any language don't get along well) I saw this...

"where $filename has the path and filename of the file in question"
And I didn't quite understand it.  Path and filename to which file?  The ZIP I can't get working?  There are bunches and more would be uploaded by different people...

If someone would be o so kind to post a modded wm.php useing kegobeer's instructions I would love you for the rest of my life :-P
I don't know why but I can totally understand nearelly everything in computers... I just can NOT understand programming languages and 3D proggies... I really need to work at php maybe get myself a book...
Title: Re: Watermarking hack (w/ ImageMagick)
Post by: Zeitgeist on October 20, 2004, 09:38:39 am
So ImageMagick, we can't just do a command lime from config menu in Coppermine?

Where can I find a thread about the DJ Axion mod for imagemagick? The links were dead.

Thanks

And does thsi still work with 1.3?
Title: Re: Watermarking hack (w/ ImageMagick)
Post by: Joachim Müller on October 20, 2004, 10:00:40 am
all available watermarking mods are within this very sub-board named "Watermarking & image manipulation (http://forum.coppermine-gallery.net/index.php?board=33.0)". Mods that don't appear on this board are simply not there, and have never been.

Joachim
Title: Re: Watermarking hack (w/ ImageMagick)
Post by: Zeitgeist on October 20, 2004, 12:05:16 pm
Well, I just tried this and after reading reports on it not working with the recent ver of coppermine, those were dumbfounded.

I installed it with no modifications and it works perfectly.

You can see it at www.topdrunks.com
Title: Re: Watermarking hack (w/ ImageMagick)
Post by: kiig on October 20, 2004, 01:04:10 pm
yes, - it works, - but with a slight delay... I noticed it on my server, - and apparently you have it too :-), - just a small 1 second lag... but still, - it brings up the question of doing this on-the-fly, - or as a batch-job before uploading images.

Kim Igel.
Title: Re: Watermarking hack (w/ ImageMagick)
Post by: Zeitgeist on October 20, 2004, 02:32:16 pm
Yeah, I noticed the delay.

It would be cool if the script could do the commands during batch add files rather then "on the fly...." I assume it wouldn't be too much to do, but I sure as hell wouldn't know what to do ;)
Title: Re: Watermarking hack (w/ ImageMagick)
Post by: kiig on October 20, 2004, 03:09:42 pm
In another thread Gaugau suggested this :
Code: [Select]
http://www.picture-shark.com
it's free, - and apparently it build for exactly batch-adding watermarks to images... :-)

take a look ...

If your normal work-flow involves sorting the images, - maybe do some adjustment's in Photoshop using batch, - uploading to your server.. then it would be easy to 'plug in' a step along the way that watermarked everyting in a specific folder...

Kim Igel.
Title: Re: Watermarking hack (w/ ImageMagick)
Post by: LiquidLife on February 10, 2005, 03:06:35 am
I installed this and it works like a charm.

You can view my gallery here:
http://www.lifeforceliquid.com/coppermine2/

Thanks a ton!
Title: Re: Watermarking hack (w/ ImageMagick)
Post by: Joachim Müller on February 24, 2005, 01:22:38 pm
[moderation]Split unrelated posting (dealing with hosting issues) and merged it with Web Hosting for Coppermine photo Album? (http://forum.coppermine-gallery.net/index.php?topic=15187.0)[/moderation]
Title: Re: Watermarking hack (w/ ImageMagick)
Post by: fartlek on June 10, 2005, 08:06:32 pm
i got this to work on my server by replacing
Code: [Select]
<?
at the start of wm.php with
Code: [Select]
<?php
Title: Re: Watermarking hack (w/ ImageMagick)
Post by: ekleiner on January 18, 2006, 03:19:42 am
Anyone know how to do this with CPG 1.4.3?
Title: Re: Watermarking hack (w/ ImageMagick)
Post by: Joachim Müller on January 18, 2006, 09:16:33 am
http://forum.coppermine-gallery.net/index.php?topic=24540.0
Title: Re: Watermarking hack (w/ ImageMagick)
Post by: emielk on January 23, 2006, 06:56:34 pm
Hi there,

thanks GauGau for your inspiring words  ;)

I'm not a programmer but I tried to rewrite this mod for use in cpg 1.4.3 it looks like it works now see:

http://forum.coppermine-gallery.net/index.php?topic=26858.0

for more info.
Title: Re: Watermarking hack (w/ ImageMagick)
Post by: FIREBOX on March 09, 2006, 09:23:04 pm
how do you insert the imagemagick command
Title: Re: Watermarking hack (w/ ImageMagick)
Post by: Senator on March 19, 2006, 11:21:25 am
Can someone help me with a permanent watermarking, I don't now if i must use GD or imagemagick. My site is extern hosted by a hostingcompagny.

I can only make access with ftp.

How must i do that.

Title: Re: Watermarking hack (w/ ImageMagick)
Post by: Joachim Müller on March 19, 2006, 11:54:18 pm
http://coppermine-gallery.net/demo/cpg14x/docs/faq.htm#VersionGD