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);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With