How to test if a base64 string is a valid image in PHP?
I tried the following code:
function convertAndSaveLogo($data, $id){
        if(isset($data->base64_image) && $data->base64_image){
            $imageData = base64_decode($data->base64_image);
            if($imageData){
                $source = imagecreatefromstring($imageData);
                if($source){
                    imagepng($source, getcwd()."../dir/image/".$id.".png", 5);
                    imagedestroy($source);
                }
            }
        }
    }
But it is not working.
 
    