Laravel图像上传太慢

问题描述

我正在使用laravel干预软件包来调整图像大小。但是在实时服务器中发布带有图像的帖子时非常慢。我正在使用下面的代码来处理图像并上传。我一次上传5张图片。我可以在上传之前使用Javascript调整图像大小吗?我没有使用JS进行上传,而是使用js进行了预览缩略图删除按钮将其删除enter image description here

这是表单字段

<input value="{{old('image_01')}}" required name="image_01" type="file" class="custom-file-input " id="inputGroupFile01"> <label for="inputGroupFile01">Add a photo</label>

$image01_name ='';
        if ($request->hasFile('image_01')){
            $image01 = $request->image_01;
            $img01 = Image::make($image01);
            $height = $img01->height();
            $width = $img01->width();
            if ($width > $height) {
                $im = $img01->resize(700,null,function ($constraint) {
                    $constraint->aspectRatio();
                });
            }
            if ($width < $height) {
                $im = $img01->resize(null,467,function ($constraint) {
                    $constraint->aspectRatio();
                });
            }

            $image01_name = str_slug($request->title).'_'.mt_rand(1,100).'-'.time().'_1.'.$image01->getClientOriginalExtension();
            $thumb01_name = str_slug($request->title).'_'.mt_rand(1,100).'-'.time().'_1_t.'.$image01->getClientOriginalExtension();
            $img = Image::canvas(700,467);
            $img->insert($im,'center');
            $img->insert( $waterMarkUrl,'center-center',10,10);
            $img->save('storage/'.$image01_name);
            $thumb = $img01->fit(450,300);
            $thumb->save('storage/'.$thumb01_name);

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)