mirror of
https://github.com/Intervention/image.git
synced 2025-09-09 05:30:40 +02:00
added brightness and contrast methods
This commit is contained in:
@@ -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
|
||||
|
@@ -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
|
||||
*
|
||||
|
@@ -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);
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user