Rt:
How can you synthesize two pictures with PHP?
One is a PNG transparent basemap and the other is a JPG image
Now you want to make the JPG image into a PNG basemap, as a new picture, how to do it?
Also asked, is not the composition of the picture to size as large? Or can the Basemap be bigger?
I have found some methods on the Internet, but I can't seem to.
$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));
have done the same, give a solution ...
Reply to discussion (solution)
GD provides a lot of functions, you have to try it! Like how about this?
$t 1 = ' http://avatar.csdn.net/1/C/9/1_mahuatengbc.jpg '; $t 2 = ' http://avatar.csdn.net/2/5/B/1_yykr1987.jpg '; $im 1 = Imagecreatefromjpeg ($t 1); $im 2 = Imagecreatefromjpeg ($t 2); Imagecopymerge ($im 1, $im 2,, 5, 0, 0, Imagesx ($im 2), Imagesy ($im 2), imagejpeg ($im 1);
GD provides a lot of functions, you have to try it! Like how about this?
$t 1 = ' http://avatar.csdn.net/1/C/9/1_mahuatengbc.jpg '; $t 2 = ' http://avatar.csdn.net/2/5/B/1_yykr1987.jpg '; $im 1 = Imagecreatefromjpeg ($t 1); $im 2 = Imagecreatefromjpeg ($t 2); Imagecopymerge ($im 1, $im 2,, 5, 0, 0, Imagesx ($im 2), Imagesy ($im 2), imagejpeg ($im 1);
Thank you moderator, I first try!
Emma, I'm freaking out!
My request is a JPG, a PNG, PNG to do the basemap, the composition is also PNG format!
In accordance with the practice of the moderator, there have been a lot of strange garbled, such as
My code is like this:
$path _1 = "522592b5d61cb_ip4.jpg"; $path _2 = "Topic_border_android.png"; $im 1 = imagecreatefromjpeg ($path _1); $im 2 = Imagecreatefrompng ($path _2); Imagecopymerge ($im 1, $im 2, 5, 0, 0, Imagesx ($im 2), Imagesy ($im 2), 2); Imagedestroy ($im 2);
Don't know where the problem is ....
Emma, I'm freaking out!
My request is a JPG, a PNG, PNG to do the basemap, the composition is also PNG format!
In accordance with the practice of the moderator, there have been a lot of strange garbled, such as
My code is like this:
$path _1 = "522592b5d61cb_ip4.jpg"; $path _2 = "Topic_border_android.png"; $im 1 = imagecreatefromjpeg ($path _1); $im 2 = Imagecreatefrompng ($path _2); Imagecopymerge ($im 1, $im 2, 5, 0, 0, Imagesx ($im 2), Imagesy ($im 2), 2); Imagedestroy ($im 2);
Don't know where the problem is ....
Imagejpeg produces a JPG-formatted picture. Imgpng generated is the PNG format of the picture.
Your reason for the "strange" code is because it is not added to the header, so it is directly output as a binary data.
Prefix with header ("Content-type:image/png");
Then create the picture with Imgpng.
Nor necessarily
may also be the relationship of BOM header
Thanks for the upstairs, but the picture hasn't been saved?
I just see this picture in the browser, but I want to find this picture in the folder, there is no, is a composite picture, can't save it?
And there is a black shadow behind this picture, this can be removed!
Imagejpeg ($im 2, ' picture filename ');
Header ("Content-type:image/png"); Synthesize two pictures $targetFileDark = "522ec9db6b46b"; $dest = imagecreatefrompng (' topic_border_android.png '); $src = Imagecreatefromjpeg ($targetFileDark. " _ip4.jpg "); $newim = Imagecreatetruecolor (103,92); $back = Imagecolorallocatealpha ($newim, 0, 0, 0, 127); Imagefilledrectangle ($src, 0, 0, 98, $back), Imagealphablending ($dest, false); Imagesavealpha ($dest, true); Imagecopymerge ($dest, $SRC, 36,11,0,0,imagesx ($SRC), Imagesy ($SRC), Imagepng ($dest, $targetFileDark. " _android.png "); Imagedestroy ($dest); Imagedestroy ($SRC);
I studied it yesterday afternoon and finally got it done.