From 4956f25b68724fce118c09f7924ada1874ffd97e Mon Sep 17 00:00:00 2001 From: Oliver Vogel Date: Wed, 11 Dec 2013 20:55:41 +0100 Subject: [PATCH] added gamma method --- src/Intervention/Image/Image.php | 14 ++++++++++++++ tests/ImageTest.php | 11 +++++++++++ 2 files changed, 25 insertions(+) diff --git a/src/Intervention/Image/Image.php b/src/Intervention/Image/Image.php index faee0006..ff992abb 100644 --- a/src/Intervention/Image/Image.php +++ b/src/Intervention/Image/Image.php @@ -1365,6 +1365,20 @@ class Image return $this; } + /** + * Applies gamma correction + * + * @param float $input + * @param float $output + * @return Image + */ + public function gamma($input, $output) + { + imagegammacorrect($this->resource, $input, $output); + + return $this; + } + /** * Reset to original image resource * diff --git a/tests/ImageTest.php b/tests/ImageTest.php index 22fbf51a..b3015674 100644 --- a/tests/ImageTest.php +++ b/tests/ImageTest.php @@ -1400,6 +1400,17 @@ class ImageTest extends PHPUnit_Framework_Testcase $this->assertEquals(( ord($contents[28]) != '0' ), false); } + public function testGammaImage() + { + $img = Image::make('public/tile.png'); + $img->gamma(1.0, 1.6); + $this->assertInstanceOf('Intervention\Image\Image', $img); + $color1 = $img->pickColor(0, 0, 'hex'); + $color2 = $img->pickColor(10, 10, 'hex'); + $this->assertEquals('#cdeb00', $color1); + $this->assertEquals('#707d8a', $color2); + } + public function testSaveImage() { $save_as = 'public/test2.jpg';