JBZoo\Image\Image::_loadMeta PHP Метод

_loadMeta() защищенный Метод

Get meta data of image or base64 string
protected _loadMeta ( null | string $image = null, boolean | null $strict = false )
$image null | string
$strict boolean | null
    protected function _loadMeta($image = null, $strict = false)
    {
        // Gather meta data
        if (null === $image && $this->_filename) {
            $imageInfo = getimagesize($this->_filename);
            $this->_image = $this->_imageCreate($imageInfo['mime']);
        } elseif (Helper::isGdRes($image)) {
            $this->_image = $image;
            $imageInfo = array('0' => imagesx($this->_image), '1' => imagesy($this->_image), 'mime' => 'image/png');
        } else {
            if (!Sys::isFunc('getimagesizefromstring')) {
                throw new Exception('PHP 5.4 is required to use method getimagesizefromstring');
            }
            if ($strict) {
                $cleanedString = str_replace(' ', '+', preg_replace('#^data:image/[^;]+;base64,#', '', $image));
                if (base64_decode($cleanedString, true) === false) {
                    throw new Exception('Invalid image source.');
                }
            }
            $image = Helper::strToBin($image);
            $imageInfo = getimagesizefromstring($image);
            $this->_image = imagecreatefromstring($image);
        }
        // Set internal state
        $this->_mime = $imageInfo['mime'];
        $this->_width = $imageInfo['0'];
        $this->_height = $imageInfo['1'];
        $this->_exif = $this->_getExif();
        $this->_orient = $this->_getOrientation();
        // Prepare alpha chanel
        Helper::addAlpha($this->_image);
        return $this;
    }