Advanced search  

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

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

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

0 Members and 1 Guest are viewing this topic.

comic

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

flex

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

comic

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

Joachim Müller

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

comic

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

flex

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

comic

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

flex

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

FreeMail

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 67
    • http://www.myphotodb.com
Watermarking hack (w/ ImageMagick)
« Reply #48 on: March 04, 2004, 12:18:58 pm »

any tip on how to create our own watermark text or graphics?  via photoshop.


tia!
Logged

golf16vkr

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 28
Watermarking hack (w/ ImageMagick)
« Reply #49 on: March 04, 2004, 01:27:01 pm »

Thanks this hack worked excellent for me
Logged

FreeMail

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

flex

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

flex

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

FreeMail

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

flex

  • Contributor
  • Coppermine novice
  • ***
  • Offline Offline
  • Posts: 29
Watermarking hack (w/ ImageMagick)
« Reply #54 on: March 04, 2004, 03:19:02 pm »

functions.inc.php is the file u should edit
Logged
jvcam.co.uk

FreeMail

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 67
    • http://www.myphotodb.com
Watermarking hack (w/ ImageMagick)
« Reply #55 on: March 04, 2004, 03:29:00 pm »

ok, thanks a lot! wish me luck!
Logged

FreeMail

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

flex

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

FreeMail

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 67
    • http://www.myphotodb.com
Watermarking hack (w/ ImageMagick)
« Reply #58 on: March 04, 2004, 03:46:12 pm »

my index.php page is working already, but clicking the normal picutre give my a X.
Logged

bshrdr

  • Coppermine newbie
  • Offline Offline
  • Posts: 1
    • http://www.railfanzone.com
Watermark with text instead of PNG
« Reply #59 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
Logged
Pages: 1 2 [3] 4 5 6   Go Up
 

Page created in 0.034 seconds with 20 queries.