TP5缩放图片加水印
// 给图片增加水印文字 试验缩放图片,放大图片,加水印,加文字功能
public function doCreateImage1($data,$path) { $basePath = ROOT_PATH . 'public/static/index/images/'; $image = Image::open($basePath . 'demo1.jpg'); $tempName = pathinfo($data['img'],PATHINFO_FILENAME) . '_temp.' . pathinfo($data['img'],PATHINFO_EXTENSION); $waterImg = Image::open($path . 'qrcode/' . $data['img']); $waterImgSizeArr = $waterImg->size(); $waterImg = $waterImg
// 先裁剪图片,将图片放大为1000,1000 ->crop($waterImgSizeArr[0],$waterImgSizeArr[1],0,0,1000,1000)
// 该步骤是缩放图片为339,339 只是试验功能 ->thumb(339,339) ->save($path . $tempName,null,98); $fontPath = ROOT_PATH . 'public/static/fonts/msyh.ttf'; $image->water($path . $tempName,[595,1330]) ->text($data['name'],$fontPath, 24, '#ffffff', [169,1469]) ->text($data['phone'],$fontPath, 24, '#ffffff', [135,1526]) ->save($path . 'imagesnew/' . $data['img']); unlink($path . $tempName); }