jeudi 1 octobre 2020

i want to resize single image to multiple resolution and store in diffrent folder in laravel

I want to crop and resize image and save into multiple folder. But only single image is saving in folder(firstone) Please fix this need help urgent...

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);

}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire