The message is a bit outdated, but if someone wants to, I just made this function
function save_image_from_64($path, $name, $dimension, $original) { header("Content-Type: image/jpeg"); list($width,$height) = explode('x',$dimension); //Getting new height and width $img = str_replace('data:image/jpeg;base64,', '', $original); //Getting the base64 image $image = imagecreatefromstring(base64_decode($img)); $new_image = imagecreatetruecolor($width, $height); imagecopyresampled($new_image, $image, 0, 0, 0, 0, $width, $height, imagesx($image), imagesy($image)); imagejpeg($new_image, $path.$name.'.jpg'); // saving the image } save_image_from_64("cdn/","test","800x200","data:image/jpeg;base64,/9j/4AAQS...");
source share