Home > Backend Development > PHP Tutorial > 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
Release: 2016-08-04 09:20:36
Original
1012 people have browsed it

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

<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的颜色
</code>
Copy after login
Copy after login

AB

Reply content:

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

<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的颜色
</code>
Copy after login
Copy after login

AB

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

Related labels:
php
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template