Class

Imagine\Gd\Image

class Image extends AbstractImage

Image implementation using the GD library

Methods

ImageInterface thumbnail(BoxInterface $size, string $mode = ImageInterface::THUMBNAIL_INSET, string $filter = ImageInterface::FILTER_UNDEFINED)

Generates a thumbnail from a current image Returns it as a new image, doesn't modify the current image

from AbstractImage
MetadataBag metadata()

Returns the Image's meta data

from AbstractImage
__clone()

Assures the metadata instance will be cloned, too

from AbstractImage
__construct(resource $resource, PaletteInterface $palette, MetadataBag $metadata)

Constructs a new Image instance

__destruct()

Makes sure the current image resource is destroyed

resource getGdResource()

Returns Gd resource

ImageInterface copy()

Copies current source image into a new ImageInterface instance

ImageInterface crop(PointInterface $start, BoxInterface $size)

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

ImageInterface paste(ImageInterface $image, PointInterface $start)

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

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

Resizes current image and returns self

ImageInterface rotate(integer $angle, ColorInterface $background = null)

Rotates an image at the given angle.

ImageInterface 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 and xbm are supported

ImageInterface 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

string __toString()

Returns the image content as a PNG binary string

ImageInterface flipHorizontally()

Flips current image using horizontal axis

ImageInterface flipVertically()

Flips current image using vertical axis

ImageInterface strip()

Remove all profiles and comments

DrawerInterface draw()

Instantiates and returns a DrawerInterface instance for image drawing

EffectsInterface effects()

BoxInterface getSize()

Returns current image size

ImageInterface applyMask(ImageInterface $mask)

Applies a given mask to current image's alpha channel

ImageInterface 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

ImageInterface mask()

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

array histogram()

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

ColorInterface getColorAt(PointInterface $point)

Returns color at specified positions of current image

LayersInterface layers()

Returns the image layers when applicable.

ImageInterface interlace(string $scheme)

Enables or disables interlacing

PaletteInterface palette()

Return the current color palette

ImageInterface profile(ProfileInterface $profile)

Applies a color profile on the Image

ImageInterface usePalette(PaletteInterface $palette)

Set a palette for the image.

Details

in AbstractImage at line 29
public ImageInterface thumbnail(BoxInterface $size, string $mode = ImageInterface::THUMBNAIL_INSET, string $filter = ImageInterface::FILTER_UNDEFINED)

Generates a thumbnail from a current image Returns it as a new image, doesn't modify the current image

Parameters

BoxInterface $size
string $mode
string $filter The filter to use for resizing, one of ImageInterface::FILTER_*

Return Value

ImageInterface

Exceptions

RuntimeException

in AbstractImage at line 105
public MetadataBag metadata()

Returns the Image's meta data

Return Value

MetadataBag

in AbstractImage at line 113
public __clone()

Assures the metadata instance will be cloned, too

at line 58
public __construct(resource $resource, PaletteInterface $palette, MetadataBag $metadata)

Constructs a new Image instance

Parameters

resource $resource
PaletteInterface $palette
MetadataBag $metadata

at line 68
public __destruct()

Makes sure the current image resource is destroyed

at line 80
public resource getGdResource()

Returns Gd resource

Return Value

resource

at line 90
final public ImageInterface copy()

Copies current source image into a new ImageInterface instance

Return Value

ImageInterface

Exceptions

RuntimeException

at line 107
final public ImageInterface 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

ImageInterface

Exceptions

OutOfBoundsException
RuntimeException

at line 134
final public ImageInterface paste(ImageInterface $image, PointInterface $start)

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

Returns source image

at line 163
final public ImageInterface resize(BoxInterface $size, string $filter = ImageInterface::FILTER_UNDEFINED)

Resizes current image and returns self

Parameters

BoxInterface $size
string $filter

Return Value

ImageInterface

Exceptions

RuntimeException

at line 196
final public ImageInterface rotate(integer $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

integer $angle
ColorInterface $background

Return Value

ImageInterface

Exceptions

RuntimeException

at line 216
final public ImageInterface 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 and xbm are supported

Parameters

string $path
array $options

Return Value

ImageInterface

Exceptions

RuntimeException

at line 243
public ImageInterface show(string $format, array $options = array())

Outputs the image content

Parameters

string $format
array $options

Return Value

ImageInterface

Exceptions

RuntimeException

at line 255
public 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 266
public string __toString()

Returns the image content as a PNG binary string

Return Value

string binary

Exceptions

RuntimeException

at line 276
final public ImageInterface flipHorizontally()

Flips current image using horizontal axis

Return Value

ImageInterface

Exceptions

RuntimeException

at line 301
final public ImageInterface flipVertically()

Flips current image using vertical axis

Return Value

ImageInterface

Exceptions

RuntimeException

at line 326
final public ImageInterface strip()

Remove all profiles and comments

Return Value

ImageInterface

Exceptions

RuntimeException

at line 335
public DrawerInterface draw()

Instantiates and returns a DrawerInterface instance for image drawing

Return Value

DrawerInterface

at line 343
public EffectsInterface effects()

Return Value

EffectsInterface

at line 351
public BoxInterface getSize()

Returns current image size

Return Value

BoxInterface

at line 361
public ImageInterface applyMask(ImageInterface $mask)

Applies a given mask to current image's alpha channel

Parameters

ImageInterface $mask

Return Value

ImageInterface

at line 395
public ImageInterface 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

ImageInterface

at line 413
public 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 427
public array histogram()

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

Return Value

array

at line 444
public ColorInterface getColorAt(PointInterface $point)

Returns color at specified positions of current image

Parameters

PointInterface $point

Return Value

ColorInterface

Exceptions

RuntimeException

at line 459
public 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 471
public ImageInterface interlace(string $scheme)

Enables or disables interlacing

Parameters

string $scheme

Return Value

ImageInterface

Exceptions

InvalidArgumentException When an unsupported Interface type is supplied

at line 492
public PaletteInterface palette()

Return the current color palette

Return Value

PaletteInterface

at line 500
public ImageInterface profile(ProfileInterface $profile)

Applies a color profile on the Image

Parameters

ProfileInterface $profile

Return Value

ImageInterface

Exceptions

RuntimeException

at line 508
public ImageInterface usePalette(PaletteInterface $palette)

Set a palette for the image.

Useful to change colorspace.

Parameters

PaletteInterface $palette

Return Value

ImageInterface

Exceptions

RuntimeException