Skip to content

Commit eecc36d

Browse files
authored
better quality support
I made a little change to prevent bad use of quality
1 parent b2189fb commit eecc36d

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
@@ -147,6 +147,7 @@ public function imageCreateJpegfromExif($filename){
147147
public function save($filename, $image_type = null, $quality = null, $permissions = null)
148148
{
149149
$image_type = $image_type ?: $this->source_type;
150+
$quality = (int) abs($quality);
150151

151152
switch ($image_type) {
152153
case IMAGETYPE_GIF:
@@ -202,15 +203,15 @@ public function save($filename, $image_type = null, $quality = null, $permission
202203
break;
203204

204205
case IMAGETYPE_JPEG:
205-
if ($quality === null) {
206+
if ($quality === null || $quality < 0 || $quality > 100) {
206207
$quality = $this->quality_jpg;
207208
}
208209

209210
imagejpeg($dest_image, $filename, $quality);
210211
break;
211212

212213
case IMAGETYPE_PNG:
213-
if ($quality === null) {
214+
if ($quality === null || $quality < 0 || $quality > 9) {
214215
$quality = $this->quality_png;
215216
}
216217

0 commit comments

Comments
 (0)