public function __construct() { parent::__construct(function (ImageInterface $image, Point $point) { $color = $image->getColorAt($point); $image->draw()->dot($point, new Color(array('red' => 255 - $color->getRed(), 'green' => 255 - $color->getGreen(), 'blue' => 255 - $color->getBlue()))); }); }
/** * @param $border If the grayed pixel has a value smaller than $border, the pixel will be whiten. Otherwise the * color will be black. * @throws \Imagine\Exception\InvalidArgumentException if border < 0 or border > 255 */ public function __construct($border) { if ($border < 0 || $border > 255) { throw new InvalidArgumentException('Border has to be between 0 and 255'); } parent::__construct(function (ImageInterface $image, Point $point) use($border) { $newColor = $image->getColorAt($point)->getRed() < $border ? 255 : 0; $image->draw()->dot($point, new Color(array('red' => $newColor, 'green' => $newColor, 'blue' => $newColor))); }); }
/** * @param int $brightness the brightnes of the resulting image * @throws \Imagine\Exception\InvalidArgumentException if $brightness < 0 */ public function __construct($brightness = 1) { if ($brightness < 0) { throw new InvalidArgumentException('Brightness has to be positive'); } parent::__construct(function (ImageInterface $image, Point $point) use($brightness) { $color = $image->getColorAt($point); $image->draw()->dot($point, new Color(array('red' => min(255, $color->getRed() * $brightness), 'green' => min(255, $color->getGreen() * $brightness), 'blue' => min(255, $color->getBlue() * $brightness)))); }); }