图片处理 PictureLibrary
图片追加水印、文字以及将长图拆分为1:1多图
调用类:
Abnermouke\Supports\Library\PictureLibrary::make($source)
默认需传入处理图片绝对路径
添加图片水印实例:
$main_img_path = 'path to image';
$water_img_path = 'path to water image';
$width = 100; //水印图片宽度
$height = 100; //水印图片高度
$x = 10; //水印图片X轴坐标
$y = 10; //水印图片Y轴坐标
$position = 'top-left'; //水印图片对其位置(默认:左上)
$save_img_path = 'path to save image';
Abnermouke\Supports\Library\PictureLibrary::make($main_img_path)
->draw($water_img_path, $width, $height, $x, $y, $position)
->save($save_img_path);添加文字水印实例:
当然,水印肯定是可以重叠使用的:
拆剪正方形
常用于商品详情图,如供应链或厂家提供的为长图,为减小加载压力,需将长图拆剪为等比图片进行展示
拆剪的长图将生成多张图片,文件名为:$prefix[序号]_[原文件名],例如:square-0_main_picture.jpg
Last updated