HumHub Documentation (unofficial)

Image extends AbstractImage
in package
implements InfoProvider

FinalYes

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

$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

Methods

__destruct()

Destroys allocated imagick resources.

public __destruct() : mixed

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
Tags
see
ManipulatorInterface::fill()
Return values
$this

get()

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
see
ImageInterface::get()
Return values
string

binary

getDriverInfo()

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
see
InfoProvider::getDriverInfo()
since
1.3.0
Return values
Info|null

getImagick()

Returns the underlying \Imagick instance.

public getImagick() : Imagick
Return values
Imagick

interlace()

Enables or disables interlacing.

public interlace(mixed $scheme) : $this
Parameters
$scheme : mixed
Tags
see
ImageInterface::interlace()
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
Tags
see
ImageInterface::mask()
Return values
static

pixelToColor()

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
throws
InvalidArgumentException

In case a unknown color is requested

Return values
ColorInterface

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([mixed $path = null ][, array<string|int, mixed> $options = array() ]) : $this
Parameters
$path : mixed = null
$options : array<string|int, mixed> = array()
Tags
see
ManipulatorInterface::save()
Return values
$this

show()

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
see
ManipulatorInterface::show()
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[, 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
see
ManipulatorInterface::thumbnail()
Return values
static

cloneImagick()

Clone the Imagick resource of this instance.

protected cloneImagick() : Imagick
Tags
throws
ImagickException
Return values
Imagick

getAllFilterValues()

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
throws
InvalidArgumentException
throws
RuntimeException
Return values
Imagick

checkThumbnailSettings()

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
ImagickPixel

getFilter()

Returns the filter if it's supported.

private getFilter([string $filter = ImageInterface::FILTER_UNDEFINED ]) : string
Parameters
$filter : string = ImageInterface::FILTER_UNDEFINED
Tags
throws
InvalidArgumentException

if the filter is unsupported

Return values
string

isLinearOpaque()

Checks whether given $fill is linear and opaque.

private isLinearOpaque(FillInterface $fill) : bool
Parameters
$fill : FillInterface
Return values
bool

prepareOutput()

private prepareOutput(array<string|int, mixed> $options[, string $path = null ]) : mixed
Parameters
$options : array<string|int, mixed>
$path : string = null

        
On this page

Search results