@@ -24,6 +24,7 @@ class ImageResize
2424 public $ quality_webp = 85 ;
2525 public $ quality_png = 6 ;
2626 public $ quality_truecolor = true ;
27+ public $ gamma_correct = true ;
2728
2829 public $ interlace = 1 ;
2930
@@ -47,8 +48,7 @@ class ImageResize
4748 protected $ source_h ;
4849
4950 protected $ source_info ;
50-
51-
51+
5252 protected $ filters = [];
5353
5454 /**
@@ -286,7 +286,9 @@ public function save($filename, $image_type = null, $quality = null, $permission
286286
287287 imageinterlace ($ dest_image , $ this ->interlace );
288288
289- imagegammacorrect ($ this ->source_image , 2.2 , 1.0 );
289+ if ($ this ->gamma_correct ) {
290+ imagegammacorrect ($ this ->source_image , 2.2 , 1.0 );
291+ }
290292
291293 if ( !empty ($ exact_size ) && is_array ($ exact_size ) ) {
292294 if ($ this ->getSourceHeight () < $ this ->getSourceWidth ()) {
@@ -312,7 +314,9 @@ public function save($filename, $image_type = null, $quality = null, $permission
312314 $ this ->source_h
313315 );
314316
315- imagegammacorrect ($ dest_image , 1.0 , 2.2 );
317+ if ($ this ->gamma_correct ) {
318+ imagegammacorrect ($ dest_image , 1.0 , 2.2 );
319+ }
316320
317321
318322 $ this ->applyFilter ($ dest_image );
@@ -756,4 +760,17 @@ public function imageFlip($image, $mode)
756760 }
757761 imagedestroy ($ temp_image );
758762 }
763+
764+ /**
765+ * Enable or not the gamma color correction on the image, enabled by default
766+ *
767+ * @param bool $enable
768+ * @return static
769+ */
770+ public function gamma ($ enable = true )
771+ {
772+ $ this ->gamma_correct = $ enable ;
773+
774+ return $ this ;
775+ }
759776}
0 commit comments