Improved image handling logic

The image processing logic has been updated to better handle optional parameters. Previously, the code would always pad and resize the canvas regardless of whether width, height, or canvas dimensions were provided. Now, padding and resizing only occur if the corresponding options are set. This change makes the code more flexible and prevents potential errors when certain parameters are not provided.
This commit is contained in:
Jeroen De Meerleer 2024-07-23 13:55:20 +02:00
parent c6d800c010
commit 8fbbccfa21
Signed by: JeroenED
GPG Key ID: 28CCCB8F62BFADD6

View File

@ -53,9 +53,14 @@ if(isSvg($imagecontent)) {
$transparent = (new \Intervention\Image\Colors\Rgb\Color(0,0,0,0)); $transparent = (new \Intervention\Image\Colors\Rgb\Color(0,0,0,0));
// to finally create image instances // to finally create image instances
$image = $manager $image = $manager
->read($imagecontent) ->read($imagecontent);
->pad($options['width'], $options['height'], $transparent)
->resizeCanvas($options['canvaswidth'], $options['canvasheight'], $transparent); if(isset($options['width']) || isset($options['height'])) {
$image = $image->pad($options['width'], $options['height'], $transparent);
}
if(isset($options['canvaswidth']) || isset($options['canvasheight'])) {
$image = $image->resizeCanvas($options['canvaswidth'], $options['canvasheight'], $transparent);
}
if (isset($options['fill'])) { if (isset($options['fill'])) {
$image = $image->blendTransparency($options['fill']); $image = $image->blendTransparency($options['fill']);