Many websites add, during the conversion from .jpg / .png to base64 some words before the base64 string : "data:image/png;base64,"
If you let them, the PHP function will return an error "Data is not in a recognized format in".
If you have this situation :
$image_string=str_replace("data:image/png;base64,","",$image_string);
$image_string = base64_decode($image_string);
$img = imagecreatefromstring($image_string);