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 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)))); }); }
/** * Applies scheduled transformation to ImageInterface instance * Returns processed ImageInterface instance * * @param \Imagine\Image\ImageInterface $image * * @return \Imagine\Image\ImageInterface */ public function apply(ImageInterface $image) { $grayscale = new Grayscale(); return parent::apply($grayscale->apply($image)); }