Image
extends AbstractImage
in package
implements
InfoProvider
Image implementation using the Imagick PHP extension.
Table of Contents
Interfaces
- InfoProvider
- Interface implemented by classes that provide info about a graphics driver.
Properties
- $metadata : MetadataBag
- $classFactory : ClassFactoryInterface|null
- $colorspaceMapping : array<string|int, mixed>
- $imagick : Imagick
- $layers : Layers|null
- $palette : PaletteInterface
Methods
- __clone() : mixed
- Clones all the resources associated to this instance.
- __construct() : mixed
- Constructs a new Image instance.
- __destruct() : mixed
- Destroys allocated imagick resources.
- __toString() : string
- Returns the image content as a PNG binary string.
- applyMask() : $this
- Applies a given mask to current image's alpha channel.
- copy() : static
- Copies current source image into a new ImageInterface instance.
- crop() : $this
- Crops a specified box out of the source image (modifies the source image) Returns cropped self.
- draw() : DrawerInterface|AlphaBlendingAwareDrawerInterface
- Instantiates and returns a DrawerInterface instance for image drawing.
- effects() : EffectsInterface
- fill() : $this
- Fills image with provided filling, by replacing each pixel's color in the current image with corresponding color from FillInterface, and returns modified image.
- flipHorizontally() : $this
- Flips current image using vertical axis.
- flipVertically() : $this
- Flips current image using horizontal axis.
- get() : string
- Returns the image content as a binary string.
- getClassFactory() : ClassFactoryInterface
- Get the class factory instance to be used.
- getColorAt() : ColorInterface
- Returns color at specified positions of current image.
- getDriverInfo() : Info|null
- Get the info about this driver.
- getImagick() : Imagick
- Returns the underlying \Imagick instance.
- getSize() : BoxInterface
- Returns current image size.
- histogram() : array<string|int, ColorInterface>
- Returns array of image colors as Imagine\Image\Palette\Color\ColorInterface instances.
- interlace() : $this
- Enables or disables interlacing.
- layers() : LayersInterface
- Returns the image layers when applicable.
- mask() : static
- Transforms creates a grayscale mask from current image, returns a new image, while keeping the existing image unmodified.
- metadata() : MetadataBag
- Returns the Image's meta data.
- palette() : PaletteInterface
- Return the current color palette.
- paste() : $this
- Pastes an image into a parent image Throws exceptions if image exceeds parent image borders or if paste operation fails.
- pixelToColor() : ColorInterface
- Returns a color given a pixel, depending the Palette context.
- profile() : $this
- Applies a color profile on the Image.
- resize() : $this
- Resizes current image and returns self.
- rotate() : $this
- Rotates an image at the given angle.
- save() : $this
- 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.
- setClassFactory() : $this
- Set the class factory instance to be used.
- show() : $this
- Outputs the image content.
- strip() : $this
- Remove all profiles and comments.
- thumbnail() : static
- 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.
- usePalette() : $this
- Set a palette for the image. Useful to change colorspace.
- cloneImagick() : Imagick
- Clone the Imagick resource of this instance.
- getAllFilterValues() : array<string|int, string>
- Get all the available filter defined in ImageInterface.
- getAllThumbnailModes() : array<string|int, int>
- Get all the available thumbnail modes.
- updateSaveOptions() : array<string|int, mixed>
- Updates a given array of save options for backward compatibility with legacy names.
- applyFastLinear() : mixed
- Performs optimized gradient fill for non-opaque linear gradients.
- applyImageOptions() : Imagick
- Applies options before save or output.
- checkThumbnailSettings() : mixed
- Check the settings argument in thumbnail() method.
- flatten() : mixed
- Flatten the image.
- getColor() : ImagickPixel
- Gets specifically formatted color string from Color instance.
- getFilter() : string
- Returns the filter if it's supported.
- isLinearOpaque() : bool
- Checks whether given $fill is linear and opaque.
- prepareOutput() : mixed
- setColorspace() : mixed
- Sets colorspace and image type, assigns the palette.
Properties
$metadata
protected
MetadataBag
$metadata
$classFactory
private
ClassFactoryInterface|null
$classFactory
$colorspaceMapping
private
static array<string|int, mixed>
$colorspaceMapping
= array(\Imagine\Image\Palette\PaletteInterface::PALETTE_CMYK => \Imagick::COLORSPACE_CMYK, \Imagine\Image\Palette\PaletteInterface::PALETTE_RGB => \Imagick::COLORSPACE_RGB, \Imagine\Image\Palette\PaletteInterface::PALETTE_GRAYSCALE => \Imagick::COLORSPACE_GRAY)
$imagick
private
Imagick
$imagick
$layers
private
Layers|null
$layers
$palette
private
PaletteInterface
$palette
Methods
__clone()
Clones all the resources associated to this instance.
public
__clone() : mixed
Tags
__construct()
Constructs a new Image instance.
public
__construct(Imagick $imagick, PaletteInterface $palette, MetadataBag $metadata) : mixed
Parameters
- $imagick : Imagick
- $palette : PaletteInterface
- $metadata : MetadataBag
__destruct()
Destroys allocated imagick resources.
public
__destruct() : mixed
__toString()
Returns the image content as a PNG binary string.
public
__toString() : string
Tags
Return values
string —binary
applyMask()
Applies a given mask to current image's alpha channel.
public
applyMask(ImageInterface $mask) : $this
Parameters
- $mask : ImageInterface
Tags
Return values
$thiscopy()
Copies current source image into a new ImageInterface instance.
public
copy() : static
Tags
Return values
staticcrop()
Crops a specified box out of the source image (modifies the source image) Returns cropped self.
public
crop(PointInterface $start, BoxInterface $size) : $this
Parameters
- $start : PointInterface
- $size : BoxInterface
Tags
Return values
$thisdraw()
Instantiates and returns a DrawerInterface instance for image drawing.
public
draw() : DrawerInterface|AlphaBlendingAwareDrawerInterface
Tags
Return values
DrawerInterface|AlphaBlendingAwareDrawerInterfaceeffects()
public
effects() : EffectsInterface
Tags
Return values
EffectsInterfacefill()
Fills image with provided filling, by replacing each pixel's color in the current image with corresponding color from FillInterface, and returns modified image.
public
fill(FillInterface $fill) : $this
Parameters
- $fill : FillInterface
Tags
Return values
$thisflipHorizontally()
Flips current image using vertical axis.
public
flipHorizontally() : $this
Tags
Return values
$thisflipVertically()
Flips current image using horizontal axis.
public
flipVertically() : $this
Tags
Return values
$thisget()
Returns the image content as a binary string.
public
get(mixed $format[, array<string|int, mixed> $options = array() ]) : string
Parameters
- $format : mixed
- $options : array<string|int, mixed> = array()
Tags
Return values
string —binary
getClassFactory()
Get the class factory instance to be used.
public
getClassFactory() : ClassFactoryInterface
Tags
Return values
ClassFactoryInterfacegetColorAt()
Returns color at specified positions of current image.
public
getColorAt(PointInterface $point) : ColorInterface
Parameters
- $point : PointInterface
Tags
Return values
ColorInterfacegetDriverInfo()
Get the info about this driver.
public
static getDriverInfo([mixed $required = true ]) : Info|null
Parameters
- $required : mixed = true
-
when the driver is not available: if FALSE the function returns NULL, if TRUE the driver throws a \Imagine\Exception\NotSupportedException
Tags
Return values
Info|nullgetImagick()
Returns the underlying \Imagick instance.
public
getImagick() : Imagick
Return values
ImagickgetSize()
Returns current image size.
public
getSize() : BoxInterface
Tags
Return values
BoxInterfacehistogram()
Returns array of image colors as Imagine\Image\Palette\Color\ColorInterface instances.
public
histogram() : array<string|int, ColorInterface>
Tags
Return values
array<string|int, ColorInterface>interlace()
Enables or disables interlacing.
public
interlace(mixed $scheme) : $this
Parameters
- $scheme : mixed
Tags
Return values
$thislayers()
Returns the image layers when applicable.
public
layers() : LayersInterface
Tags
Return values
LayersInterfacemask()
Transforms creates a grayscale mask from current image, returns a new image, while keeping the existing image unmodified.
public
mask() : static
Tags
Return values
staticmetadata()
Returns the Image's meta data.
public
metadata() : MetadataBag
Tags
Return values
MetadataBagpalette()
Return the current color palette.
public
palette() : PaletteInterface
Tags
Return values
PaletteInterfacepaste()
Pastes an image into a parent image Throws exceptions if image exceeds parent image borders or if paste operation fails.
public
paste(ImageInterface $image, PointInterface $start[, mixed $alpha = 100 ]) : $this
Parameters
- $image : ImageInterface
- $start : PointInterface
- $alpha : mixed = 100
-
How to paste the image, from 0 (fully transparent) to 100 (fully opaque)
Tags
Return values
$thispixelToColor()
Returns a color given a pixel, depending the Palette context.
public
pixelToColor(ImagickPixel $pixel) : ColorInterface
Note : this method is public for PHP 5.3 compatibility
Parameters
- $pixel : ImagickPixel
Tags
Return values
ColorInterfaceprofile()
Applies a color profile on the Image.
public
profile(ProfileInterface $profile) : $this
Parameters
- $profile : ProfileInterface
Tags
Return values
$thisresize()
Resizes current image and returns self.
public
resize(BoxInterface $size[, mixed $filter = ImageInterface::FILTER_UNDEFINED ]) : $this
Parameters
- $size : BoxInterface
- $filter : mixed = ImageInterface::FILTER_UNDEFINED
Tags
Return values
$thisrotate()
Rotates an image at the given angle.
public
rotate(mixed $angle[, ColorInterface $background = null ]) : $this
Parameters
- $angle : mixed
- $background : ColorInterface = null
Tags
Return values
$thissave()
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.
public
save([mixed $path = null ][, array<string|int, mixed> $options = array() ]) : $this
Parameters
- $path : mixed = null
- $options : array<string|int, mixed> = array()
Tags
Return values
$thissetClassFactory()
Set the class factory instance to be used.
public
setClassFactory(ClassFactoryInterface $classFactory) : $this
Parameters
- $classFactory : ClassFactoryInterface
Tags
Return values
$thisshow()
Outputs the image content.
public
show(mixed $format[, array<string|int, mixed> $options = array() ]) : $this
Parameters
- $format : mixed
- $options : array<string|int, mixed> = array()
Tags
Return values
$thisstrip()
Remove all profiles and comments.
public
strip() : $this
Tags
Return values
$thisthumbnail()
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.
public
thumbnail(BoxInterface $size[, mixed $settings = ImageInterface::THUMBNAIL_INSET ][, mixed $filter = ImageInterface::FILTER_UNDEFINED ]) : static
Parameters
- $size : BoxInterface
- $settings : mixed = ImageInterface::THUMBNAIL_INSET
-
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.
- $filter : mixed = ImageInterface::FILTER_UNDEFINED
-
The filter to use for resizing, one of ImageInterface::FILTER_*
Tags
Return values
staticusePalette()
Set a palette for the image. Useful to change colorspace.
public
usePalette(PaletteInterface $palette) : $this
Parameters
- $palette : PaletteInterface
Tags
Return values
$thiscloneImagick()
Clone the Imagick resource of this instance.
protected
cloneImagick() : Imagick
Tags
Return values
ImagickgetAllFilterValues()
Get all the available filter defined in ImageInterface.
protected
static getAllFilterValues() : array<string|int, string>
Return values
array<string|int, string>getAllThumbnailModes()
Get all the available thumbnail modes.
protected
getAllThumbnailModes() : array<string|int, int>
Return values
array<string|int, int>updateSaveOptions()
Updates a given array of save options for backward compatibility with legacy names.
protected
updateSaveOptions(array<string|int, mixed> $options) : array<string|int, mixed>
Parameters
- $options : array<string|int, mixed>
Return values
array<string|int, mixed>applyFastLinear()
Performs optimized gradient fill for non-opaque linear gradients.
private
applyFastLinear(Linear $fill) : mixed
Parameters
- $fill : Linear
applyImageOptions()
Applies options before save or output.
private
applyImageOptions(Imagick $image, array<string|int, mixed> $options, string $path) : Imagick
Parameters
- $image : Imagick
- $options : array<string|int, mixed>
- $path : string
Tags
Return values
ImagickcheckThumbnailSettings()
Check the settings argument in thumbnail() method.
private
checkThumbnailSettings(int $settings) : mixed
Parameters
- $settings : int
flatten()
Flatten the image.
private
flatten() : mixed
getColor()
Gets specifically formatted color string from Color instance.
private
getColor(ColorInterface $color) : ImagickPixel
Parameters
- $color : ColorInterface
Return values
ImagickPixelgetFilter()
Returns the filter if it's supported.
private
getFilter([string $filter = ImageInterface::FILTER_UNDEFINED ]) : string
Parameters
- $filter : string = ImageInterface::FILTER_UNDEFINED
Tags
Return values
stringisLinearOpaque()
Checks whether given $fill is linear and opaque.
private
isLinearOpaque(FillInterface $fill) : bool
Parameters
- $fill : FillInterface
Return values
boolprepareOutput()
private
prepareOutput(array<string|int, mixed> $options[, string $path = null ]) : mixed
Parameters
- $options : array<string|int, mixed>
- $path : string = null
setColorspace()
Sets colorspace and image type, assigns the palette.
private
setColorspace(PaletteInterface $palette) : mixed
Parameters
- $palette : PaletteInterface