1
0
mirror of https://github.com/Intervention/image.git synced 2025-09-08 21:20:46 +02:00

added brightness and contrast methods

This commit is contained in:
Oliver Vogel
2013-02-03 13:57:49 +01:00
parent c0972d7bbc
commit 486743dfcf
3 changed files with 42 additions and 0 deletions

View File

@@ -46,6 +46,8 @@ Add the facade of this package to the `$aliases` array.
* Image::resize - Resize image based on given width and/or height
* Image::grab - Cut out a detail of the image in given ratio and resize to output size
* Image::insert - Insert another image on top of the current image
* Image::brightness - Changes brightness of current image
* Image::contrast - Changes contrast of current image
* Image::pixelate - Pixelate current image
* Image::greyscale - Turn current image into a greyscale version
* Image::text - Write text in current image

View File

@@ -405,6 +405,30 @@ class Image
return $this;
}
/**
* Changes the brightness of the current image
*
* @param int $level [description]
* @return Image
*/
public function brightness($level)
{
imagefilter($this->resource, IMG_FILTER_BRIGHTNESS, $level);
return $this;
}
/**
* Changes the contrast of the current image
*
* @param int $level
* @return Image
*/
public function contrast($level)
{
imagefilter($this->resource, IMG_FILTER_CONTRAST, $level);
return $this;
}
/**
* Pixelate current image
*

View File

@@ -294,4 +294,20 @@ class ImageTest extends PHPUnit_Framework_Testcase
}
public function testBrightnessImage()
{
$img = $this->getTestImage();
$img->brightness(50);
$img->brightness(-50);
$this->assertInstanceOf('Intervention\Image\Image', $img);
}
public function testContrastImage()
{
$img = $this->getTestImage();
$img->contrast(50);
$img->contrast(-50);
$this->assertInstanceOf('Intervention\Image\Image', $img);
}
}