Think/Image/Driver/Gd.php
public function open($imgname)
    {
        //检测图像文件
        if (!is_file($imgname)) {
            throw new BaseException('不存在的图像文件');
        }

        //获取图像信息
        $_info = getimagesize($imgname);

        //检测图像合法性
        if (false === $_info || (IMAGETYPE_GIF === $_info[2] && empty($_info['bits']))) {
            throw new BaseException('非法图像文件');
        }

        //设置图像信息
        $this->info = [
            'width'  => $_info[0],
            'height' => $_info[1],
            'type'   => image_type_to_extension($_info[2], false),
            'mime'   => $_info['mime'],
        ];

        //销毁已存在的图像
        empty($this->img) || imagedestroy($this->img);

        //打开图像
        //@todo gif支持
        if ('gif' == $this->info['type']) {
            $class = 'Think\\Image\\Driver\\GIF';
            $this->gif = new $class($imgname);
            $this->img = imagecreatefromstring($this->gif->image());
        } else {
            $fun = "imagecreatefrom{$this->info['type']}";
            $this->img = $fun($imgname);
        }
    }
public function open($imgname)
    {
        //检测图像文件
        if (!is_file($imgname)) {
            throw new BaseException('不存在的图像文件');
        }

        //获取图像信息
        $_info = getimagesize($imgname);

        //检测图像合法性
        if (false === $_info || (IMAGETYPE_GIF === $_info[2] && empty($_info['bits']))) {
            throw new BaseException('非法图像文件');
        }

        //设置图像信息
        $this->info = [
            'width'  => $_info[0],
            'height' => $_info[1],
            'type'   => image_type_to_extension($_info[2], false),
            'mime'   => $_info['mime'],
        ];

        //销毁已存在的图像
        empty($this->img) || imagedestroy($this->img);

        //打开图像
        //@todo gif支持
        if ('gif' == $this->info['type']) {
            $class = 'Think\\Image\\Driver\\GIF';
            $this->gif = new $class($imgname);
            $this->img = imagecreatefromstring($this->gif->image());
        } else {
            $fun = "imagecreatefrom{$this->info['type']}";
            $this->img = $fun($imgname);
        }
    }
打开一张图像

@param  string $imgname 图像路径
@throws BaseException