From 58fd9b2f28366ec529d539ab9e40ac22f67c782d Mon Sep 17 00:00:00 2001 From: Andrew Welch Date: Mon, 9 Dec 2024 14:35:39 -0500 Subject: [PATCH] fix: Don't try to apply filters to assets that are seemingly corrupt, and have a `0` width or `0` height ([#383](https://github.com/nystudio107/craft-imageoptimize/issues/383)) --- src/services/Optimize.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/Optimize.php b/src/services/Optimize.php index e4f17f4..e851b4d 100644 --- a/src/services/Optimize.php +++ b/src/services/Optimize.php @@ -641,7 +641,7 @@ protected function applyFiltersToImage(AssetTransform $transform, Asset $asset, /** @var Settings $settings */ $settings = ImageOptimize::$plugin->getSettings(); // Only try to apply filters to Raster images - if ($image instanceof Raster) { + if ($image instanceof Raster && $asset->getWidth() > 0 && $asset->getHeight() > 0) { $imagineImage = $image->getImagineImage(); // Handle auto-sharpening scaled down images if ($imagineImage !== null && $settings->autoSharpenScaledImages) {