Image
extends AbstractImage
in package
implements
InfoProvider
Image implementation using the GD library.
Table of Contents
Interfaces
- InfoProvider
- Interface implemented by classes that provide info about a graphics driver.
Properties
- $metadata : MetadataBag
- $classFactory : ClassFactoryInterface|null
- $layers : Layers|null
- $palette : PaletteInterface
- $resource : resource|GdImage
Methods
- __clone() : mixed
- Clones all the resources associated to this instance.
- __construct() : mixed
- Constructs a new Image instance.
- __destruct() : mixed
- Makes sure the current image resource is destroyed.
- __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.
- getGdResource() : resource|GdImage
- Returns Gd resource.
- 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.
- 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.
- 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.
- checkThumbnailSettings() : mixed
- Check the settings argument in thumbnail() method.
- createImage() : resource|GdImage
- Generates a GD image.
- finalizeOptions() : array<string|int, mixed>
- getColor() : int
- Generates a GD color from Color instance.
- saveOrOutput() : mixed
- Performs save or show operation using one of GD's image... functions.
Properties
$metadata
protected
MetadataBag
$metadata
$classFactory
private
ClassFactoryInterface|null
$classFactory
$layers
private
Layers|null
$layers
$palette
private
PaletteInterface
$palette
$resource
private
resource|GdImage
$resource
Methods
__clone()
Clones all the resources associated to this instance.
public
__clone() : mixed
Tags
__construct()
Constructs a new Image instance.
public
__construct(resource|GdImage $resource, PaletteInterface $palette, MetadataBag $metadata) : mixed
Parameters
- $resource : resource|GdImage
- $palette : PaletteInterface
- $metadata : MetadataBag
__destruct()
Makes sure the current image resource is destroyed.
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
final copy() : static
Tags
Return values
staticcrop()
Crops a specified box out of the source image (modifies the source image) Returns cropped self.
public
final 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
final flipHorizontally() : $this
Tags
Return values
$thisflipVertically()
Flips current image using horizontal axis.
public
final 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|nullgetGdResource()
Returns Gd resource.
public
getGdResource() : resource|GdImage
Return values
resource|GdImagegetSize()
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
final 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
$thisprofile()
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
final resize(BoxInterface $size[, mixed $filter = ImageInterface::FILTER_UNDEFINED ]) : $this
Please remark that GD doesn't support different filters, so the $filter argument is ignored.
Parameters
- $size : BoxInterface
- $filter : mixed = ImageInterface::FILTER_UNDEFINED
Tags
Return values
$thisrotate()
Rotates an image at the given angle.
public
final 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
final 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
final 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
$thisgetAllFilterValues()
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>checkThumbnailSettings()
Check the settings argument in thumbnail() method.
private
checkThumbnailSettings(int $settings) : mixed
Parameters
- $settings : int
createImage()
Generates a GD image.
private
createImage(BoxInterface $size, string $operation) : resource|GdImage
Parameters
- $size : BoxInterface
- $operation : string
-
the operation initiating the creation
Tags
Return values
resource|GdImagefinalizeOptions()
private
finalizeOptions(Format $format, array<string|int, mixed> $options) : array<string|int, mixed>
Parameters
- $format : Format
- $options : array<string|int, mixed>
Tags
Return values
array<string|int, mixed>getColor()
Generates a GD color from Color instance.
private
getColor(ColorInterface $color) : int
Parameters
- $color : ColorInterface
Tags
Return values
int —A color identifier
saveOrOutput()
Performs save or show operation using one of GD's image... functions.
private
saveOrOutput(Format $format, array<string|int, mixed> $options[, string $filename = null ]) : mixed
Parameters
- $format : Format
- $options : array<string|int, mixed>
- $filename : string = null