This works:
$img = imagecreatefromstring(base64_decode(str_replace('data:image/png;base64,', '', $image)));
$width = imagesx($img);
$height = imagesy($img);
$output = imagecreatetruecolor($width, $height);
$white = imagecolorallocate($output, 255, 255, 255);
imagefilledrectangle($output, 0, 0, $width, $height, $white);
imagecopy($output, $img, 0, 0, 0, 0, $width, $height);
imagejpeg($output, './'.$filename);
echo $filename;
But I want to add a background image under this image, what I searched maybe using imagecreatefromjpeg("bg.png")
but how can I achieve?
Here is a example how to use it:
http://php.net/manual/en/image.examples.merged-watermark.php
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.