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

Add modifier methods

This commit is contained in:
Oliver Vogel
2023-11-26 13:29:41 +01:00
parent 9e0d9cb53f
commit 5889391fc8
2 changed files with 45 additions and 0 deletions

View File

@@ -26,8 +26,11 @@ use Intervention\Image\Interfaces\ModifierInterface;
use Intervention\Image\Interfaces\ProfileInterface;
use Intervention\Image\Interfaces\ResolutionInterface;
use Intervention\Image\Interfaces\SizeInterface;
use Intervention\Image\Modifiers\ColorspaceModifier;
use Intervention\Image\Modifiers\GreyscaleModifier;
use Intervention\Image\Modifiers\PixelateModifier;
use Intervention\Image\Modifiers\ProfileModifier;
use Intervention\Image\Modifiers\ResolutionModifier;
use Intervention\Image\Modifiers\RotateModifier;
use Intervention\Image\Modifiers\SharpenModifier;
use Intervention\Image\Modifiers\TextModifier;
@@ -112,11 +115,21 @@ class Image implements ImageInterface, Countable
return $this->analyze(new ColorspaceAnalyzer());
}
public function setColorspace(string|ColorspaceInterface $colorspace): ImageInterface
{
return $this->modify(new ColorspaceModifier($colorspace));
}
public function resolution(): ResolutionInterface
{
return $this->analyze(new ResolutionAnalyzer());
}
public function setResolution(float $x, float $y): ImageInterface
{
return $this->modify(new ResolutionModifier($x, $y));
}
public function pickColor(int $x, int $y, int $frame_key = 0): ColorInterface
{
return $this->analyze(new PixelColorAnalyzer($x, $y, $frame_key));
@@ -132,6 +145,11 @@ class Image implements ImageInterface, Countable
return $this->analyze(new ProfileAnalyzer());
}
public function setProfile(ProfileInterface $profile): ImageInterface
{
return $this->modify(new ProfileModifier($profile));
}
public function sharpen(int $amount = 10): ImageInterface
{
return $this->modify(new SharpenModifier($amount));

View File

@@ -4,6 +4,7 @@ namespace Intervention\Image\Interfaces;
use Countable;
use Intervention\Image\EncodedImage;
use Intervention\Image\Modifiers\ColorspaceModifier;
use IteratorAggregate;
interface ImageInterface extends IteratorAggregate, Countable
@@ -95,6 +96,16 @@ interface ImageInterface extends IteratorAggregate, Countable
*/
public function resolution(): ResolutionInterface;
/**
* Set image resolution
*
* @param float $x
* @param float $y
* @return ImageInterface
*/
public function setResolution(float $x, float $y): ImageInterface;
/**
* Get the colorspace of the image
*
@@ -102,6 +113,14 @@ interface ImageInterface extends IteratorAggregate, Countable
*/
public function colorspace(): ColorspaceInterface;
/**
* Transform image to given colorspace
*
* @param string|ColorspaceInterface $colorspace
* @return ImageInterface
*/
public function setColorspace(string|ColorspaceInterface $colorspace): ImageInterface;
/**
* Return color of pixel at given position on given frame position
*
@@ -128,6 +147,14 @@ interface ImageInterface extends IteratorAggregate, Countable
*/
public function profile(): ProfileInterface;
/**
* Set given icc color profile to image
*
* @param ProfileInterface $profile
* @return ImageInterface
*/
public function setProfile(ProfileInterface $profile): ImageInterface;
/**
* Sharpen the current image with given strength
*