Jump to:

10850 Posts in 2517 Topics by 1793 members

All other Modules

SilverStripe Forums » All other Modules » ImageGallery and Watermark

Discuss all other Modules here.

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

Page: 1
Go to End
Author Topic: 2191 Views
  • alexanm
    Avatar
    Community Member
    38 Posts

    ImageGallery and Watermark Link to this post

    Hello UncleCheese,

    is there a way to extend the existing image gallery, oder even the image upload field to add a watermark to each photo when it has been uploaded? That would preserve me from much work, when this can be done in the process of uploading...

    TIA
    Markus Alexander

  • UncleCheese
    Avatar
    4085 Posts

    Re: ImageGallery and Watermark Link to this post

    I'm sure there is. Plenty of sites do it, but it's complex work with the GD library. You might be able to find an open-source PHP class that does it for you.

  • Fuzz10
    Avatar
    Community Member
    786 Posts

    Re: ImageGallery and Watermark Link to this post

    did you search the forum ? I posted a (non-elegant) piece of code for that.....

    http://www.silverstripe.org/archive/show/1144

  • Brady.Dyer
    Avatar
    Community Member
    21 Posts

    Re: ImageGallery and Watermark Link to this post

    Hey Fuzz10,
    I am struggling to implement it into my website... I am wanting to make it add the watermark to all the large images (not the thumbnails)

    Do I add that function into the page control for the gallery page? or into the gd.php file?
    How do I call it on the page?

    Thanks HEAPS for your help!

    If you're too busy to explain it, if you just sent me the pages involved I'll be able to work the rest out me@bradydyer.com

    Cheers!

  • Fuzz10
    Avatar
    Community Member
    786 Posts

    Re: ImageGallery and Watermark Link to this post

    Brady,

    Basically , what you want to do is extend the Image class and use that class to add images to your pages.

    For more information : check out
    http://silverstripe.org/template-questions/show/256484
    http://silverstripe.org/template-questions/show/256331
    http://silverstripe.org/customising-the-cms/show/257710

    You can add the new watermark code to the image class as well..... Good luck !

  • CHD
    Avatar
    Community Member
    217 Posts

    Re: ImageGallery and Watermark Link to this post

    can anybody shed any more light on this?
    im struggling to work out where to actually put the code.

    im working with Uncle Cheese's Image_gallery.

    do i apply the watermark when images are UPLOADED via the CMS, or is it when they are RENDERED?

    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;
       }

    2191 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.