1
0
mirror of https://github.com/Intervention/image.git synced 2025-08-30 01:00:06 +02:00

added invert method

This commit is contained in:
Oliver Vogel
2013-03-01 16:53:57 +01:00
parent d3f10d0aeb
commit 291a13927b
3 changed files with 21 additions and 0 deletions

View File

@@ -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

View File

@@ -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
*

View File

@@ -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();