Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xslt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何使用Laravel设置干预图像包中的图像大小和尺寸_Php_Laravel_Image_Laravel 5.8_Intervention - Fatal编程技术网

Php 如何使用Laravel设置干预图像包中的图像大小和尺寸

Php 如何使用Laravel设置干预图像包中的图像大小和尺寸,php,laravel,image,laravel-5.8,intervention,Php,Laravel,Image,Laravel 5.8,Intervention,我正在使用干预映像包在将上载的映像保存到服务器之前对其进行操作。我已经成功设置了图像的尺寸,它工作正常,但我想固定图像大小,即生成的图像应该小于等于30KB,并且应该只有300dpi的分辨率 下面是我用来调整上传图像大小的代码: $file = $post->file('profile_image'); $filename = Carbon::now()->timestamp.'_'.$file->getClientOriginalName(); \Image::make(

我正在使用干预映像包在将上载的映像保存到服务器之前对其进行操作。我已经成功设置了图像的尺寸,它工作正常,但我想固定图像大小,即生成的图像应该小于等于30KB,并且应该只有300dpi的分辨率

下面是我用来调整上传图像大小的代码:

$file = $post->file('profile_image');

$filename = Carbon::now()->timestamp.'_'.$file->getClientOriginalName();

\Image::make($file->getRealPath())->resize(160, 160)->save('uploads/profile/'.$filename);
如果我的问题是可行的干预图像包,请给我一个解决方案


提前谢谢。

你可以试试这样的东西

$size=160;
$img=\Image::make($file->getRealPath())->resize($size,$size)->save($uploads/profile/”。$filename);
而($img->filesize()<“someAmount”){
$size=(int)$size-20;//根据需要进行调整
$img=\Image::make($file->getRealPath())->resize($size,$size)->save($uploads/profile/”。$filename);
}
注意这不是正确答案,但解决这个问题是个好主意


您好Kamlesh,谢谢您的回复,但是如何将图像分辨率设置为300度