interface ManipulatorInterface

The manipulator interface.

Constants

THUMBNAIL_INSET

The original image is scaled so it is fully contained within the thumbnail dimensions (the image width/height ratio doesn't change).

THUMBNAIL_OUTBOUND

The thumbnail is scaled so that its smallest side equals the length of the corresponding side in the original image (the width or the height are cropped).

THUMBNAIL_FLAG_UPSCALE

Allow upscaling the image if it's smaller than the wanted thumbnail size.

THUMBNAIL_FLAG_NOCLONE

Instead of creating a new image instance, the thumbnail method modifies the original image (saving memory.

Methods

copy()

Copies current source image into a new ImageInterface instance.

$this
crop(PointInterface $start, BoxInterface $size)

Crops a specified box out of the source image (modifies the source image) Returns cropped self.

$this
resize(BoxInterface $size, string $filter = ImageInterface::FILTER_UNDEFINED)

Resizes current image and returns self.

$this
rotate(int $angle, ColorInterface $background = null)

Rotates an image at the given angle.

$this
paste(ImageInterface $image, PointInterface $start, int $alpha = 100)

Pastes an image into a parent image Throws exceptions if image exceeds parent image borders or if paste operation fails.

$this
save(string $path = null, array $options = array())

Saves the image at a specified path, the target file extension is used to determine file format, only jpg, jpeg, gif, png, wbmp, xbm, webp and bmp are supported.

$this
show(string $format, array $options = array())

Outputs the image content.

$this
flipHorizontally()

Flips current image using vertical axis.

$this
flipVertically()

Flips current image using horizontal axis.

$this
strip()

Remove all profiles and comments.

thumbnail(BoxInterface $size, int|string $settings = self::THUMBNAIL_INSET, string $filter = ImageInterface::FILTER_UNDEFINED)

Generates a thumbnail from a current image Returns it as a new image without modifying the current image unless the THUMBNAIL_FLAG_NOCLONE flag is specified.

$this
applyMask(ImageInterface $mask)

Applies a given mask to current image's alpha channel.

$this
fill(FillInterface $fill)

Fills image with provided filling, by replacing each pixel's color in the current image with corresponding color from FillInterface, and returns modified image.

Details

at line 57
ManipulatorInterface copy()

Copies current source image into a new ImageInterface instance.

Return Value

ManipulatorInterface

Exceptions

RuntimeException

at line 71
$this crop(PointInterface $start, BoxInterface $size)

Crops a specified box out of the source image (modifies the source image) Returns cropped self.

Parameters

PointInterface $start
BoxInterface $size

Return Value

$this

Exceptions

OutOfBoundsException
RuntimeException

at line 83
$this resize(BoxInterface $size, string $filter = ImageInterface::FILTER_UNDEFINED)

Resizes current image and returns self.

Parameters

BoxInterface $size
string $filter

Return Value

$this

Exceptions

RuntimeException

at line 97
$this rotate(int $angle, ColorInterface $background = null)

Rotates an image at the given angle.

Optional $background can be used to specify the fill color of the empty area of rotated image.

Parameters

int $angle
ColorInterface $background

Return Value

$this

Exceptions

RuntimeException

at line 115
$this paste(ImageInterface $image, PointInterface $start, int $alpha = 100)

Pastes an image into a parent image Throws exceptions if image exceeds parent image borders or if paste operation fails.

Returns source image

Parameters

ImageInterface $image
PointInterface $start
int $alpha How to paste the image, from 0 (fully transparent) to 100 (fully opaque)

Return Value

$this

Exceptions

InvalidArgumentException
RuntimeException

at line 130
$this save(string $path = null, array $options = array())

Saves the image at a specified path, the target file extension is used to determine file format, only jpg, jpeg, gif, png, wbmp, xbm, webp and bmp are supported.

Please remark that bmp is supported by the GD driver only since PHP 7.2.

Parameters

string $path
array $options

Return Value

$this

Exceptions

RuntimeException

at line 142
$this show(string $format, array $options = array())

Outputs the image content.

Parameters

string $format
array $options

Return Value

$this

Exceptions

RuntimeException

at line 151
$this flipHorizontally()

Flips current image using vertical axis.

Return Value

$this

Exceptions

RuntimeException

at line 160
$this flipVertically()

Flips current image using horizontal axis.

Return Value

$this

Exceptions

RuntimeException

at line 169
$this strip()

Remove all profiles and comments.

Return Value

$this

Exceptions

RuntimeException

at line 183
ManipulatorInterface thumbnail(BoxInterface $size, int|string $settings = self::THUMBNAIL_INSET, string $filter = ImageInterface::FILTER_UNDEFINED)

Generates a thumbnail from a current image Returns it as a new image without modifying the current image unless the THUMBNAIL_FLAG_NOCLONE flag is specified.

Parameters

BoxInterface $size
int|string $settings One or more of the ManipulatorInterface::THUMBNAIL_ flags (joined with |). It may be a string for backward compatibility with old constant values that were strings.
string $filter The filter to use for resizing, one of ImageInterface::FILTER_*

Return Value

ManipulatorInterface

Exceptions

RuntimeException

at line 192
$this applyMask(ImageInterface $mask)

Applies a given mask to current image's alpha channel.

Parameters

ImageInterface $mask

Return Value

$this

at line 203
$this fill(FillInterface $fill)

Fills image with provided filling, by replacing each pixel's color in the current image with corresponding color from FillInterface, and returns modified image.

Parameters

FillInterface $fill

Return Value

$this