1
0
mirror of https://github.com/Intervention/image.git synced 2025-08-19 12:11:26 +02:00
This commit is contained in:
Vincent Langlet
2024-02-29 10:10:52 +01:00
parent 3e87be6a63
commit ba39c13d2b
16 changed files with 79 additions and 77 deletions

View File

@@ -25,8 +25,8 @@ abstract class AbstractDecoder extends DriverSpecialized implements DecoderInter
* Try to decode given input to image or color object
*
* @param mixed $input
* @return ImageInterface|ColorInterface
* @throws DecoderException
* @return ImageInterface|ColorInterface
*/
final public function handle(mixed $input): ImageInterface|ColorInterface
{

View File

@@ -31,8 +31,8 @@ abstract class AbstractInputHandler implements InputHandlerInterface
/**
* Stack the decoder array into a nested decoder object
*
* @return AbstractDecoder
* @throws DecoderException
* @return AbstractDecoder
*/
protected function chain(): AbstractDecoder
{

View File

@@ -13,8 +13,8 @@ abstract class AbstractDecoder extends GenericAbstractDecoder
* Return media (mime) type of the file at given file path
*
* @param string $filepath
* @return string
* @throws DecoderException
* @return string
*/
protected function getMediaTypeByFilePath(string $filepath): string
{
@@ -35,8 +35,8 @@ abstract class AbstractDecoder extends GenericAbstractDecoder
* Return media (mime) type of the given image data
*
* @param string $data
* @return string
* @throws DecoderException
* @return string
*/
protected function getMediaTypeByBinary(string $data): string
{

View File

@@ -36,8 +36,8 @@ class BinaryImageDecoder extends GdImageDecoder implements DecoderInterface
* Decode image from given binary data
*
* @param string $input
* @return ImageInterface
* @throws DecoderException
* @return ImageInterface
*/
private function decodeBinary(string $input): ImageInterface
{

View File

@@ -45,10 +45,10 @@ class FontProcessor extends AbstractFontProcessor
*
* @param FontInterface $font
* @param null|ImagickPixel $color
* @return ImagickDraw
* @throws FontException
* @throws ImagickDrawException
* @throws ImagickException
* @return ImagickDraw
*/
public function toImagickDraw(FontInterface $font, ?ImagickPixel $color = null): ImagickDraw
{

View File

@@ -41,8 +41,8 @@ class FileExtensionEncoder extends AutoEncoder
* Create matching encoder for given file extension
*
* @param string $extension
* @return EncoderInterface
* @throws EncoderException
* @return EncoderInterface
*/
protected function encoderByFileExtension(?string $extension): EncoderInterface
{

View File

@@ -34,8 +34,8 @@ class MediaTypeEncoder extends SpecializableEncoder implements EncoderInterface
* Return new encoder by given media (MIME) type
*
* @param string $type
* @return EncoderInterface
* @throws EncoderException
* @return EncoderInterface
*/
protected function encoderByMediaType(string $type): EncoderInterface
{

View File

@@ -4,7 +4,6 @@ declare(strict_types=1);
namespace Intervention\Image;
use Intervention\Image\Exceptions\RuntimeException;
use Traversable;
use Intervention\Image\Analyzers\ColorspaceAnalyzer;
use Intervention\Image\Analyzers\HeightAnalyzer;
@@ -892,8 +891,8 @@ final class Image implements ImageInterface
* Alias of self::toJpeg()
*
* @param mixed $options
* @throws EncoderException
* @return EncodedImageInterface
* @throws RuntimeException
*/
public function toJpg(mixed ...$options): EncodedImageInterface
{
@@ -914,8 +913,8 @@ final class Image implements ImageInterface
* ALias of self::toJpeg2000()
*
* @param mixed $options
* @throws EncoderException
* @return EncodedImageInterface
* @throws RuntimeException
*/
public function toJp2(mixed ...$options): EncodedImageInterface
{
@@ -965,8 +964,8 @@ final class Image implements ImageInterface
/**
* Alias if self::toBitmap()
*
* @throws EncoderException
* @return EncodedImageInterface
* @throws RuntimeException
*/
public function toBmp(mixed ...$options): EncodedImageInterface
{
@@ -997,8 +996,8 @@ final class Image implements ImageInterface
* Alias of self::toTiff()
*
* @param mixed $options
* @throws EncoderException
* @return EncodedImageInterface
* @throws RuntimeException
*/
public function toTif(mixed ...$options): EncodedImageInterface
{

View File

@@ -88,8 +88,8 @@ final class ImageManager
*
* @param mixed $input
* @param string|array|DecoderInterface $decoders
* @return ImageInterface
* @throws DecoderException
* @return ImageInterface
*/
public function read(mixed $input, string|array|DecoderInterface $decoders = []): ImageInterface
{

View File

@@ -4,6 +4,8 @@ declare(strict_types=1);
namespace Intervention\Image\Interfaces;
use Intervention\Image\Exceptions\DecoderException;
interface ColorInterface
{
/**
@@ -11,8 +13,8 @@ interface ColorInterface
* and returns a corresponding color object
*
* @param mixed $input
* @throws DecoderException
* @return ColorInterface
* @throws \Intervention\Image\Exceptions\DecoderException
*/
public static function create(mixed $input): self;

View File

@@ -12,8 +12,8 @@ interface DecoderInterface
* Decode given input either to color or image
*
* @param mixed $input
* @return ImageInterface|ColorInterface
* @throws DecoderException
* @return ImageInterface|ColorInterface
*/
public function decode(mixed $input): ImageInterface|ColorInterface;
}

View File

@@ -5,6 +5,7 @@ declare(strict_types=1);
namespace Intervention\Image\Interfaces;
use Intervention\Image\Exceptions\DecoderException;
use Intervention\Image\Exceptions\RuntimeException;
interface DriverInterface
{
@@ -53,8 +54,8 @@ interface DriverInterface
*
* @param mixed $input
* @param array $decoders
* @return ImageInterface|ColorInterface
* @throws DecoderException
* @return ImageInterface|ColorInterface
*/
public function handleInput(mixed $input, array $decoders = []): ImageInterface|ColorInterface;
@@ -77,7 +78,7 @@ interface DriverInterface
* Check whether all requirements for operating the driver are met and
* throw exception if the check fails.
*
* @throws \Intervention\Image\Exceptions\RuntimeException
* @throws RuntimeException
* @return void
*/
public function checkHealth(): void;

View File

@@ -12,8 +12,8 @@ interface EncoderInterface
* Encode given image
*
* @param ImageInterface $image
* @return EncodedImageInterface
* @throws EncoderException
* @return EncodedImageInterface
*/
public function encode(ImageInterface $image): EncodedImageInterface;
}

View File

@@ -67,8 +67,8 @@ interface ImageInterface extends IteratorAggregate, Countable
* Encode image with given encoder
*
* @param EncoderInterface $encoder
* @return EncodedImageInterface
* @throws EncoderException
* @return EncodedImageInterface
*/
public function encode(EncoderInterface $encoder = new AutoEncoder()): EncodedImageInterface;
@@ -77,8 +77,8 @@ interface ImageInterface extends IteratorAggregate, Countable
* given, the image will be saved at its original location.
*
* @param null|string $path
* @return ImageInterface
* @throws EncoderException
* @return ImageInterface
*/
public function save(?string $path = null, ...$options): self;
@@ -86,8 +86,8 @@ interface ImageInterface extends IteratorAggregate, Countable
* Apply given modifier to current image
*
* @param ModifierInterface $modifier
* @return ImageInterface
* @throws DecoderException
* @return ImageInterface
*/
public function modify(ModifierInterface $modifier): self;
@@ -115,8 +115,8 @@ interface ImageInterface extends IteratorAggregate, Countable
* and the respective frame position is only determined approximately.
*
* @param int|string $position
* @return ImageInterface
* @throws DecoderException
* @return ImageInterface
*/
public function removeAnimation(int|string $position = 0): self;
@@ -125,8 +125,8 @@ interface ImageInterface extends IteratorAggregate, Countable
*
* @param int $offset
* @param null|int $length
* @return ImageInterface
* @throws DecoderException
* @return ImageInterface
*/
public function sliceAnimation(int $offset = 0, ?int $length = null): self;
@@ -172,8 +172,8 @@ interface ImageInterface extends IteratorAggregate, Countable
*
* @param float $x
* @param float $y
* @return ImageInterface
* @throws DecoderException
* @return ImageInterface
*/
public function setResolution(float $x, float $y): self;
@@ -188,8 +188,8 @@ interface ImageInterface extends IteratorAggregate, Countable
* Transform image to given colorspace
*
* @param string|ColorspaceInterface $colorspace
* @return ImageInterface
* @throws DecoderException
* @return ImageInterface
*/
public function setColorspace(string|ColorspaceInterface $colorspace): self;
@@ -225,8 +225,8 @@ interface ImageInterface extends IteratorAggregate, Countable
* which does not support transparency.
*
* @param mixed $color
* @return ImageInterface
* @throws DecoderException
* @return ImageInterface
*/
public function setBlendingColor(mixed $color): self;
@@ -234,8 +234,8 @@ interface ImageInterface extends IteratorAggregate, Countable
* Replace transparent areas of the image with given color
*
* @param mixed $color
* @return ImageInterface
* @throws DecoderException
* @return ImageInterface
*/
public function blendTransparency(mixed $color = null): self;
@@ -250,16 +250,16 @@ interface ImageInterface extends IteratorAggregate, Countable
* Set given icc color profile to image
*
* @param ProfileInterface $profile
* @return ImageInterface
* @throws DecoderException
* @return ImageInterface
*/
public function setProfile(ProfileInterface $profile): self;
/**
* Remove ICC color profile from the current image
*
* @return ImageInterface
* @throws DecoderException
* @return ImageInterface
*/
public function removeProfile(): self;
@@ -268,8 +268,8 @@ interface ImageInterface extends IteratorAggregate, Countable
*
* @param int $limit
* @param mixed $background
* @return ImageInterface
* @throws DecoderException
* @return ImageInterface
*/
public function reduceColors(int $limit, mixed $background = 'transparent'): self;
@@ -277,16 +277,16 @@ interface ImageInterface extends IteratorAggregate, Countable
* Sharpen the current image with given strength
*
* @param int $amount
* @return ImageInterface
* @throws DecoderException
* @return ImageInterface
*/
public function sharpen(int $amount = 10): self;
/**
* Turn image into a greyscale version
*
* @return ImageInterface
* @throws DecoderException
* @return ImageInterface
*/
public function greyscale(): self;
@@ -294,8 +294,8 @@ interface ImageInterface extends IteratorAggregate, Countable
* Adjust brightness of the current image
*
* @param int $level
* @return ImageInterface
* @throws DecoderException
* @return ImageInterface
*/
public function brightness(int $level): self;
@@ -303,8 +303,8 @@ interface ImageInterface extends IteratorAggregate, Countable
* Adjust color contrast of the current image
*
* @param int $level
* @return ImageInterface
* @throws DecoderException
* @return ImageInterface
*/
public function contrast(int $level): self;
@@ -312,8 +312,8 @@ interface ImageInterface extends IteratorAggregate, Countable
* Apply gamma correction on the current image
*
* @param float $gamma
* @return ImageInterface
* @throws DecoderException
* @return ImageInterface
*/
public function gamma(float $gamma): self;
@@ -323,24 +323,24 @@ interface ImageInterface extends IteratorAggregate, Countable
* @param int $red
* @param int $green
* @param int $blue
* @return ImageInterface
* @throws DecoderException
* @return ImageInterface
*/
public function colorize(int $red = 0, int $green = 0, int $blue = 0): self;
/**
* Mirror the current image horizontally
*
* @return ImageInterface
* @throws DecoderException
* @return ImageInterface
*/
public function flip(): self;
/**
* Mirror the current image vertically
*
* @return ImageInterface
* @throws DecoderException
* @return ImageInterface
*/
public function flop(): self;
@@ -348,16 +348,16 @@ interface ImageInterface extends IteratorAggregate, Countable
* Blur current image by given strength
*
* @param int $amount
* @return ImageInterface
* @throws DecoderException
* @return ImageInterface
*/
public function blur(int $amount = 5): self;
/**
* Invert the colors of the current image
*
* @return ImageInterface
* @throws DecoderException
* @return ImageInterface
*/
public function invert(): self;
@@ -365,8 +365,8 @@ interface ImageInterface extends IteratorAggregate, Countable
* Apply pixelation filter effect on current image
*
* @param int $size
* @return ImageInterface
* @throws DecoderException
* @return ImageInterface
*/
public function pixelate(int $size): self;
@@ -375,8 +375,8 @@ interface ImageInterface extends IteratorAggregate, Countable
*
* @param float $angle
* @param string $background
* @return ImageInterface
* @throws DecoderException
* @return ImageInterface
*/
public function rotate(float $angle, mixed $background = 'ffffff'): self;
@@ -387,8 +387,8 @@ interface ImageInterface extends IteratorAggregate, Countable
* @param int $x
* @param int $y
* @param callable|FontInterface $font
* @return ImageInterface
* @throws DecoderException
* @return ImageInterface
*/
public function text(string $text, int $x, int $y, callable|FontInterface $font): self;
@@ -397,8 +397,8 @@ interface ImageInterface extends IteratorAggregate, Countable
*
* @param null|int $width
* @param null|int $height
* @return ImageInterface
* @throws DecoderException
* @return ImageInterface
*/
public function resize(?int $width = null, ?int $height = null): self;
@@ -407,8 +407,8 @@ interface ImageInterface extends IteratorAggregate, Countable
*
* @param null|int $width
* @param null|int $height
* @return ImageInterface
* @throws DecoderException
* @return ImageInterface
*/
public function resizeDown(?int $width = null, ?int $height = null): self;
@@ -417,8 +417,8 @@ interface ImageInterface extends IteratorAggregate, Countable
*
* @param null|int $width
* @param null|int $height
* @return ImageInterface
* @throws DecoderException
* @return ImageInterface
*/
public function scale(?int $width = null, ?int $height = null): self;
@@ -428,8 +428,8 @@ interface ImageInterface extends IteratorAggregate, Countable
*
* @param null|int $width
* @param null|int $height
* @return ImageInterface
* @throws DecoderException
* @return ImageInterface
*/
public function scaleDown(?int $width = null, ?int $height = null): self;
@@ -441,8 +441,8 @@ interface ImageInterface extends IteratorAggregate, Countable
* @param int $width
* @param int $height
* @param string $position
* @return ImageInterface
* @throws DecoderException
* @return ImageInterface
*/
public function cover(int $width, int $height, string $position = 'center'): self;
@@ -452,8 +452,8 @@ interface ImageInterface extends IteratorAggregate, Countable
* @param int $width
* @param int $height
* @param string $position
* @return ImageInterface
* @throws DecoderException
* @return ImageInterface
*/
public function coverDown(int $width, int $height, string $position = 'center'): self;
@@ -467,8 +467,8 @@ interface ImageInterface extends IteratorAggregate, Countable
* @param null|int $height
* @param string $position
* @param mixed $background
* @return ImageInterface
* @throws DecoderException
* @return ImageInterface
*/
public function resizeCanvas(
?int $width = null,
@@ -486,8 +486,8 @@ interface ImageInterface extends IteratorAggregate, Countable
* @param null|int $height
* @param string $position
* @param mixed $background
* @return ImageInterface
* @throws DecoderException
* @return ImageInterface
*/
public function resizeCanvasRelative(
?int $width = null,
@@ -509,8 +509,8 @@ interface ImageInterface extends IteratorAggregate, Countable
* @param int $height
* @param string $background
* @param string $position
* @return ImageInterface
* @throws DecoderException
* @return ImageInterface
*/
public function pad(
int $width,
@@ -527,8 +527,8 @@ interface ImageInterface extends IteratorAggregate, Countable
* @param int $height
* @param string $background
* @param string $position
* @return ImageInterface
* @throws DecoderException
* @return ImageInterface
*/
public function contain(
int $width,
@@ -548,8 +548,8 @@ interface ImageInterface extends IteratorAggregate, Countable
* @param int $offset_y
* @param mixed $background
* @param string $position
* @return ImageInterface
* @throws DecoderException
* @return ImageInterface
*/
public function crop(
int $width,
@@ -568,8 +568,8 @@ interface ImageInterface extends IteratorAggregate, Countable
* @param int $offset_x
* @param int $offset_y
* @param int $opacity
* @return ImageInterface
* @throws DecoderException
* @return ImageInterface
*/
public function place(
mixed $element,
@@ -592,8 +592,8 @@ interface ImageInterface extends IteratorAggregate, Countable
* @param mixed $color
* @param null|int $x
* @param null|int $y
* @return ImageInterface
* @throws DecoderException
* @return ImageInterface
*/
public function fill(mixed $color, ?int $x = null, ?int $y = null): self;
@@ -603,8 +603,8 @@ interface ImageInterface extends IteratorAggregate, Countable
* @param int $x
* @param int $y
* @param mixed $color
* @return ImageInterface
* @throws DecoderException
* @return ImageInterface
*/
public function drawPixel(int $x, int $y, mixed $color): self;
@@ -614,8 +614,8 @@ interface ImageInterface extends IteratorAggregate, Countable
* @param int $x
* @param int $y
* @param callable $init
* @return ImageInterface
* @throws DecoderException
* @return ImageInterface
*/
public function drawRectangle(int $x, int $y, callable $init): self;
@@ -625,8 +625,8 @@ interface ImageInterface extends IteratorAggregate, Countable
* @param int $x
* @param int $y
* @param callable $init
* @return ImageInterface
* @throws DecoderException
* @return ImageInterface
*/
public function drawEllipse(int $x, int $y, callable $init): self;
@@ -636,8 +636,8 @@ interface ImageInterface extends IteratorAggregate, Countable
* @param int $x
* @param int $y
* @param callable $init
* @return ImageInterface
* @throws DecoderException
* @return ImageInterface
*/
public function drawCircle(int $x, int $y, callable $init): self;
@@ -645,8 +645,8 @@ interface ImageInterface extends IteratorAggregate, Countable
* Draw a polygon on the current image
*
* @param callable $init
* @return ImageInterface
* @throws DecoderException
* @return ImageInterface
*/
public function drawPolygon(callable $init): self;
@@ -654,8 +654,8 @@ interface ImageInterface extends IteratorAggregate, Countable
* Draw a line on the current image
*
* @param callable $init
* @return ImageInterface
* @throws DecoderException
* @return ImageInterface
*/
public function drawLine(callable $init): self;
@@ -664,8 +664,8 @@ interface ImageInterface extends IteratorAggregate, Countable
* will be encoded to the format of the originally read image.
*
* @param null|string $type
* @return EncodedImageInterface
* @throws EncoderException
* @return EncodedImageInterface
*/
public function encodeByMediaType(?string $type = null, ...$options): EncodedImageInterface;
@@ -675,8 +675,8 @@ interface ImageInterface extends IteratorAggregate, Countable
* originally read image.
*
* @param null|string $extension
* @return EncodedImageInterface
* @throws EncoderException
* @return EncodedImageInterface
*/
public function encodeByExtension(?string $extension = null, mixed ...$options): EncodedImageInterface;
@@ -686,8 +686,8 @@ interface ImageInterface extends IteratorAggregate, Countable
* the format of the originally read image.
*
* @param null|string $path
* @return EncodedImageInterface
* @throws EncoderException
* @return EncodedImageInterface
*/
public function encodeByPath(?string $path = null, mixed ...$options): EncodedImageInterface;
@@ -695,8 +695,8 @@ interface ImageInterface extends IteratorAggregate, Countable
* Encode image to JPEG format
*
* @param mixed $options
* @return EncodedImageInterface
* @throws EncoderException
* @return EncodedImageInterface
*/
public function toJpeg(mixed ...$options): EncodedImageInterface;
@@ -705,8 +705,8 @@ interface ImageInterface extends IteratorAggregate, Countable
* Encode image to Jpeg2000 format
*
* @param mixed $options
* @return EncodedImageInterface
* @throws EncoderException
* @return EncodedImageInterface
*/
public function toJpeg2000(mixed ...$options): EncodedImageInterface;
@@ -714,8 +714,8 @@ interface ImageInterface extends IteratorAggregate, Countable
* Encode image to Webp format
*
* @param mixed $options
* @return EncodedImageInterface
* @throws EncoderException
* @return EncodedImageInterface
*/
public function toWebp(mixed ...$options): EncodedImageInterface;
@@ -723,8 +723,8 @@ interface ImageInterface extends IteratorAggregate, Countable
* Encode image to PNG format
*
* @param mixed $options
* @return EncodedImageInterface
* @throws EncoderException
* @return EncodedImageInterface
*/
public function toPng(mixed ...$options): EncodedImageInterface;
@@ -732,8 +732,8 @@ interface ImageInterface extends IteratorAggregate, Countable
* Encode image to GIF format
*
* @param mixed $options
* @return EncodedImageInterface
* @throws EncoderException
* @return EncodedImageInterface
*/
public function toGif(mixed ...$options): EncodedImageInterface;
@@ -741,8 +741,8 @@ interface ImageInterface extends IteratorAggregate, Countable
* Encode image to Bitmap format
*
* @param mixed $options
* @return EncodedImageInterface
* @throws EncoderException
* @return EncodedImageInterface
*/
public function toBitmap(mixed ...$options): EncodedImageInterface;
@@ -750,8 +750,8 @@ interface ImageInterface extends IteratorAggregate, Countable
* Encode image to AVIF format
*
* @param mixed $options
* @return EncodedImageInterface
* @throws EncoderException
* @return EncodedImageInterface
*/
public function toAvif(mixed ...$options): EncodedImageInterface;
@@ -759,8 +759,8 @@ interface ImageInterface extends IteratorAggregate, Countable
* Encode image to TIFF format
*
* @param mixed $options
* @return EncodedImageInterface
* @throws EncoderException
* @return EncodedImageInterface
*/
public function toTiff(mixed ...$options): EncodedImageInterface;
@@ -768,8 +768,8 @@ interface ImageInterface extends IteratorAggregate, Countable
* Encode image to HEIC format
*
* @param mixed $options
* @return EncodedImageInterface
* @throws EncoderException
* @return EncodedImageInterface
*/
public function toHeic(mixed ...$options): EncodedImageInterface;
}

View File

@@ -12,8 +12,8 @@ interface InputHandlerInterface
* Try to decode the given input with each decoder of the the handler chain
*
* @param mixed $input
* @return ImageInterface|ColorInterface
* @throws DecoderException
* @return ImageInterface|ColorInterface
*/
public function handle($input): ImageInterface|ColorInterface;
}

View File

@@ -12,8 +12,8 @@ interface ModifierInterface
* Apply modifications of the current modifier to the given image
*
* @param ImageInterface $image
* @return ImageInterface
* @throws DecoderException
* @return ImageInterface
*/
public function apply(ImageInterface $image): ImageInterface;
}