Page 1 of 3

watermark

Posted: Thu Apr 09, 2009 2:52 pm
by tompeterson
Hello

I want to add to my images watermark when picture is enlarged how can I do this?

can help somebody?

Re: watermark

Posted: Sat Apr 11, 2009 12:20 am
by mal-schauen
1. either DIV Overlay
2. or advance bring it manually on the images

Re: watermark

Posted: Tue Apr 14, 2009 3:28 pm
by tompeterson
But I need watermark only in picture enlarged..in popup...is it possible to create watermark by php function..and how? thanks

Re: watermark

Posted: Tue Apr 14, 2009 11:59 pm
by iloveopencart

Re: watermark

Posted: Mon May 18, 2009 8:22 pm
by tompeterson
can somebody help with script for watermarking and its adding to opencart?

Re: watermark

Posted: Mon May 18, 2009 8:29 pm
by Daniel
watermarking is already built into the image class.

Re: watermark

Posted: Mon May 18, 2009 8:56 pm
by tompeterson
Yes I find it but i don' t know how to use it

Re: watermark

Posted: Mon May 18, 2009 9:45 pm
by Daniel
$image = new Image('my_image.jpg'):
$image->watermark('watermark_image.png', 'bottomright');

You might want to use transparent png's for the watermark for the best effect.

Re: watermark

Posted: Mon May 18, 2009 9:54 pm
by tompeterson
thanks very much

Re: watermark

Posted: Tue May 19, 2009 2:42 pm
by tompeterson
i 've added this line of code
$image->watermark('watermark.png', 'bottomright');
to image.php in system / helper
but it doesn't work...

Re: watermark

Posted: Tue May 19, 2009 6:14 pm
by Daniel
did you add the exact location of the watemark image?

$image->watermark(DIR_IMAGE . 'watermark.png', 'bottomright');

Did you create a watermark image and put it in the right place?

Re: watermark

Posted: Tue May 19, 2009 6:19 pm
by tompeterson
yes watermark image is in the image folder and I try also add exact location of watermark image

Re: watermark

Posted: Tue May 19, 2009 8:56 pm
by tompeterson
this is error statement that i've got...images are in jpg format

Warning: imagecreatefromjpeg() [function.imagecreatefromjpeg]: gd-jpeg: JPEG library reports unrecoverable error: in /domains1/do1231500/public/www_root/vmshop/system/library/image.php on line 34

Warning: imagecreatefromjpeg() [function.imagecreatefromjpeg]: '/domains1/do1231500/public/www_root/vmshop/image/watermark.png' is not a valid JPEG file in /system/library/image.php on line 34

Warning: imagesx(): supplied argument is not a valid Image resource in /system/library/image.php on line 88

Warning: imagesy(): supplied argument is not a valid Image resource in /system/library/image.php on line 89

Warning: imagecopy(): supplied argument is not a valid Image resource in /system/library/image.php on line 110

Warning: imagedestroy(): supplied argument is not a valid Image resource in /system/library/image.php on line 112

Re: watermark

Posted: Thu Jun 18, 2009 12:33 am
by acidline
Hello,

You must modify the watermark method ...

Code: Select all

   public function watermark($file, $position = 'bottomright') {
	
	//Pb ! you don't work on the true object => you must modify the "create" method ($mime = $this->info['mime']; it's work only if we have the same image format !
        //$watermark = $this->create($file);

        //Prefer PNG files => it's not optimized but it's work
	$watermark = imagecreatefrompng($file);
        
        $watermark_width  = imagesx($watermark);
        $watermark_height = imagesy($watermark);

        switch($position) {
            case 'topleft':
                $watermark_pos_x = 0;
                $watermark_pos_y = 0;
                break;
            case 'topright':
                $watermark_pos_x = $this->info['width'] - $watermark_width;
                $watermark_pos_y = 0;
                break;
            case 'bottomleft':
                $watermark_pos_x = 0;
                $watermark_pos_y = $this->info['height'] - $watermark_height;
                break;
            case 'bottomright':
                $watermark_pos_x = $this->info['width'] - $watermark_width;
                $watermark_pos_y = $this->info['height'] - $watermark_height;
                break;
        }
       
        imagecopy($this->image, $watermark, $watermark_pos_x, $watermark_pos_y, 0, 0, $watermark_width, $watermark_height);
        
        imagedestroy($watermark);
    }
In your helper you can use this solution like this :

Code: Select all

$image = new Image(DIR_IMAGE . $old_image);
$image->resize($width, $height);
$image->watermark(HTTP_IMAGE . 'watermark.png', 'bottomright');
$image->save(DIR_IMAGE . $new_image);	
Nico :D

Re: watermark

Posted: Wed Jul 15, 2009 5:23 am
by itrends
Hi.

I have this working, however I was wondering if it is possible to make the watermark match the size of the image it is being put over the top of? Essentially

LARGE WATERMARK
placed over
LARGE IMAGE
then
RESIZED to the size needed


anyone that can help? I have the watermark part working fine its just the image is being resized smaller while the watermark remains full size over the top and covers half the image :)

Thanks!

Re: watermark

Posted: Wed Jul 15, 2009 5:26 am
by itrends
Also, is it possible to center it instead of using a corner?

Re: watermark

Posted: Wed Jul 15, 2009 5:32 am
by itrends
HA! I sorted both problems in 10 seconds!

For those that want to know

I changed the order from

$image = new Image(DIR_IMAGE . $old_image);
$image->resize($width, $height);
$image->watermark(HTTP_IMAGE . 'overlay.png', 'bottomright');


to


$image = new Image(DIR_IMAGE . $old_image);
$image->watermark(HTTP_IMAGE . 'overlay.png', 'bottomright');
$image->resize($width, $height);



simples :)

Re: watermark

Posted: Wed Oct 28, 2009 6:50 am
by idoso
You will get problem with " $image->watermark(HTTP_IMAGE . 'overlay.png', 'bottomright'); "
if your shared server has disabled URL access which most of them does for security reason.
use DIR_IMAGE instead of HTTP_IMAGE.

Re: watermark

Posted: Tue Nov 03, 2009 9:54 pm
by ThePath
Ive just tested this out and it works but the watermark is very small. How does one make it bigger?

Cheers

Re: watermark

Posted: Tue Nov 03, 2009 10:13 pm
by Qphoria
itrends wrote:HA! I sorted both problems in 10 seconds!

For those that want to know

I changed the order from

$image = new Image(DIR_IMAGE . $old_image);
$image->resize($width, $height);
$image->watermark(HTTP_IMAGE . 'overlay.png', 'bottomright');


to


$image = new Image(DIR_IMAGE . $old_image);
$image->watermark(HTTP_IMAGE . 'overlay.png', 'bottomright');
$image->resize($width, $height);



simples :)
I would think the first thing to "center" my watermark would be to remove "bottomright" from the parameter and replace it with something like "center"