Skip to content

Commit 0496393

Browse files
Merge pull request #84 from emiliodeg/patch-1
better quality support
2 parents 4536668 + 9f092df commit 0496393

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

lib/ImageResize.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ public function imageCreateJpegfromExif($filename){
162162
public function save($filename, $image_type = null, $quality = null, $permissions = null)
163163
{
164164
$image_type = $image_type ?: $this->source_type;
165+
$quality = is_numeric($quality) ? (int) abs($quality) : null;
165166

166167
switch ($image_type) {
167168
case IMAGETYPE_GIF:
@@ -217,15 +218,15 @@ public function save($filename, $image_type = null, $quality = null, $permission
217218
break;
218219

219220
case IMAGETYPE_JPEG:
220-
if ($quality === null) {
221+
if ($quality === null || $quality > 100) {
221222
$quality = $this->quality_jpg;
222223
}
223224

224225
imagejpeg($dest_image, $filename, $quality);
225226
break;
226227

227228
case IMAGETYPE_PNG:
228-
if ($quality === null) {
229+
if ($quality === null || $quality > 9) {
229230
$quality = $this->quality_png;
230231
}
231232

0 commit comments

Comments
 (0)