Snippets - Watermark

Snippets index page

NOTE: Most of the IM snippets have been tested on IM version 6.3.5 There may be some differences if you are using the code on other versions.

Watermark an animated gif - Anthony 15/6/2008

Watermark every frame of an animated gif.

  1. <?php
  2. //This will save the watermarked image
  3. $animation "original.gif";
  4. $watermark "watermark.png";
  5. $cmd "$animation -coalesce -gravity Center -geometry +0+0 
  6. null: $watermark -layers composite -layers optimize";
  7. exec(convert $cmd output.gif);
  8. // This will watermak on the fly but the code is saved on a page of its own and called using the image tags with its page name.
  9. $animation "original.gif";
  10. $watermark "watermark.png";
  11. $cmd "convert $animation -coalesce -gravity Center -geometry +0+0 
  12. null: $watermark -layers composite -layers optimize GIF:-";
  13. header("Content-type: image/gif");
  14. passthru($cmd$retval);
  15. ?>

For more examples and information check out the main Imagemagick section.

Image watermark View

Multiple image watermarks View

Rotated transparent text View

Transparent text View

Watermark an animated gif View

Watermark text and shadow View

Watermark tiled text View