N
N
NDll2022-03-13 14:40:41
Laravel
NDll, 2022-03-13 14:40:41

Why doesn't it crop the image?

Tell me, where did you go wrong?

for some reason, when uploading files to S3, it does not cut it off

public function upload($file)
    {

        $image = Image::make($file);
        $filename = $this->getFileName($file->getClientOriginalName(), $file->getClientOriginalExtension());

        $data['filename'] = $filename;
        $data['path'] = config('filesystems.disks.s3.url').'/'.$this->storagePath.'/';

        foreach ($this->storageSizes as $key => $storageSize) {
            $imageResize = $image->resize($storageSize['width'], $storageSize['height'], function ($constraint) {
                $constraint->aspectRatio();
                $constraint->upsize();
            });

            Storage::disk('s3')->put("{$this->storagePath}/{$key}/{$filename}", $imageResize->encode());

            $data['sizes'][] = $key;
        }
    }

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question