GD function merging image problem (one jpg, one png) RT: How can I synthesize two images using php? One is a png & nbsp; transparent basemap, and the other is a jpg & nbsp; image. now we want to make the jpg image synthetic to the png basemap and become a new image, how to implement it? In addition, I would like to ask if the synthesized image requires GD function to synthesize the image (one jpg and one png)
RT:
How can I use php to synthesize two images?
One is a png transparent basemap and the other is a jpg image.
Now, how can I merge jpg images into a png basemap and create a new image?
In addition, is the size of the synthesized image the same as that of the image? Or can the basemap be larger?
I also found some methods on the Internet, but none of them seem to work.
$path_1 = "topic_assets/522592b5d61cb_ip4.jpg";
$path_2 = "topic_assets/topic_border_android.png";
//echo $path_1;
$image=imagecreatefromjpeg($path_1);
$wm=imagecreatefrompng($path_2);
$im=imagecreatetruecolor(imagesx($image),imagesy($image));
imagecopy($im,$image,0,0,0,0,imagesx($image),imagesy($image));
imagecopy($im,$wm,0,0,0,0,imagesx($wm),imagesy($wm));
If you have done something similar, give a solution... share it:
------ Solution --------------------
GD provides many functions. you have to try them all! How about this?
$t1 = 'http://avatar.csdn.net/1/C/9/1_mahuatengbc.jpg';
$t2 = 'http://avatar.csdn.net/2/5/B/1_yykr1987.jpg';
$im1 = imagecreatefromjpeg($t1);
$im2 = imagecreatefromjpeg($t2);
imagecopymerge($im1, $im2, 35, 5, 0, 0, imagesx($im2), imagesy($im2), 63);
imagejpeg($im1);