xref: /imagick/examples/watermark.php (revision 228c6a93)
1<?php
2
3/*
4	Simple example of watermarking
5*/
6
7/* Create Imagick object */
8$Imagick = new Imagick();
9
10/* Create a drawing object and set the font size */
11$ImagickDraw = new ImagickDraw();
12$ImagickDraw->setFontSize( 50 );
13
14/* Read image into object*/
15$Imagick->readImage( '/tmp/test.jpg' );
16
17/* Seek the place for the text */
18$ImagickDraw->setGravity( Imagick::GRAVITY_CENTER );
19
20/* Write the text on the image */
21$Imagick->annotateImage( $ImagickDraw, 4, 20, 0, "Test Watermark" );
22
23/* Set format to png */
24$Imagick->setImageFormat( 'png' );
25
26/* Output */
27header( "Content-Type: image/{$Imagick->getImageFormat()}" );
28echo $Imagick->getImageBlob();
29
30?>