Watermarking hack (w/ ImageMagick) - Page 2 Watermarking hack (w/ ImageMagick) - Page 2
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

Watermarking hack (w/ ImageMagick)

Started by flex, November 10, 2003, 11:50:10 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

flex

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!

Gaurav

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 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

klaws

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?

Gaurav

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

asdf

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

moorey

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.

mslino

Hi!

How can add a watermark for each user a have using gallery? Is it possible?

gmarik

does any of you had problems configuring Image Magick to read gif's - it just doent accepts them!

Joachim Müller

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:

Trinity

I get some photos not showing as well... it seems as if it loses them at times depending on how you move around.

Strange

Trinity

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:

return $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
                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:

<?
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

fool

hello,

mod is working fine !!

thanks for your work!

greetings fool

elderban

Got it to work great for me! Thanks for the hack!   :D

comic

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.

comic

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

doxx

hello, I applied the hack exactly as described (CP 1.1.0)
and this happens

QuoteParse 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

Joachim Müller

the parse error indicates that you didn't apply the mod as suggested, see faq: common php errors

GauGau

Trinity

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

FreeMail

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!

flex

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:


$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 :)