我需要使用 intervention image 和 laravel 将一些图像插入到另一张图片中。
这是我的主要图片:
这些是要插入到主要图片中的图像:
最后得到的插入图片如下:
下面是我用来实现这个功能的代码:
$img = Image::make(asset('images/cover.png' ) )->encode('jpg', 15);
$token = Session::get('_token');
$imgWidth = $img->width();
$imgHeight = $img->height();
$coverImages = Storage::allFiles('public/' . $token . '/cover');
$r1 = Image::make(asset('storage/' . $token . '/cover/r1.png') );
$r2 = Image::make(asset('storage/' . $token . '/cover/r2.png') );
$r1->resize(80, 180, function ($constraint){
$constraint->aspectRatio();
});
$r2->resize(80, 180, function ($constraint){
$constraint->aspectRatio();
});
$img->insert($r1, 'top-left', 190, 175);
$img->insert($r2, 'top-left', 290, 175);
$img->save( public_path("storage/{$token}/111111.png"));
现在我需要将r1.png
和r2.png
的角弧度调整以适应主图像
。
您知道我该如何做吗?
谢谢提前
注意:
感谢@Pascal Meunier
,但是
因为某种原因,我必须单独为
r1.png
进行圆角处理,因为我必须再将圆角图像保存在另一个地方...