Composite with tile (watermark)
Posted: 2009-01-25T18:24:48-07:00
Hey,
I'm trying to do a simple watermarking script, so I can secure images on my site from stealing.
Here is a site with the effect I would like to achieve: http://www.selonen.org/arto/netbsd/watermarks.html
He's using:
How can I get the same result with PHP?
I created a PNG transparent image on my own, but can't tile it on the original image.
Thanks in advance
Regards
Pacio
*EDIT*
How I solved it:
I had to change PNG layer opacity to about 30%.
I'm trying to do a simple watermarking script, so I can secure images on my site from stealing.
Here is a site with the effect I would like to achieve: http://www.selonen.org/arto/netbsd/watermarks.html
He's using:
Code: Select all
composite -dissolve 15 -tile watermark.png src.jpg dst.jpg
I created a PNG transparent image on my own, but can't tile it on the original image.
Thanks in advance
Regards
Pacio
*EDIT*
How I solved it:
Code: Select all
$main = new Imagick('src.jpg');
$watermark = new Imagick('watermark.png');
$watermark_width = $watermark->getImageWidth();
$watermark_height = $watermark->getImageHeight();
$rows = ceil($main->getImageWidth() / $watermark_width);
$cols = ceil($main->getImageHeight() / $watermark_height);
for ( $w=0; $w <= $rows; $w++ ) {
for ( $h=0; $h <= $cols; $h++ ) {
$main->compositeImage($watermark, imagick::COMPOSITE_DEFAULT, $w*$watermark_width, $h*$watermark_height);
}
}
$main->writeImage('dst.jpg');