<?php
Ob_clean ();
Header (' content-type:image/png ');
If you have a problem and need to find a bug, put the header last
/*
$str = "1\n2\n3\n";
$im = Imagecreate (100,120);
$white = Imagecolorallocate ($im, 0xff,0xff,0xff);
Imagecolortransparent ($im, $white); Imagecolortransparent () sets the specific color to be a transparent color, if the annotation
$black = Imagecolorallocate ($im, 0x00,0x00,0x00);
Imagettftext ($im, 15,0,50,40, $black, "Simkai.ttf", $str); Font Settings section Linux and Windows may have different paths
Header ("Content-type:image/png");
Imagepng ($im);//text-generated pictures
*/
Characters
$path _1 = "Bbb.png";
Equipment picture
$path _2 = "222.png";
Take a picture of people and equipment to two canvases
$image _1 = imagecreatefrompng ($path _1);
$image _2 = imagecreatefrompng ($path _2);
Create a true color canvas that is the size of a person's picture (PS: This is the only way to ensure that the copy is not distorted when it is equipped with the image)
$image _3 = Imagecreatetruecolor (Imagesx ($image _1), Imagesy ($image _1));
Create a white background for the true color canvas and set it to transparent
$color = Imagecolorallocate ($image _3, 255, 255, 255);
Imagefill ($image _3, 0, 0, $color);
Imagecolortransparent ($image _3, $color);
First copy the character canvas to the true color canvas without distortion
Imagecopyresampled ($image _3, $image _1,0,0,0,0,imagesx ($image _1), Imagesy ($image _1), Imagesx ($image _1), Imagesy ($ Image_1));
Copy the equipment image to a true color canvas that already has a character image, without distortion
Imagecopymerge ($image _3, $image _2, 150,150,0,0,imagesx ($image _2), Imagesy ($image _2), 100);
Saves the canvas to the specified GIF file
Imagegif ($image _3);
?>
PHP text generates images and synthesizes a picture with two images