How can I add an image onto an image in PHP like a watermark

前端 未结 2 1935
盖世英雄少女心
盖世英雄少女心 2020-12-11 11:44

I am trying to write a small php function to take an image and apply a watermark type image on top of the image and them save them as 1 image, this code runs with 0 errors b

2条回答
  •  醉话见心
    2020-12-11 12:18

    I think you need to change this (here is a simple tutorial http://www.cafewebmaster.com/image-watermark-php):

    //Add watermark to the image
    if (!(imagecopy($image, $watermark, $watermark_x, $watermark_y, 0, 0, $watermark_w,
        $watermark_h)))
    

    with:

    //Add watermark to the image
    if (!(imagecopymerge($image, $watermark, $watermark_x, $watermark_y, 0, 0, $watermark_w,
        $watermark_h, 100)))
    

    or use wideImage ;)

提交回复
热议问题