class Image extends AbstractImage

Image implementation using the Imagick PHP extension.

Properties

protected MetadataBag $metadata from AbstractImage

Methods

thumbnail(BoxInterface $size, int|string $settings = ImageInterface::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.

int[]
getAllThumbnailModes()

Get all the available thumbnail modes.

array
updateSaveOptions(array $options)

Updates a given array of save options for backward compatibility with legacy names.

metadata()

Returns the Image's meta data.

__clone()

Clones all the resources associated to this instance.

getClassFactory()

Get the class factory instance to be used.

$this
setClassFactory(ClassFactoryInterface $classFactory)

Set the class factory instance to be used.

__construct(Imagick $imagick, PaletteInterface $palette, MetadataBag $metadata)

Constructs a new Image instance.

__destruct()

Destroys allocated imagick resources.

Imagick
getImagick()

Returns the underlying \Imagick instance.

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
flipHorizontally()

Flips current image using vertical axis.

$this
flipVertically()

Flips current image using horizontal axis.

$this
strip()

Remove all profiles and comments.

$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
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
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.

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

Returns the image content as a binary string.

$this
interlace(string $scheme)

Enables or disables interlacing.

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.

$this
applyMask(ImageInterface $mask)

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

mask()

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

$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.

histogram()

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

getColorAt(PointInterface $point)

Returns color at specified positions of current image.

pixelToColor(ImagickPixel $pixel)

Returns a color given a pixel, depending the Palette context.

layers()

Returns the image layers when applicable.

$this
usePalette(PaletteInterface $palette)

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

palette()

Return the current color palette.

$this
profile(ProfileInterface $profile)

Applies a color profile on the Image.

Imagick
cloneImagick()

Clone the Imagick resource of this instance.

Details

in AbstractImage at line 36
ManipulatorInterface thumbnail(BoxInterface $size, int|string $settings = ImageInterface::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

See also

ManipulatorInterface::thumbnail

in AbstractImage at line 146
protected int[] getAllThumbnailModes()

Get all the available thumbnail modes.

Return Value

int[]

in AbstractImage at line 161
protected array updateSaveOptions(array $options)

Updates a given array of save options for backward compatibility with legacy names.

Parameters

array $options

Return Value

array

in AbstractImage at line 176
MetadataBag metadata()

Returns the Image's meta data.

Return Value

MetadataBag

See also

ImageInterface::metadata

at line 94
__clone()

Clones all the resources associated to this instance.

in AbstractImage at line 196
ClassFactoryInterface getClassFactory()

Get the class factory instance to be used.

in AbstractImage at line 210
$this setClassFactory(ClassFactoryInterface $classFactory)

Set the class factory instance to be used.

Parameters

ClassFactoryInterface $classFactory

Return Value

$this

See also

ClassFactoryAwareInterface::setClassFactory

at line 78
__construct(Imagick $imagick, PaletteInterface $palette, MetadataBag $metadata)

Constructs a new Image instance.

Parameters

Imagick $imagick
PaletteInterface $palette
MetadataBag $metadata

at line 109
__destruct()

Destroys allocated imagick resources.

at line 122
Imagick getImagick()

Returns the underlying \Imagick instance.

Return Value

Imagick

at line 132
ManipulatorInterface copy()

Copies current source image into a new ImageInterface instance.

at line 146
$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

See also

ManipulatorInterface::crop

at line 178
$this flipHorizontally()

Flips current image using vertical axis.

Return Value

$this

Exceptions

RuntimeException

See also

ManipulatorInterface::flipHorizontally

at line 194
$this flipVertically()

Flips current image using horizontal axis.

Return Value

$this

Exceptions

RuntimeException

See also

ManipulatorInterface::flipVertically

at line 210
$this strip()

Remove all profiles and comments.

Return Value

$this

Exceptions

RuntimeException

See also

ManipulatorInterface::strip

at line 232
$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

See also

ManipulatorInterface::paste

at line 282
$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

See also

ManipulatorInterface::resize

at line 306
$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

See also

ManipulatorInterface::rotate

at line 332
$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

See also

ManipulatorInterface::save

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

Outputs the image content.

Parameters

string $format
array $options

Return Value

$this

Exceptions

RuntimeException

See also

ManipulatorInterface::show

at line 367
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

See also

ImageInterface::get

at line 384
$this interlace(string $scheme)

Enables or disables interlacing.

Parameters

string $scheme

Return Value

$this

Exceptions

InvalidArgumentException When an unsupported Interface type is supplied

See also

ImageInterface::interlace

at line 436
string __toString()

Returns the image content as a PNG binary string.

Return Value

string binary

Exceptions

RuntimeException

See also

ImageInterface::__toString

at line 446
DrawerInterface draw()

Instantiates and returns a DrawerInterface instance for image drawing.

Return Value

DrawerInterface

See also

ImageInterface::draw

at line 456
EffectsInterface effects()

at line 466
BoxInterface getSize()

Returns current image size.

Return Value

BoxInterface

See also

ImageInterface::getSize

at line 486
$this applyMask(ImageInterface $mask)

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

Parameters

ImageInterface $mask

Return Value

$this

See also

ManipulatorInterface::applyMask

at line 521
ImageInterface mask()

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

Return Value

ImageInterface

See also

ImageInterface::mask

at line 540
$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

See also

ManipulatorInterface::fill

at line 571
ColorInterface[] histogram()

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

Return Value

ColorInterface[]

See also

ImageInterface::histogram

at line 591
ColorInterface getColorAt(PointInterface $point)

Returns color at specified positions of current image.

Parameters

PointInterface $point

Return Value

ColorInterface

Exceptions

RuntimeException

See also

ImageInterface::getColorAt

at line 617
ColorInterface pixelToColor(ImagickPixel $pixel)

Returns a color given a pixel, depending the Palette context.

Note : this method is public for PHP 5.3 compatibility

Parameters

ImagickPixel $pixel

Return Value

ColorInterface

Exceptions

InvalidArgumentException In case a unknown color is requested

at line 652
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

See also

ImageInterface::layers

at line 666
$this usePalette(PaletteInterface $palette)

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

Parameters

PaletteInterface $palette

Return Value

$this

Exceptions

RuntimeException

See also

ImageInterface::usePalette

at line 705
PaletteInterface palette()

Return the current color palette.

at line 715
$this profile(ProfileInterface $profile)

Applies a color profile on the Image.

Parameters

ProfileInterface $profile

Return Value

$this

Exceptions

RuntimeException

See also

ImageInterface::profile

at line 1071
protected Imagick cloneImagick()

Clone the Imagick resource of this instance.

Return Value

Imagick

Exceptions

ImagickException