class File
{
static function image($file)
{
validate(['image'=>'fileSize:5242880|fileExt:jpg'])
->check(['image'=>$file]);
$savename = \think\facade\Filesystem::disk('public')->putFile( '/topic', $file);
$path=date('Ymd').md5(rand(1111,9999)).'.jpg';
$image = \think\Image::open($file);
// 给原图左上角添加水印并保存water_image.png
$image->text('十年磨一剑 - 为API开发设计的高性能框架',getcwd().'./static/1.ttf',20,'#ffffff')->save('./water/'.$path);
$image = \think\Image::open('./water/'.$path);
// 按照原图的比例生成一个最大为150*150的缩略图并保存为thumb.png
$image->thumb(400, 400)->save('./thumb/'.$path);
$filePash= '/thumb/'.$path;
return $filePash;
}
}