phMagick :: Watermarks
It's easy to add watermarks to an image, you can set the postion and opacity of the overlaped image
I've seen a lot of confusion with this function, you need specify 3 files :
- The source and destination in phMagick constructor
- The watermark image (the first parameter in the function) this will be the image that will be placed above the source imace
Function reference
$phMagick->watermark($image_to_use_as_watermark, $watermark_placement, $opacity);
Watermarks examples
From an existing image
$phMagick = &new phMagick('original.png', 'destination.png'); $phMagick->watermark('watermark-source.png', phMagickGravity::Center, 60);
| Original Image | Watermark Source | Result |
![]() |
![]() |
![]() |
Draw text and use it as watermark
//adding text format $format = new phMagickTextObject(); $format->fontSize(10) ->font('Arial.ttf') ->color('#000') ->background('#f0f0f0'); //creating an image that will serve as watermak source $phMagick = &new phMagick('', 'wm_text.png'); $phMagick->fromString(html_entity_decode('© francodacosta.com'), $format); //watermarking image $phMagick = &new phMagick('original.png', 'watermark.png'); $phMagick->watermark('wm_text.png', phMagickGravity::NorthEast, 50);
| Original Image | Watermark Source | Result |
![]() |
![]() |
![]() |
A more complex example
$format = new phMagickTextObject(); $format->fontSize(12) ->font('Arial.ttf') ->color('#000') ->background('none') ; $phMagick = &new phMagick('', 'wm_text1.png'); $phMagick->debug = true ; $phMagick->fromString(html_entity_decode('© francodacosta.com '), $format) ->rotate(-45); //rotating text 45 degrees $phMagick = &new phMagick('resize_porp_wh.png', 'watermark3.png'); $phMagick->watermark('wm_text1.png', phMagickGravity::Center,70);
| Original Image | Watermark Source | Result |
![]() |
![]() |
![]() |






