class Image implements ImageInterface

Image class for GD.

Methods

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

Image constructor.

__clone()

Method called when 'clone' keyword is used.

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

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

static ImageInterface
createFromFile(string $imageFile)

Create Image from image file.

static ImageInterface
createFromCore(resource $gd)

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

static ImageInterface
createBlank(int $width = 1, int $height = 1)

Create a blank image.

alphaBlendingMode(bool $flag)

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

fullAlphaMode(bool $flag)

Enable/Disable transparency

bool
isAnimated()

Returns animated flag.

resource|Imagick
getCore()

Get GD resource ID.

string
getImageFile()

Get image file path.

int
getWidth()

Get image width in pixels.

int
getHeight()

Get image height in pixels.

string
getType()

Get image type.

string.
getBlocks()

Get blocks.

array
histogram(array|null $slice = null)

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

Details

at line line 60
__construct(resource $gd, string $imageFile, int $width, int $height, string $type, string $blocks = '', bool $animated = false)

Image constructor.

Parameters

resource $gd Must use GD's imagecreate* family of functions to create a GD resource.
string $imageFile
int $width
int $height
string $type
string $blocks
bool $animated

at line line 73
__clone()

Method called when 'clone' keyword is used.

at line line 90
blob(string|ImageType $type = 'PNG')

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

Parameters

string|ImageType $type Image format of the dump. See Grafika\ImageType for supported formats.

Exceptions

Exception When unsupported type.

at line line 122
static ImageInterface createFromFile(string $imageFile)

Create Image from image file.

Parameters

string $imageFile Path to image file.

Return Value

ImageInterface Instance of image.

Exceptions

Exception

at line line 156
static ImageInterface createFromCore(resource $gd)

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

Parameters

resource $gd GD resource.

Return Value

ImageInterface Instance of image.

at line line 168
static ImageInterface createBlank(int $width = 1, int $height = 1)

Create a blank image.

Parameters

int $width Width of image in pixels.
int $height Height of image in pixels.

Return Value

ImageInterface Instance of image.

at line line 180
Image alphaBlendingMode(bool $flag)

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

Parameters

bool $flag True to enable blending mode.

Return Value

Image

at line line 192
Image fullAlphaMode(bool $flag)

Enable/Disable transparency

Parameters

bool $flag True to enable alpha mode.

Return Value

Image

at line line 206
bool isAnimated()

Returns animated flag.

Return Value

bool True if animated GIF or false otherwise.

at line line 215
resource|Imagick getCore()

Get GD resource ID.

Return Value

resource|Imagick GD resource or Imagick instance

at line line 224
string getImageFile()

Get image file path.

Return Value

string File path to image if Image was created from an image file.

at line line 233
int getWidth()

Get image width in pixels.

Return Value

int Width in pixels.

at line line 242
int getHeight()

Get image height in pixels.

Return Value

int Height in pixels.

at line line 251
string getType()

Get image type.

Return Value

string Type of image. See ImageType.

at line line 260
string. getBlocks()

Get blocks.

Return Value

string.

at line line 271
array histogram(array|null $slice = null)

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

Return Value

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