HumHub Documentation (unofficial)

ImageInterface extends ManipulatorInterface

The image interface.

Table of Contents

Constants

FILTER_BESSEL  = 'bessel'
Resampling filter: bessel.
FILTER_BLACKMAN  = 'blackman'
Resampling filter: blackman.
FILTER_BOX  = 'box'
Resampling filter: box.
FILTER_CATROM  = 'catrom'
Resampling filter: catrom.
FILTER_CUBIC  = 'cubic'
Resampling filter: cubic.
FILTER_GAUSSIAN  = 'gaussian'
Resampling filter: gaussian.
FILTER_HAMMING  = 'hamming'
Resampling filter: hamming.
FILTER_HANNING  = 'hanning'
Resampling filter: hanning.
FILTER_HERMITE  = 'hermite'
Resampling filter: hermite.
FILTER_LANCZOS  = 'lanczos'
Resampling filter: lanczos.
FILTER_MITCHELL  = 'mitchell'
Resampling filter: mitchell.
FILTER_POINT  = 'point'
Resampling filter: point (interpolated).
FILTER_QUADRATIC  = 'quadratic'
Resampling filter: quadratic.
FILTER_SINC  = 'sinc'
Resampling filter: sinc.
FILTER_SINCFAST  = 'sincfast'
Resampling filter: sincfast.
FILTER_TRIANGLE  = 'triangle'
Resampling filter: triangle.
FILTER_UNDEFINED  = 'undefined'
Image filter: none/undefined.
INTERLACE_LINE  = 'line'
Image interlacing: scanline.
INTERLACE_NONE  = 'none'
Image interlacing: none.
INTERLACE_PARTITION  = 'partition'
Image interlacing: like plane interlacing except the different planes are saved to individual files.
INTERLACE_PLANE  = 'plane'
Image interlacing: plane.
RESOLUTION_PIXELSPERCENTIMETER  = 'ppc'
Resolution units: pixels per centimeter.
RESOLUTION_PIXELSPERINCH  = 'ppi'
Resolution units: pixels per inch.
THUMBNAIL_FLAG_NOCLONE  = 0x20000
Instead of creating a new image instance, the thumbnail method modifies the original image (saving memory.
THUMBNAIL_FLAG_UPSCALE  = 0x10000
Allow upscaling the image if it's smaller than the wanted thumbnail size.
THUMBNAIL_INSET  = 0x1
The original image is scaled so it is fully contained within the thumbnail dimensions (the image width/height ratio doesn't change).
THUMBNAIL_OUTBOUND  = 0x2
The thumbnail is scaled so that its smallest side equals the length of the corresponding side in the original image (the width or the height are cropped).

Methods

__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.
getColorAt()  : ColorInterface
Returns color at specified positions of current image.
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.
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.

Constants

FILTER_BESSEL

Resampling filter: bessel.

public string FILTER_BESSEL = 'bessel'

FILTER_BLACKMAN

Resampling filter: blackman.

public string FILTER_BLACKMAN = 'blackman'

FILTER_BOX

Resampling filter: box.

public string FILTER_BOX = 'box'

FILTER_CATROM

Resampling filter: catrom.

public string FILTER_CATROM = 'catrom'

FILTER_CUBIC

Resampling filter: cubic.

public string FILTER_CUBIC = 'cubic'

FILTER_GAUSSIAN

Resampling filter: gaussian.

public string FILTER_GAUSSIAN = 'gaussian'

FILTER_HAMMING

Resampling filter: hamming.

public string FILTER_HAMMING = 'hamming'

FILTER_HANNING

Resampling filter: hanning.

public string FILTER_HANNING = 'hanning'

FILTER_HERMITE

Resampling filter: hermite.

public string FILTER_HERMITE = 'hermite'

FILTER_LANCZOS

Resampling filter: lanczos.

public string FILTER_LANCZOS = 'lanczos'

FILTER_MITCHELL

Resampling filter: mitchell.

public string FILTER_MITCHELL = 'mitchell'

FILTER_POINT

Resampling filter: point (interpolated).

public string FILTER_POINT = 'point'

FILTER_QUADRATIC

Resampling filter: quadratic.

public string FILTER_QUADRATIC = 'quadratic'

FILTER_SINC

Resampling filter: sinc.

public string FILTER_SINC = 'sinc'

FILTER_SINCFAST

Resampling filter: sincfast.

public string FILTER_SINCFAST = 'sincfast'

FILTER_TRIANGLE

Resampling filter: triangle.

public string FILTER_TRIANGLE = 'triangle'

FILTER_UNDEFINED

Image filter: none/undefined.

public string FILTER_UNDEFINED = 'undefined'

INTERLACE_LINE

Image interlacing: scanline.

public string INTERLACE_LINE = 'line'

INTERLACE_NONE

Image interlacing: none.

public string INTERLACE_NONE = 'none'

INTERLACE_PARTITION

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

public string INTERLACE_PARTITION = 'partition'

INTERLACE_PLANE

Image interlacing: plane.

public string INTERLACE_PLANE = 'plane'

RESOLUTION_PIXELSPERCENTIMETER

Resolution units: pixels per centimeter.

public string RESOLUTION_PIXELSPERCENTIMETER = 'ppc'

RESOLUTION_PIXELSPERINCH

Resolution units: pixels per inch.

public string RESOLUTION_PIXELSPERINCH = 'ppi'

THUMBNAIL_FLAG_NOCLONE

Instead of creating a new image instance, the thumbnail method modifies the original image (saving memory.

public int THUMBNAIL_FLAG_NOCLONE = 0x20000

THUMBNAIL_FLAG_UPSCALE

Allow upscaling the image if it's smaller than the wanted thumbnail size.

public int THUMBNAIL_FLAG_UPSCALE = 0x10000

THUMBNAIL_INSET

The original image is scaled so it is fully contained within the thumbnail dimensions (the image width/height ratio doesn't change).

public int THUMBNAIL_INSET = 0x1

THUMBNAIL_OUTBOUND

The thumbnail is scaled so that its smallest side equals the length of the corresponding side in the original image (the width or the height are cropped).

public int THUMBNAIL_OUTBOUND = 0x2

Methods

__toString()

Returns the image content as a PNG binary string.

public __toString() : string
Tags
throws
RuntimeException
Return values
string

binary

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.

public fill(FillInterface $fill) : $this
Parameters
$fill : FillInterface
Return values
$this

get()

Returns the image content as a binary string.

public get(string $format[, array<string|int, mixed> $options = array() ]) : string
Parameters
$format : string
$options : array<string|int, mixed> = array()
Tags
throws
RuntimeException
Return values
string

binary

interlace()

Enables or disables interlacing.

public interlace(string $scheme) : $this
Parameters
$scheme : string
Tags
throws
InvalidArgumentException

When an unsupported Interface type is supplied

Return values
$this

mask()

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

public mask() : static
Return values
static

paste()

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[, int $alpha = 100 ]) : $this

Returns source image

Parameters
$image : ImageInterface
$start : PointInterface
$alpha : int = 100

How to paste the image, from 0 (fully transparent) to 100 (fully opaque)

Tags
throws
InvalidArgumentException
throws
RuntimeException
Return values
$this

rotate()

Rotates an image at the given angle.

public rotate(int $angle[, ColorInterface $background = null ]) : $this

Optional $background can be used to specify the fill color of the empty area of rotated image.

Parameters
$angle : int
$background : ColorInterface = null
Tags
throws
RuntimeException
Return values
$this

save()

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([string $path = null ][, array<string|int, mixed> $options = array() ]) : $this

Please remark that bmp is supported by the GD driver only since PHP 7.2.

Parameters
$path : string = null
$options : array<string|int, mixed> = array()
Tags
throws
RuntimeException
Return values
$this

show()

Outputs the image content.

public show(string $format[, array<string|int, mixed> $options = array() ]) : $this
Parameters
$format : string
$options : array<string|int, mixed> = array()
Tags
throws
RuntimeException
Return values
$this

thumbnail()

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[, int|string $settings = self::THUMBNAIL_INSET ][, string $filter = ImageInterface::FILTER_UNDEFINED ]) : static
Parameters
$size : BoxInterface
$settings : int|string = self::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 : string = ImageInterface::FILTER_UNDEFINED

The filter to use for resizing, one of ImageInterface::FILTER_*

Tags
throws
RuntimeException
Return values
static

        
On this page

Search results