我想将单个图像调整为多种分辨率并存储在laravel中的不同文件夹中

问题描述 投票:0回答:1

我想裁剪图像并调整图像大小并保存到多个文件夹中。但只有一张图像保存在文件夹中(第一个)

public function update(Request $request)
{
      $image = $request->file('file');
      $name = time().''.mt_rand(100, 200).'_1280x768.'.$image->getClientOriginalExtension();
      $name1 = time().''.mt_rand(100, 200).'_320x240.'.$image->getClientOriginalExtension();
      $image1= $image->move('public/storage/uploadimage/main', $name);
      $image2= $image->move('public/storage/uploadimage/thumb', $name1);



      $img = Image::make($imagename);
      $img->fit(1280, 768, function ($constraint) {
          $constraint->upsize();
      });
      $img->insert('https://kafesta.com/public/images/kafesta-10.png', 'center');
      $img->save($imagename);

      $img1 = Image::make($imagename1);
      $img1->fit(320, 240, function ($constraint) {
          $constraint->upsize();
      });
      $img1->insert('https://kafesta.com/public/images/kafesta-10.png', 'center');
      $img1->save($imagename1);
}
laravel laravel-5 eloquent laravel-4
1个回答
0
投票
$image1 = clone $image;
$image2 = clone $image;
© www.soinside.com 2019 - 2024. All rights reserved.