summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/PHPImageWorkshop/Core/ImageWorkshopLayer.php9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/PHPImageWorkshop/Core/ImageWorkshopLayer.php b/src/PHPImageWorkshop/Core/ImageWorkshopLayer.php
index 113602a..c668599 100644
--- a/src/PHPImageWorkshop/Core/ImageWorkshopLayer.php
+++ b/src/PHPImageWorkshop/Core/ImageWorkshopLayer.php
@@ -1559,8 +1559,13 @@ class ImageWorkshopLayer
} elseif ($extension == 'png') {
- $imageQuality = $imageQuality / 10;
- $imageQuality -= 1;
+ if ($imageQuality >= 100) {
+ $imageQuality = 0;
+ } elseif ($imageQuality <= 0) {
+ $imageQuality = 10;
+ } else {
+ $imageQuality = round((100 - $imageQuality) / 10);
+ }
$isSaved = imagepng($image, $filename, intval($imageQuality));