Advanced search  

News:

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

Pages: 1 [2] 3 4 5 6   Go Down

Author Topic: Watermarking hack (w/ ImageMagick)  (Read 210141 times)

0 Members and 1 Guest are viewing this topic.

flex

  • Contributor
  • Coppermine novice
  • ***
  • Offline Offline
  • Posts: 29
Watermarking hack (w/ ImageMagick)
« Reply #20 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!
Logged
jvcam.co.uk

Gaurav

  • Coppermine newbie
  • Offline Offline
  • Posts: 10
Watermarking hack (w/ ImageMagick)
« Reply #21 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 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
Logged

klaws

  • Contributor
  • Coppermine newbie
  • ***
  • Offline Offline
  • Posts: 11
seems to be a problem
« Reply #22 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?
Logged

Gaurav

  • Coppermine newbie
  • Offline Offline
  • Posts: 10
Watermarking hack (w/ ImageMagick)
« Reply #23 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
Logged

asdf

  • Guest
alpha-layer transparency
« Reply #24 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
Logged

moorey

  • VIP
  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 404
Re: alpha-layer transparency
« Reply #25 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.
Logged

mslino

  • Coppermine newbie
  • Offline Offline
  • Posts: 8
Watermark question
« Reply #26 on: January 16, 2004, 08:14:22 pm »

Hi!

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

gmarik

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 34
gif
« Reply #27 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!
Logged
webmaxtor.com

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: gif
« Reply #28 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:
Logged

Trinity

  • Coppermine newbie
  • Offline Offline
  • Posts: 8
Watermarking hack (w/ ImageMagick)
« Reply #29 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
Logged

Trinity

  • Coppermine newbie
  • Offline Offline
  • Posts: 8
Watermarking hack (w/ ImageMagick)
« Reply #30 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
Logged

fool

  • Coppermine newbie
  • Offline Offline
  • Posts: 2
    • http://www.pixpage.net
Watermarking hack (w/ ImageMagick)
« Reply #31 on: January 26, 2004, 01:33:27 pm »

hello,

mod is working fine !!

thanks for your work!

greetings fool
Logged

elderban

  • Coppermine newbie
  • Offline Offline
  • Posts: 6
Watermarking hack (w/ ImageMagick)
« Reply #32 on: February 01, 2004, 03:42:34 am »

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

comic

  • Coppermine newbie
  • Offline Offline
  • Posts: 8
Thumbnails too?
« Reply #33 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.
Logged

comic

  • Coppermine newbie
  • Offline Offline
  • Posts: 8
Re: Thumbnails too?
« Reply #34 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
Logged

doxx

  • Coppermine newbie
  • Offline Offline
  • Posts: 1
Watermarking hack (w/ ImageMagick)
« Reply #35 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
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Watermarking hack (w/ ImageMagick)
« Reply #36 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

GauGau
Logged

Trinity

  • Coppermine newbie
  • Offline Offline
  • Posts: 8
Move watermark
« Reply #37 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
Logged

FreeMail

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 67
    • http://www.myphotodb.com
Watermarking hack (w/ ImageMagick)
« Reply #38 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!
Logged

flex

  • Contributor
  • Coppermine novice
  • ***
  • Offline Offline
  • Posts: 29
Watermarking hack (w/ ImageMagick)
« Reply #39 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 :)
Logged
jvcam.co.uk
Pages: 1 [2] 3 4 5 6   Go Up
 

Page created in 0.088 seconds with 20 queries.