Jump to:

10994 Posts in 2728 Topics by 1819 members

All other Modules

SilverStripe Forums » All other Modules » Image_Gallery and watermark

Discuss all other Modules here.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 694 Views
  • CHD
    Avatar
    Community Member
    218 Posts

    Image_Gallery and watermark Link to this post

    Hi guys,

    I'm looking for the best solution to add watermarks to my image gallery: http://ace.clickheredigital.co.uk/roofing-photo-gallery/
    and my watermark is stored here: http://ace.clickheredigital.co.uk/themes/Ace/images/watermark.png

    I've read all of the related threads on here (which look great) but im not much of a developer and don't really understand where I need to put the codes...

    can anybody post a short tutorial for me?
    im working with uncle cheese's Image_gallery

    ANY help at all would be greatly appreciated.

  • CHD
    Avatar
    Community Member
    218 Posts

    Re: Image_Gallery and watermark Link to this post

    do i do something like this

       public function Watermark(GD $gd) {
       // Read the watermark picture
       $watermark = imagecreatefrompng($URL . '/themes/Ace/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;
       }

    where do i put this??

    694 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.