-
-
Notifications
You must be signed in to change notification settings - Fork 384
Open
Labels
Description
Versions:
PHP 7.4.27 (cli)
claviska/simpleimage ^3.6
if you pass invalid values to the resize function it does not throw an error and ends up
creating bad images
Warnings
Warning: imagecreatetruecolor(): Invalid image dimensions in
vendor\claviska\simpleimage\src\claviska\SimpleImage.php on line 805
Warning: imagecolorallocatealpha() expects parameter 1 to be resource, bool given in vendor\claviska\simpleimage\src\claviska\SimpleImage.php on line 806
Warning: imagecolortransparent() expects parameter 1 to be resource, bool given in vendor\claviska\simpleimage\src\claviska\SimpleImage.php on line 807
Warning: imagefill() expects parameter 1 to be resource, bool given in
vendor\claviska\simpleimage\src\claviska\SimpleImage.php on line 808
Warning: imagecopyresampled() expects parameter 1 to be resource, bool given in vendor\claviska\simpleimage\src\claviska\SimpleImage.php on line 816
[Broken] Code
(You should use the change as a percentage so you dot get zero or negative heights :P )
try {
$image->fromFile($path2image);
$filesizeold = filesize($path2image);
if (($image->getWidth() > 1000) && ($filesizekb > 400)) {
$change = $image->getWidth() - 750;
$image->resize($image->getWidth() - $change, $image->getHeight() - $change);
$image->toFile($path2image, null, 75);
}
} catch (Exception $e) {
// --
}