Imagecreatefromstring using an image with data: image / png; base64,

I have an image that is stored as a string that starts with:

data:image/png;base64, 

I need to convert it to a normal image in order to use it with GD.

I tried imagecreatefromstring() , but it seems to only accept images without data:image/etc pefix.

How can i do this?

+4
source share
1 answer
 $exploded = explode(',', $data, 2); // limit to 2 parts, ie: find the first comma $encoded = $exploded[1]; // pick up the 2nd part $decoded = base64_decode($encoded); $img_handler = imagecreatefromstring($decoded); 
+5
source

All Articles