thinkphp5的缩略图演示

浏览:5365 发布日期:2016/06/13 分类:ThinkPHP5专区 关键字: thinkphp缩略图,缩略图
public function get_thumb($file,$type=true){
        if(is_file('.'.$file)){
            $image = \org\Image::init();
            $image->open('.'.$file);  //打开图片

            //组合缩略图路径
            if($type){
                $width = config('thumb_width');
                $height = config('thumb_height');
            }else{
                $width = config('product_width');
                $height = config('product_height');
            }
            //单独使用必须保存在已经有的目录中,目前不会自动创建目录
            $thumb = './attachment/'.date('Y-m-d').'/thumb'.$width.$height.time().'==.jpg';
            $image->thumb($width,$height)->save($thumb);
            return $thumb;
        }
    }
错误提示:imagejpeg(./attachement/20160613/thumb5804001465785620==.jpg): failed to open stream: No such file or directory
最佳答案
评论( 相关
后面还有条评论,点击查看>>