ImagickException'无效的图像几何'


ERROR: Uncaught exception 'ImagickException' with message 'Invalid image geometry'

我编写了一小段代码来调整服务器上显示的图像的大小。我正在xampp上测试它。

if ($img_width[0] >= 750) { $imagick_image_width = 920; }
elseif (($img_width[0] > 500) && ($img_width[0] < 750))  { $imagick_image_width = 500; }
elseif (($img_width[0] >= 200) && ($img_width[0] <= 500)) { $imagick_image_width = 500; }
$save_path = 'c:/xampp/htdocs/images/'.$image_name.'.jpg';
$image = new Imagick($save_path);
$image->resizeImage($imagick_image_width, 0,Imagick::FILTER_LANCZOS,0.95); //line 226
$image->writeImage($save_path);
$image->destroy();  

我已经把img_width通过getimagesize数组。

执行时给出错误:

Fatal error: Uncaught exception 'ImagickException' with message 'Invalid image geometry' in C:'xampp'htdocs'test-templ.php on line 226
ImagickException: Invalid image geometry in C:'xampp'htdocs'test-templ.php on line 226

如何解决这个问题?

在使用$imagick_image_width变量调整大小前检查其值。我得到了同样的错误,并且参考它,我的laravel代码无法从'env'文件读取值。

尝试用任何默认大小初始化$imagick_image_width变量