SimpleImage::load_base64 PHP Method

load_base64() public method

Load a base64 string as image
public load_base64 ( $base64string ) : SimpleImage
return SimpleImage
    function load_base64($base64string)
    {
        if (!extension_loaded('gd')) {
            throw new Exception('Required extension GD is not loaded.');
        }
        //remove data URI scheme and spaces from base64 string then decode it
        $this->imagestring = base64_decode(str_replace(' ', '+', preg_replace('#^data:image/[^;]+;base64,#', '', $base64string)));
        $this->image = imagecreatefromstring($this->imagestring);
        return $this->get_meta_data();
    }