I've an image stored as string that starts with:
data:image/png;base64,
I need to convert it to a normal image for use it with GD.
I tried imagecreatefromstring()
but it seems to accept only images without the data:image/etc
pefix.
How can I do?
$exploded = explode(',', $data, 2); // limit to 2 parts, i.e: find the first comma
$encoded = $exploded[1]; // pick up the 2nd part
$decoded = base64_decode($encoded);
$img_handler = imagecreatefromstring($decoded);
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.