HumHub Documentation (unofficial)

Image extends AbstractImage
in package
implements InfoProvider

FinalYes

Image implementation using the Gmagick 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>|null
$gmagick  : Gmagick
$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 gmagick 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.
getGmagick()  : Gmagick
Returns gmagick 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.
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.
applyImageOptions()  : mixed
Applies options before save or output.
checkThumbnailSettings()  : mixed
Check the settings argument in thumbnail() method.
flatten()  : mixed
Flatten the image.
getColor()  : GmagickPixel
Gets specifically formatted color string from Color instance.
getColorspaceMapping()  : array<string|int, mixed>
getMimeType()  : string
Get the mime type based on format.
prepareOutput()  : mixed
setColorspace()  : mixed
Sets colorspace and image type, assigns the palette.

Properties

$colorspaceMapping

private static array<string|int, mixed>|null $colorspaceMapping = null

$gmagick

private Gmagick $gmagick

Methods

__destruct()

Destroys allocated gmagick 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

getGmagick()

Returns gmagick instance.

public getGmagick() : Gmagick
Return values
Gmagick

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(GmagickPixel $pixel) : ColorInterface

Note : this method is public for PHP 5.3 compatibility

Parameters
$pixel : GmagickPixel
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

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>

applyImageOptions()

Applies options before save or output.

private applyImageOptions(Gmagick $image, array<string|int, mixed> $options, string $path) : mixed
Parameters
$image : Gmagick
$options : array<string|int, mixed>
$path : string
Tags
throws
InvalidArgumentException

checkThumbnailSettings()

Check the settings argument in thumbnail() method.

private checkThumbnailSettings(int $settings) : mixed
Parameters
$settings : int

flatten()

Flatten the image.

private flatten() : mixed

getColorspaceMapping()

private static getColorspaceMapping() : array<string|int, mixed>
Return values
array<string|int, mixed>

getMimeType()

Get the mime type based on format.

private getMimeType(string $format) : string
Parameters
$format : string
Tags
throws
InvalidArgumentException
Return values
string

mime-type

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