Properties

$gd

$gd : resource

Type

resource — GD resource ID.

$imageFile

$imageFile : string

Type

string — File path to image.

$width

$width : integer

Type

integer — Image width in pixels.

$height

$height : integer

Type

integer — Image height in pixels.

$type

$type : string

Type

string — Image type. See \Grafika\ImageType

$blocks

$blocks : string

Type

string — Contains array of animated GIF data.

$animated

$animated : boolean

Type

boolean — True if animated GIF.

Methods

__construct()

__construct(resource  $gd, string  $imageFile, integer  $width, integer  $height, string  $type, string  $blocks = '', boolean  $animated = false) 

Image constructor.

Parameters

resource $gd

Must use GD's imagecreate* family of functions to create a GD resource.

string $imageFile
integer $width
integer $height
string $type
string $blocks
boolean $animated

__clone()

__clone() 

Method called when 'clone' keyword is used.

blob()

blob(string|\Grafika\ImageType  $type = 'PNG') 

Output a binary raw dump of an image in a specified format.

Parameters

string|\Grafika\ImageType $type

Image format of the dump.

Throws

\Exception

When unsupported type.

createFromFile()

createFromFile(string  $imageFile) : \Grafika\Gd\Image

Create Image from image file.

Parameters

string $imageFile

Path to image.

Throws

\Exception

Returns

\Grafika\Gd\Image

createFromCore()

createFromCore(resource  $gd) : \Grafika\Gd\Image

Create an Image from a GD resource. The file type defaults to unknown.

Parameters

resource $gd

GD resource.

Returns

\Grafika\Gd\Image

createBlank()

createBlank(integer  $width = 1, integer  $height = 1) : \Grafika\Gd\Image

Create a blank image.

Parameters

integer $width

Width in pixels.

integer $height

Height in pixels.

Returns

\Grafika\Gd\Image

alphaBlendingMode()

alphaBlendingMode(boolean  $flag) : self

Set the blending mode for an image. Allows transparent overlays on top of an image.

Parameters

boolean $flag

True to enable blending mode.

Returns

self

fullAlphaMode()

fullAlphaMode(boolean  $flag) : self

Enable/Disable transparency

Parameters

boolean $flag

True to enable alpha mode.

Returns

self

isAnimated()

isAnimated() : boolean

Returns animated flag.

Returns

boolean —

True if animated GIF.

getCore()

getCore() : resource

Get GD resource ID.

Returns

resource

getImageFile()

getImageFile() : string

Get image file path.

Returns

string —

File path to image.

getWidth()

getWidth() : integer

Get image width in pixels.

Returns

integer

getHeight()

getHeight() : integer

Get image height in pixels.

Returns

integer

getType()

getType() : string

Get image type.

Returns

string

getBlocks()

getBlocks() : \Grafika\Gd\string.

Get blocks.

Returns

\Grafika\Gd\string.

histogram()

histogram(array|null  $slice = null) : array

Get histogram from an entire image or its sub-region.

Parameters

array|null $slice

Array of slice information. array( array( 0,0), array(100,50)) means x,y is 0,0 and width,height is 100,50

Returns

array —

Returns array containing RGBA bins array('r'=>array(), 'g'=>array(), 'b'=>array(), 'a'=>array())

_createGif()

_createGif(string  $imageFile) : \Grafika\Gd\Image

Load a GIF image.

Parameters

string $imageFile

Throws

\Exception

Returns

\Grafika\Gd\Image

_createJpeg()

_createJpeg(string  $imageFile) : \Grafika\Gd\Image

Load a JPEG image.

Parameters

string $imageFile

File path to image.

Throws

\Exception

Returns

\Grafika\Gd\Image

_createPng()

_createPng(string  $imageFile) : \Grafika\Gd\Image

Load a PNG image.

Parameters

string $imageFile

File path to image.

Throws

\Exception

Returns

\Grafika\Gd\Image

_createWbmp()

_createWbmp(string  $imageFile) : \Grafika\Gd\Image

Load a WBMP image.

Parameters

string $imageFile

Throws

\Exception

Returns

\Grafika\Gd\Image

_guessType()

_guessType(  $imageFile) : string

Parameters

$imageFile

Returns

string