This time to bring you Imagecopymerge () function to create a translucent watermark step in detail, imagecopymerge () function to create a translucent watermark note what, the following is the actual case, take a look.
<?php//load the image to be watermarked $im = imagecreatefromjpeg (' photo.jpeg ');//First we manually create a watermark image from GD $stamp = imagecreatetruecolor (100, 70); Imagefilledrectangle ($stamp, 0, 0, 0x0000FF), Imagefilledrectangle ($stamp, 9, 9, 0xFFFFFF), Imagestring ($ Stamp, 5, D, ' libgd ', 0x0000FF), Imagestring ($stamp, 3,, ' (c) 2007-9 ', 0x0000FF);//Set the location and size of the watermark image $marge_right = $marge _bottom = ten; $sx = Imagesx ($stamp); $sy = Imagesy ($stamp);//combine watermarks and images with 50% transparency Imagecopymerge ($im, $stamp, Imagesx ($im)-$sx-$marge _right, Imagesy ($im)-$sy-$marge _bottom, 0, 0, Imagesx ($stamp), Imagesy ($stamp), 50);//Save the image to a file and release Put memory imagepng ($im, ' photo_stamp.png '); Imagedestroy ($im);? >
Translucent watermark:
This example uses the Imagecopymerge () function to combine the watermark image with the original image. We can control the transparency of the watermark, which in this case is 50% transparency. In actual use, the use of translucent watermark can not affect the user to view the image under the premise of copyright protection.
Believe that you have read the case of this article you have mastered the method, more exciting please pay attention to the PHP Chinese network other related articles!
Recommended reading:
PHP using the foreach Transform array steps
PHP double quotes to access array elements how to handle errors