HumHub Documentation (unofficial)

Image extends AbstractImage
in package
implements InfoProvider

FinalYes

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

$resource

private resource|GdImage $resource

Methods

__destruct()

Makes sure the current image resource is destroyed.

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

getGdResource()

Returns Gd resource.

public getGdResource() : resource|GdImage
Return values
resource|GdImage

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

resize()

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
see
ManipulatorInterface::resize()
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 final 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>

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
throws
RuntimeException
Return values
resource|GdImage

finalizeOptions()

private finalizeOptions(Format $format, array<string|int, mixed> $options) : array<string|int, mixed>
Parameters
$format : Format
$options : array<string|int, mixed>
Tags
throws
InvalidArgumentException
Return values
array<string|int, mixed>

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

        
On this page

Search results