17488 Posts in 4473 Topics by 1978 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 2375 Views |
-
Watermark on uploaded image

18 May 2007 at 10:05am
Hi,
i want to add a watermark to a uploaded image. Any idea?
I have a class to watermark the image, but i can't figure it out where
to insert the watermark method.
it looks like
$thumb=new Thumbnail($filename);
$thumb->img_watermark='watermark.png';
$thumb->img_watermark_Valing='BOTTOM';
$thumb->img_watermark_Haling='RIGHT';
$thumb->process();
Where i need to insert this snippet, to add the watermark to the uploaded image
from the cms.Thanks
-
Re: Watermark on uploaded image

27 August 2008 at 2:16am
Old message, but it resembles my question.
I'd like to manipulate uploaded images myself using GD (I need to watermark them). But since the Silverstripe images are wrapped in the (silverstripe) GD class, I can't figure out where to "hook" my watermark code.
Can anyone give me some pointers ? Thanks !
-
Re: Watermark on uploaded image

13 November 2008 at 7:44pm
Also trying to do the same thing... any one know?
-
Re: Watermark on uploaded image

13 November 2008 at 8:57pm
Yeah.
I found a way to do this , but it isn't a particular elegant solution. ;-)
The trick is that in the end , you have to create a GD object Silverstripe can work with. Other than that , it is pretty much straightforward GD work.
The quality can probably be improved, and it eats quite some diskspace and processing power, but it is good enough for what we wanted to achieve.
Look at http://www.fahrenheitstore.nl for the result.
// Read the watermark picture
$watermark = imagecreatefrompng($URL . '/images/watermark.png');
$watermark_width = imagesx($watermark);
$watermark_height = imagesy($watermark);// Read Full size Silverstripe image
$imageToWatermark = imagecreatefromjpeg($this->URL);// Calculate sizes
$size = getimagesize($this->URL);
$dest_x = $size[0] - $watermark_width - 5;
$dest_y = $size[1] - $watermark_height - 5;
// Do transformations and save image in assets
imagecopymerge($imageToWatermark, $watermark, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height, 40);
imagepng($imageToWatermark,$webroot . $this->filename . "_watermarked.png");// And this is the trick ;-) Create an object Silverstripe can work with....
$GDoutput= new GD($webroot . $this->filename . "_watermarked.png");
return $GDoutput;Good luck !
| 2375 Views | ||
|
Page:
1
|
Go to Top |



