Home  >  Article  >  Backend Development  >  php splice pictures and keep the previous color of the previous picture

php splice pictures and keep the previous color of the previous picture

WBOY
WBOYOriginal
2016-08-04 09:20:36916browse

I have a function to splice two pictures. Here is my code

    $im     = imagecreatefrompng("images/err.png");
    $stamp = imagecreatefrompng('images/default.png');
    $test = imagecreate(imagesx($stamp)+imagesx($im),imagesy($im));
    $orange = imagecolorallocate($test, 255, 255, 255);
   // image
    imagecopy($test, $stamp, 0, 0, 0, 0, imagesx($stamp), imagesy($stamp));
    imagecopy($test, $im, imagesx($stamp), 0, 10, 0, imagesx($im), imagesy($im));
    header("Content-type: image/png");
    imagepng($test);
    最终的结果是 第二个拼接的图片的颜色都会跟着第一个变化 因为传不上图片只能文字描述下面假如AB是拼接好的图片 有A和B拼接成 B的颜色本来是红色但是拼接完成之后B的颜色会变成A的颜色

AB

Reply content:

I have a function to splice two pictures. Here is my code

    $im     = imagecreatefrompng("images/err.png");
    $stamp = imagecreatefrompng('images/default.png');
    $test = imagecreate(imagesx($stamp)+imagesx($im),imagesy($im));
    $orange = imagecolorallocate($test, 255, 255, 255);
   // image
    imagecopy($test, $stamp, 0, 0, 0, 0, imagesx($stamp), imagesy($stamp));
    imagecopy($test, $im, imagesx($stamp), 0, 10, 0, imagesx($im), imagesy($im));
    header("Content-type: image/png");
    imagepng($test);
    最终的结果是 第二个拼接的图片的颜色都会跟着第一个变化 因为传不上图片只能文字描述下面假如AB是拼接好的图片 有A和B拼接成 B的颜色本来是红色但是拼接完成之后B的颜色会变成A的颜色

AB

The picture is invisible, please do not put the picture in the code view.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn