interface ImageInterface implements ManipulatorInterface

The image interface.

Constants

RESOLUTION_PIXELSPERINCH

Resolution units: pixels per inch.

RESOLUTION_PIXELSPERCENTIMETER

Resolution units: pixels per centimeter.

INTERLACE_NONE

Image interlacing: none.

INTERLACE_LINE

Image interlacing: scanline.

INTERLACE_PLANE

Image interlacing: plane.

INTERLACE_PARTITION

Image interlacing: like plane interlacing except the different planes are saved to individual files.

FILTER_UNDEFINED

Image filter: none/undefined.

FILTER_POINT

Resampling filter: point (interpolated).

FILTER_BOX

Resampling filter: box.

FILTER_TRIANGLE

Resampling filter: triangle.

FILTER_HERMITE

Resampling filter: hermite.

FILTER_HANNING

Resampling filter: hanning.

FILTER_HAMMING

Resampling filter: hamming.

FILTER_BLACKMAN

Resampling filter: blackman.

FILTER_GAUSSIAN

Resampling filter: gaussian.

FILTER_QUADRATIC

Resampling filter: quadratic.

FILTER_CUBIC

Resampling filter: cubic.

FILTER_CATROM

Resampling filter: catrom.

FILTER_MITCHELL

Resampling filter: mitchell.

FILTER_LANCZOS

Resampling filter: lanczos.

FILTER_BESSEL

Resampling filter: bessel.

FILTER_SINC

Resampling filter: sinc.

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.

string
get(string $format, array $options = array())

Returns the image content as a binary string.

string
__toString()

Returns the image content as a PNG binary string.

draw()

Instantiates and returns a DrawerInterface instance for image drawing.

effects()

No description

getSize()

Returns current image size.

mask()

Transforms creates a grayscale mask from current image, returns a new image, while keeping the existing image unmodified.

histogram()

Returns array of image colors as Imagine\Image\Palette\Color\ColorInterface instances.

getColorAt(PointInterface $point)

Returns color at specified positions of current image.

layers()

Returns the image layers when applicable.

$this
interlace(string $scheme)

Enables or disables interlacing.

palette()

Return the current color palette.

$this
usePalette(PaletteInterface $palette)

Set a palette for the image. Useful to change colorspace.

$this
profile(ProfileInterface $profile)

Applies a color profile on the Image.

metadata()

Returns the Image's meta data.

Details

in ManipulatorInterface at line 57
ManipulatorInterface copy()

Copies current source image into a new ImageInterface instance.

Return Value

ManipulatorInterface

Exceptions

RuntimeException

in ManipulatorInterface 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

in ManipulatorInterface 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

in ManipulatorInterface 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

in ManipulatorInterface 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

in ManipulatorInterface 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

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

Outputs the image content.

Parameters

string $format
array $options

Return Value

$this

Exceptions

RuntimeException

in ManipulatorInterface at line 151
$this flipHorizontally()

Flips current image using vertical axis.

Return Value

$this

Exceptions

RuntimeException

in ManipulatorInterface at line 160
$this flipVertically()

Flips current image using horizontal axis.

Return Value

$this

Exceptions

RuntimeException

in ManipulatorInterface at line 169
$this strip()

Remove all profiles and comments.

Return Value

$this

Exceptions

RuntimeException

in ManipulatorInterface 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

in ManipulatorInterface at line 192
$this applyMask(ImageInterface $mask)

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

Parameters

ImageInterface $mask

Return Value

$this

in ManipulatorInterface 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

at line 185
string get(string $format, array $options = array())

Returns the image content as a binary string.

Parameters

string $format
array $options

Return Value

string binary

Exceptions

RuntimeException

at line 194
string __toString()

Returns the image content as a PNG binary string.

Return Value

string binary

Exceptions

RuntimeException

at line 201
DrawerInterface draw()

Instantiates and returns a DrawerInterface instance for image drawing.

Return Value

DrawerInterface

at line 206
EffectsInterface effects()

Return Value

EffectsInterface

at line 213
BoxInterface getSize()

Returns current image size.

Return Value

BoxInterface

at line 221
ImageInterface mask()

Transforms creates a grayscale mask from current image, returns a new image, while keeping the existing image unmodified.

Return Value

ImageInterface

at line 228
ColorInterface[] histogram()

Returns array of image colors as Imagine\Image\Palette\Color\ColorInterface instances.

Return Value

ColorInterface[]

at line 239
ColorInterface getColorAt(PointInterface $point)

Returns color at specified positions of current image.

Parameters

PointInterface $point

Return Value

ColorInterface

Exceptions

RuntimeException

at line 249
LayersInterface layers()

Returns the image layers when applicable.

Return Value

LayersInterface

Exceptions

RuntimeException In case the layer can not be returned
OutOfBoundsException In case the index is not a valid value

at line 260
$this interlace(string $scheme)

Enables or disables interlacing.

Parameters

string $scheme

Return Value

$this

Exceptions

InvalidArgumentException When an unsupported Interface type is supplied

at line 267
PaletteInterface palette()

Return the current color palette.

Return Value

PaletteInterface

at line 278
$this usePalette(PaletteInterface $palette)

Set a palette for the image. Useful to change colorspace.

Parameters

PaletteInterface $palette

Return Value

$this

Exceptions

RuntimeException

at line 289
$this profile(ProfileInterface $profile)

Applies a color profile on the Image.

Parameters

ProfileInterface $profile

Return Value

$this

Exceptions

RuntimeException

at line 296
MetadataBag metadata()

Returns the Image's meta data.

Return Value

MetadataBag