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

Author Topic: Watermarking MOD with ImageMagick for cpg 1.4.x  (Read 42912 times)

0 Members and 1 Guest are viewing this topic.

emielk

  • Coppermine newbie
  • Offline Offline
  • Gender: Male
  • Posts: 4
Watermarking MOD with ImageMagick for cpg 1.4.x
« on: January 23, 2006, 04:54:03 pm »

Hi there,

I always used the watermarking hack from flex: http://forum.coppermine-gallery.net/index.php?topic=1467.0

Thank you flex for this hack!

This one did not work in coppermine version 1.4.3 anymore.

I looked through the code and I found the place where you should place the modifications. So here is the posting again with the modifications for 1.4.3

Step 1. includes/functions.inc.php


Find this line in the script:

(line 1985)

Code: [Select]
$filepathname = $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
               $filepathname = "wm.php?pid=".$pic_row["pid"]."&mode=".$mode;

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

        }


Step 2. Create a new file in the coppermine root dir called wm.php:




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 mine (or actually my girlfriend her watermark) from here:
http://www.vankalken.net/gallery/watermark.png

Remember to edit it first ;)

And put it in your root coppermine directory.

Remember I'm not a PHP programmer, I can read the code, but not create new code   :P

Regards,

Emiel from the Netherlands

http://www.vankalken.net/gallery

« Last Edit: May 31, 2006, 08:06:18 am by GauGau »
Logged

Zeitgeist

  • Coppermine regular visitor
  • **
  • Country: 00
  • Offline Offline
  • Gender: Male
  • Posts: 71
Re: Watermarking MOD with ImageMagick for cpg 1.4.3
« Reply #1 on: February 22, 2006, 01:28:06 am »

Good Job, I used this on 1.3 and this works just as great.

Another useful and simple modification would be to have different watermarks for the intermediate and full sized pictures.

To do this simply change the functions.inc.php code to as follows:
Code: [Select]
        if(($mode == "fullsize") && ($CONFIG['thumb_method']=='im')){

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

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

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

}else{

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

        }

Then copy wm.php to wm2.php and change the filename of the png in wm2.php. And that's about it for my elite coding skills...
« Last Edit: February 22, 2006, 05:21:25 am by Zeitgeist »
Logged
I love GauGau!

Skully1

  • Coppermine newbie
  • Offline Offline
  • Posts: 9
    • Insanebunkers
Re: Watermarking MOD with ImageMagick for cpg 1.4.3
« Reply #2 on: February 23, 2006, 03:45:45 am »

Hi all,
I found that while the MOD works awesome for images, it locks up video and audio from playing.

I've further modified the code.  It excludes non-images from being unnecessarily watermarked.

Code: [Select]

if(($mode == "fullsize") && ($CONFIG['thumb_method']=='im') && ($mime_content['content'] == 'image' )){

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

        }else if((($mode == "normal")) && ($CONFIG['thumb_method']=='im') && ($mime_content['content'] == 'image')){

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

}else{
               
                        // it's a thumb, don't bother wm'ing
        $filepathname = $url_prefix[$pic_row['url_prefix']]. path2url($pic_row['filepath']. $pic_prefix[$mode]. $pic_row['filename']);
        }
« Last Edit: February 23, 2006, 02:06:37 pm by Skully1 »
Logged

BeEbAcK

  • Coppermine newbie
  • Offline Offline
  • Posts: 2
Re: Watermarking MOD with ImageMagick for cpg 1.4.3
« Reply #3 on: May 08, 2006, 08:09:42 pm »

well i tryed emielk step-by-step ... and watermark isnt showing... i even for test tryed to use his and notnig :<  where did i go wrong :<

Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47844
  • aka "GauGau"
    • gaugau.de
Re: Watermarking MOD with ImageMagick for cpg 1.4.3
« Reply #4 on: May 09, 2006, 05:55:21 am »

impossible to say without being able to look at your changes and not even a link to your site ::). Do you actually have ImageMagick? Did you try the (more popular) watermarking mod posted by Stramm?
Logged

mukoh

  • Coppermine newbie
  • Offline Offline
  • Posts: 14
Re: Watermarking MOD with ImageMagick for cpg 1.4.3
« Reply #5 on: May 30, 2006, 07:40:17 pm »

Will this work with 1.4.6?
Logged

Tranz

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Gender: Female
  • Posts: 6149
Re: Watermarking MOD with ImageMagick for cpg 1.4.3
« Reply #6 on: May 31, 2006, 05:38:57 am »

It's marked 1.4.x, x meaning any number.
Logged

zenith

  • Coppermine newbie
  • Offline Offline
  • Posts: 10
Re: Watermarking MOD with ImageMagick for cpg 1.4.x
« Reply #7 on: June 20, 2006, 04:27:30 pm »


wm.php sets the image's filename to "file.jpg".
Is there any way to change this so that the original file name comes up when a user tries to save the image?

regards,
zenith.
Logged

zenith

  • Coppermine newbie
  • Offline Offline
  • Posts: 10
Re: Watermarking MOD with ImageMagick for cpg 1.4.x
« Reply #8 on: June 21, 2006, 08:55:30 pm »


Worked it out.

had to move the header section further down to after where $row is set. Then replace "file.jpg" with the variable $row["filename"].

Code now looks like this:
Code: [Select]
<?
define('IN_COPPERMINE', true);
require('include/init.inc.php');


$pid = $_REQUEST["pid"];
$mode = $_REQUEST["mode"];

$sql = "SELECT * FROM ".$CONFIG['TABLE_PREFIX']."pictures WHERE pid=$pid";
$db = mysql_connect($CONFIG['dbserver'], $CONFIG['dbuser'], $CONFIG['dbpass']);
mysql_select_db($CONFIG['dbname'], $db);


$result = mysql_query($sql, $db);
$row = mysql_fetch_array($result);

$pic_prefix = array(
   'thumb' => $CONFIG['thumb_pfx'],
   'normal' => $CONFIG['normal_pfx'],
   'fullsize' => ''
);

header('Content-Type: image/jpeg');
header("Content-Disposition: inline; filename=".($row["filename"]).";");

$cmd = "{$CONFIG['impath']}composite -compose over -gravity SouthEast \"".realpath("./watermark.png")."\" \"".realpath('./'.$CONFIG

["fullpath"].$row["filepath"].$pic_prefix[$mode].$row["filename"])."\" jpg:-";

passthru ($cmd, $output);

echo $output;

?>

Hope it helps someone.

Zenith.


Logged

debragrant

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 127
Re: Watermarking MOD with ImageMagick for cpg 1.4.x
« Reply #9 on: July 16, 2006, 09:00:37 pm »

Quote
".realpath("./watermark.png")


is that where I place thecomplete path to the watermark? anywhere else?
Logged

Zarzal

  • Coppermine novice
  • *
  • Country: 00
  • Offline Offline
  • Gender: Male
  • Posts: 40
Re: Watermarking MOD with ImageMagick for cpg 1.4.x
« Reply #10 on: October 17, 2006, 11:35:12 pm »

Anyone try this in 1.4.9? It seems to me that this is the only on-the-fly mod without touching the files. All other hacks modify the source.
Logged

mattocean

  • Coppermine newbie
  • Offline Offline
  • Posts: 11
Re: Watermarking MOD with ImageMagick for cpg 1.4.x
« Reply #11 on: November 06, 2006, 09:16:18 am »

Hi,

I am new here and would like to ask the experts: do I need ImageMagick for watermark the uploaded images? Is it possible to watermark the images something else?

Thanks ;)
Logged

Stramm

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Gender: Male
  • Posts: 6006
    • Bettis Wollwelt
Re: Watermarking MOD with ImageMagick for cpg 1.4.x
« Reply #12 on: November 06, 2006, 09:21:04 am »

this mod requires ImageMagick as you can read in the topics subject

GigaPixel

  • Coppermine newbie
  • Offline Offline
  • Posts: 11
Re: Watermarking MOD with ImageMagick for cpg 1.4.x
« Reply #13 on: November 08, 2006, 03:44:37 pm »

Thankyou very much emielk.

I couldn't get Flex's original MOD to work because I think includes/functions.inc.php is quite different in later versions. i.e. the line that needs to be ammended is not at the end of the script.

So I can confirm that your version of this Watermark MOD works perfectly with:

Coppermine version 1.4.10.
ImageMagick-6.2.5.4
php-5.1.4-1
mysql-5.0.18-2.1

on Fedora Core 5

Thanks very much, Ben.
 
Logged

joel2280

  • Coppermine newbie
  • Offline Offline
  • Posts: 3
Re: Watermarking MOD with ImageMagick for cpg 1.4.x
« Reply #14 on: February 27, 2007, 09:39:22 pm »

I love this mod...its cool and simple I have A problem though.

It only works with image magic.....
is there a way to get it to work with GD version 1 or 2??

When I have Image magic turned on it wont let me upload so I have to use GD.....

Please help!!
Ive been up for 16 hours triing to get this up and running smoothly.:o :o

Thanks!!  ;D ;D
Logged

joel2280

  • Coppermine newbie
  • Offline Offline
  • Posts: 3
Re: Watermarking MOD with ImageMagick for cpg 1.4.x
« Reply #15 on: February 27, 2007, 10:02:33 pm »

Im using coppermine 1.4.10 ..........and this is whats going on..... does anyone have a fix for it?

 I can only upload images with images with GD, and with image magic it wont let me upload.....
is there a way to get this mod to work with GD version 1 or 2??


or is there a way I can upload using image magic.
this is the only mod I'm running....I don't know whats wrong?

can anyone help??
Logged

Nibbler

  • Guest
Re: Watermarking MOD with ImageMagick for cpg 1.4.x
« Reply #16 on: February 27, 2007, 10:04:07 pm »

Either get imagemagick installed or rewrite the mod for GD2.
Logged

joel2280

  • Coppermine newbie
  • Offline Offline
  • Posts: 3
Re: Watermarking MOD with ImageMagick for cpg 1.4.x
« Reply #17 on: February 27, 2007, 10:25:47 pm »

I have image magic installed......when I have it turned on and I try to upload a file I get this message....
The previous file could not be placed. You have successfully placed all the files. (so it wont let me upload).

It did work for a while but then started doing that..... while it was working the watermark mod worked great.

So I turn on GD version 1 or 2 in config so I could upload again(now I can upload without any probs)...but now the watermark mod doesnt work.....arrrrrg pulling my hair out!!!

can anyone help???

Im running version 1.4.10
Logged

Nibbler

  • Guest
Re: Watermarking MOD with ImageMagick for cpg 1.4.x
« Reply #18 on: February 27, 2007, 10:26:47 pm »

Post on the upload troubleshooting board after reading the upload troubleshooting guide.
Logged

PirateZipp

  • Coppermine novice
  • *
  • Offline Offline
  • Gender: Male
  • Posts: 34
  • Hotimage.dk
    • HotImage
Re: Watermarking MOD with ImageMagick for cpg 1.4.x
« Reply #19 on: March 12, 2007, 10:34:26 am »

Hey.. im thinking of whis program to edit the .png in??

if i try edit it in paint the text is only a black line...

Thx.

Sry for my bad english..
Sebastian
(denmark)
Logged
.
Pages: [1] 2   Go Up
 

Page created in 0.038 seconds with 20 queries.