public function viewImage($w, $h, $path){
$image = Image::where('path', $path)->first();
if($image){
$manager = new ImageManager(array('driver' => 'gd'));
if ($w === 0){
$img = $manager->make(asset("storage/galleries/".$image->fullpath))
->resize($w, $h, function ($constraint) {
$constraint->aspectRatio();
});
return $img->response('jpg');
}
else{
if ($h === 0){
$img = $manager->make(asset("storage/galleries/".$image->fullpath))
->resize($w, $h, function ($constraint) {
$constraint->aspectRatio();
});
return $img->response('jpg');
}
$img = $manager->make(asset("storage/galleries/".$image->fullpath))->resize($w, $h);
return $img->response('jpg');
}
}
...
但是它给我这样的错误:
ErrorException: imagecreatetruecolor(): Invalid image dimensions in file C:\xampp\htdocs\PROGRAMATOR.SK_API\vendor\intervention\image\src\Intervention\Image\Gd\Commands\ResizeCommand.php on line 47
我使用Intervention \ Image \ Image库
您能帮我吗?
我正在Laravel项目上,我需要调整图像大小并从控制器作为文件返回。如果图像的width或height参数等于0,则必须计算另一个参数。我这样尝试过...
$w
和$h
是字符串。您有这些选项