mirror of
https://github.com/Intervention/image.git
synced 2025-08-30 09:10:21 +02:00
added invert method
This commit is contained in:
@@ -56,6 +56,7 @@ Add the facade of this package to the `$aliases` array.
|
||||
* Image::contrast - Changes contrast of current image (-100 = min contrast, 0 = no change, +100 = max contrast)
|
||||
* Image::pixelate - Pixelate current image
|
||||
* Image::greyscale - Turn current image into a greyscale version
|
||||
* Image::invert - Invert colors of current image
|
||||
* Image::text - Write text in current image
|
||||
* Image::fill - Fill image with given color at position x,y
|
||||
* Image::rectangle - Draw rectangle in current image starting at point 1 and ending at point 2
|
||||
|
@@ -626,6 +626,18 @@ class Image
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Invert colors of current image
|
||||
*
|
||||
* @return Image
|
||||
*/
|
||||
public function invert()
|
||||
{
|
||||
imagefilter($this->resource, IMG_FILTER_NEGATE);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset to original image resource
|
||||
*
|
||||
|
@@ -205,6 +205,14 @@ class ImageTest extends PHPUnit_Framework_Testcase
|
||||
$this->assertInstanceOf('Intervention\Image\Image', $img);
|
||||
}
|
||||
|
||||
public function testInvertImage()
|
||||
{
|
||||
$img = $this->getTestImage();
|
||||
$img->invert();
|
||||
$this->assertInstanceOf('Intervention\Image\Image', $img);
|
||||
$this->assertEquals('#000000', $img->pickColor(0, 0, 'hex'));
|
||||
}
|
||||
|
||||
public function testFillImage()
|
||||
{
|
||||
$img = $this->getTestImage();
|
||||
|
Reference in New Issue
Block a user