@@ -24,6 +24,7 @@ class ImageResize
24
24
public $ quality_webp = 85 ;
25
25
public $ quality_png = 6 ;
26
26
public $ quality_truecolor = true ;
27
+ public $ gamma_correct = true ;
27
28
28
29
public $ interlace = 1 ;
29
30
@@ -47,8 +48,7 @@ class ImageResize
47
48
protected $ source_h ;
48
49
49
50
protected $ source_info ;
50
-
51
-
51
+
52
52
protected $ filters = [];
53
53
54
54
/**
@@ -286,7 +286,9 @@ public function save($filename, $image_type = null, $quality = null, $permission
286
286
287
287
imageinterlace ($ dest_image , $ this ->interlace );
288
288
289
- imagegammacorrect ($ this ->source_image , 2.2 , 1.0 );
289
+ if ($ this ->gamma_correct ) {
290
+ imagegammacorrect ($ this ->source_image , 2.2 , 1.0 );
291
+ }
290
292
291
293
if ( !empty ($ exact_size ) && is_array ($ exact_size ) ) {
292
294
if ($ this ->getSourceHeight () < $ this ->getSourceWidth ()) {
@@ -312,7 +314,9 @@ public function save($filename, $image_type = null, $quality = null, $permission
312
314
$ this ->source_h
313
315
);
314
316
315
- imagegammacorrect ($ dest_image , 1.0 , 2.2 );
317
+ if ($ this ->gamma_correct ) {
318
+ imagegammacorrect ($ dest_image , 1.0 , 2.2 );
319
+ }
316
320
317
321
318
322
$ this ->applyFilter ($ dest_image );
@@ -756,4 +760,17 @@ public function imageFlip($image, $mode)
756
760
}
757
761
imagedestroy ($ temp_image );
758
762
}
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
+ }
759
776
}
0 commit comments