Figure
extends Image
in package
Class to embed simple graphic into the Canvas.
Tags
Table of Contents
- $blue : int
- $boxHeight : int
- $boxWidth : int
- $boxX : int
- $boxY : int
- $extension : string
- $filename : string
- $from : string
- $green : int
- $height : int
- $mimetype : string
- $name : string
- $opacity : int
- $preserve : bool
- $quality : int
- $red : int
- $resource|\GdImage : resource
- $type : int
- $width : int
- $x : int
- $y : int
- $blue : mixed
- $boxHeight : mixed
- $boxWidth : mixed
- $boxX : mixed
- $boxY : mixed
- $extension : mixed
- $figureType : mixed
- $filename : mixed
- $from : mixed
- $green : mixed
- $height : mixed
- $mimetype : mixed
- $name : mixed
- $opacity : mixed
- $preserve : mixed
- $quality : mixed
- $red : mixed
- $resource : mixed
- $type : mixed
- $width : mixed
- $x : mixed
- $y : mixed
- __construct() : mixed
- Sets size for figure.
- centerCrop() : Image|static
- Cuts the image proportionally and centered.
- create() : Figure|static
- Creates the figure with alpha channel.
- crop() : Image|static
- Cuts part of image.
- destroy() : Image|static
- Destroys the current resource.
- from() : Image|static
- Loads an image from Image or Figure class.
- getBackgroundColor() : array<string|int, mixed>
- Gets an array with the RGB background colors.
- getBoxHeight() : int
- Gets box height.
- getBoxLeft() : int
- Gets box left position.
- getBoxTop() : int
- Gets box top position.
- getBoxWidth() : int
- Gets box width.
- getExtension() : string
- Gets extension (jpg, png or gif).
- getFilename() : string
- Gets filename path of the image.
- getHeight() : int
- Gets height.
- getLeft() : int
- Gets left position.
- getLoadedFrom() : string
- Gets where the image was loaded: 'local' or 'external'.
- getName() : string
- Gets the image file name.
- getOpacity() : int
- Gets opacity.
- getPropHeight() : int
- Gets proportional height of image from width value.
- getPropWidth() : int
- Gets proportional width of image from height value.
- getQuality() : int
- Gets quality.
- getResource() : resource|GdImage
- Gets the resource or `\GdImage` object (PHP 8.0+) of the image.
- getTop() : int
- Gets top position.
- getType() : int
- Gets the image type code (IMAGETYPE_JPEG, IMAGETYPE_PNG or IMAGETYPE_GIF).
- getWidth() : int
- Gets width.
- isEllipse() : Figure|static
- Sets the figure type as 'ellipse'.
- isExternal() : bool
- Checks if image was loaded from external url.
- isGIF() : bool
- Checks if image is a GIF.
- isImageGdImage() : bool
- Checks if image was loaded from a `\GdImage` object (PHP 8.0+).
- isImageResource() : bool
- Checks if image was loaded from an image resource (PHP 7.4).
- isImageString() : bool
- Checks if image was loaded from image string.
- isJPG() : bool
- Checks if image is a JPG.
- isLocal() : bool
- Checks if image was loaded from local path.
- isPNG() : bool
- Checks if image is a PNG.
- isRectangle() : Figure|static
- Sets the figure type as 'rectangle'.
- load() : Image|static
- Loads an image from a local path, external url or image string.
- output() : Image|static
- Outputs the image on browser.
- preserve() : Image|static
- Preserves the resource image when save or output function is called.
- render() : resource
- Render the image in-memory and return the resource.
- resizeToHeight() : Image|static
- Resize image proportionally basing on the height of the image.
- resizeToWidth() : Image|static
- Resize image proportionally basing on the width of the image.
- rotate() : Image|static
- Rotate the image with a given angle.
- save() : Image|static
- Saves the image to specific path.
- scale() : Image|static
- Scales the image.
- setBackgroundColor() : Figure|static
- Sets background color in RGB format.
- setBoxHeight() : Image|static
- Sets height of box image.
- setBoxLeft() : Image|static
- Sets left position of box image.
- setBoxTop() : Image|static
- Sets top position of box image.
- setBoxWidth() : Image|static
- Sets width of box image.
- setLeft() : Image|static
- Sets left position of image.
- setOpacity() : Image|static
- Sets opacity.
- setQuality() : Image|static
- Sets quality for image.
- setResource() : Image|static
- Sets image resource.
- setSize() : Figure|static
- Sets size to figure.
- setTop() : Image|static
- Sets top position of image.
- toGIF() : Image|static
- Changes output format to GIF.
- toJPG() : Image|static
- Changes output format to JPG.
- toPNG() : Image|static
- Changes output format to PNG.
- addOpacityFilter() : void
- Add opacity filter to the current resource.
- createEllipse() : void
- Creates a filled ellipse.
- createRectangle() : void
- Creates a filled rectangle.
- fetchImageContentFromURL() : string
- Fetch an image string content from URL.
- isImageStringByString() : bool
- Checks if string is Image string.
- loadImageFromFile() : void
- Load an image file from path.
- loadImageFromResource() : void
- Load an image from a resource or `\GdImage`.
- loadImageFromString() : void
- Load an image from image string.
- loadImageFromURL() : void
- Load an image from URL.
- outputBuffer() : Image|static
- Output the image to either the browser or a file.
- outputBufferByImage() : mixed
- resize() : Image|static
- Resizes the image.
Properties
$blue
public
int
$blue
Blue color
$boxHeight
public
int
$boxHeight
$boxWidth
public
int
$boxWidth
$boxX
public
int
$boxX
$boxY
public
int
$boxY
$extension
public
string
$extension
Default 'jpg'
$filename
public
string
$filename
$from
public
string
$from
Default 'local'
$green
public
int
$green
Green color
$height
public
int
$height
$mimetype
public
string
$mimetype
Default 'image/jpeg'
$name
public
string
$name
$opacity
public
int
$opacity
From 0 to 1
$preserve
public
bool
$preserve
Default FALSE
$quality
public
int
$quality
$red
public
int
$red
Red color
$resource|\GdImage
public
resource
$resource|\GdImage
$type
public
int
$type
IMAGETYPE_JPEG
$width
public
int
$width
$x
public
int
$x
$y
public
int
$y
$blue
protected
mixed
$blue
= 0
Tags
$boxHeight
protected
mixed
$boxHeight
= 0
Tags
$boxWidth
protected
mixed
$boxWidth
= 0
Tags
$boxX
protected
mixed
$boxX
= 0
Tags
$boxY
protected
mixed
$boxY
= 0
Tags
$extension
protected
mixed
$extension
= 'jpg'
Tags
$figureType
protected
mixed
$figureType
= 'rectangle'
Tags
$filename
protected
mixed
$filename
Tags
$from
protected
mixed
$from
= 'local'
Tags
$green
protected
mixed
$green
= 0
Tags
$height
protected
mixed
$height
= 0
Tags
$mimetype
protected
mixed
$mimetype
= 'image/jpeg'
Tags
$name
protected
mixed
$name
Tags
$opacity
protected
mixed
$opacity
= 1
Tags
$preserve
protected
mixed
$preserve
= false
Tags
$quality
protected
mixed
$quality
= 100
Tags
$red
protected
mixed
$red
= 0
Tags
$resource
protected
mixed
$resource
Tags
$type
protected
mixed
$type
= IMAGETYPE_JPEG
Tags
$width
protected
mixed
$width
= 0
Tags
$x
protected
mixed
$x
= 0
Tags
$y
protected
mixed
$y
= 0
Tags
Methods
__construct()
Sets size for figure.
public
__construct([int $width = 0 ][, int $height = 0 ]) : mixed
Parameters
- $width : int = 0
-
width
- $height : int = 0
-
height
Tags
Return values
mixed —centerCrop()
Cuts the image proportionally and centered.
public
centerCrop(int $width, int $height) : Image|static
Parameters
- $width : int
-
width crop
- $height : int
-
height crop
Tags
Return values
Image|static —create()
Creates the figure with alpha channel.
public
create() : Figure|static
Tags
Return values
Figure|static —crop()
Cuts part of image.
public
crop(int $width, int $height[, int $x1 = 0 ][, int $y1 = 0 ][, int $dstX = 0 ][, int $dstY = 0 ]) : Image|static
Parameters
- $width : int
-
width crop
- $height : int
-
height crop
- $x1 : int = 0
-
[Optional] x-coordinate of source point
- $y1 : int = 0
-
[Optional] y-coordinate of source point
- $dstX : int = 0
-
[Optional] x-coordinate of destination point
- $dstY : int = 0
-
[Optional] y-coordinate of destination point
Tags
Return values
Image|static —destroy()
Destroys the current resource.
public
destroy() : Image|static
Tags
Return values
Image|static —from()
Loads an image from Image or Figure class.
public
from([Image $element = null ]) : Image|static
Parameters
- $element : Image = null
-
image or Figure class
Return values
Image|static —getBackgroundColor()
Gets an array with the RGB background colors.
public
getBackgroundColor() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —an array with RGB colors
getBoxHeight()
Gets box height.
public
getBoxHeight() : int
Tags
Return values
int —getBoxLeft()
Gets box left position.
public
getBoxLeft() : int
Tags
Return values
int —getBoxTop()
Gets box top position.
public
getBoxTop() : int
Tags
Return values
int —getBoxWidth()
Gets box width.
public
getBoxWidth() : int
Tags
Return values
int —getExtension()
Gets extension (jpg, png or gif).
public
getExtension() : string
Tags
Return values
string —getFilename()
Gets filename path of the image.
public
getFilename() : string
Tags
Return values
string —getHeight()
Gets height.
public
getHeight() : int
Tags
Return values
int —getLeft()
Gets left position.
public
getLeft() : int
Tags
Return values
int —getLoadedFrom()
Gets where the image was loaded: 'local' or 'external'.
public
getLoadedFrom() : string
Tags
Return values
string —getName()
Gets the image file name.
public
getName() : string
Tags
Return values
string —getOpacity()
Gets opacity.
public
getOpacity() : int
Tags
Return values
int —getPropHeight()
Gets proportional height of image from width value.
public
getPropHeight(int $width) : int
Parameters
- $width : int
Tags
Return values
int —getPropWidth()
Gets proportional width of image from height value.
public
getPropWidth(int $height) : int
Parameters
- $height : int
Tags
Return values
int —getQuality()
Gets quality.
public
getQuality() : int
Tags
Return values
int —getResource()
Gets the resource or `\GdImage` object (PHP 8.0+) of the image.
public
getResource() : resource|GdImage
Tags
Return values
resource|GdImage —getTop()
Gets top position.
public
getTop() : int
Tags
Return values
int —getType()
Gets the image type code (IMAGETYPE_JPEG, IMAGETYPE_PNG or IMAGETYPE_GIF).
public
getType() : int
Tags
Return values
int —getWidth()
Gets width.
public
getWidth() : int
Tags
Return values
int —isEllipse()
Sets the figure type as 'ellipse'.
public
isEllipse() : Figure|static
Tags
Return values
Figure|static —isExternal()
Checks if image was loaded from external url.
public
isExternal() : bool
Tags
Return values
bool —isGIF()
Checks if image is a GIF.
public
isGIF() : bool
Tags
Return values
bool —isImageGdImage()
Checks if image was loaded from a `\GdImage` object (PHP 8.0+).
public
isImageGdImage() : bool
Tags
Return values
bool —isImageResource()
Checks if image was loaded from an image resource (PHP 7.4).
public
isImageResource() : bool
Tags
Return values
bool —isImageString()
Checks if image was loaded from image string.
public
isImageString() : bool
Tags
Return values
bool —isJPG()
Checks if image is a JPG.
public
isJPG() : bool
Tags
Return values
bool —isLocal()
Checks if image was loaded from local path.
public
isLocal() : bool
Tags
Return values
bool —isPNG()
Checks if image is a PNG.
public
isPNG() : bool
Tags
Return values
bool —isRectangle()
Sets the figure type as 'rectangle'.
public
isRectangle() : Figure|static
Tags
Return values
Figure|static —load()
Loads an image from a local path, external url or image string.
public
load(string $src) : Image|static
Parameters
- $src : string
-
local path, external url or image string
Tags
Return values
Image|static —output()
Outputs the image on browser.
public
output() : Image|static
Tags
Return values
Image|static —preserve()
Preserves the resource image when save or output function is called.
public
preserve([bool $preserve = true ]) : Image|static
Parameters
- $preserve : bool = true
-
if it's true will preserve the resource image
Return values
Image|static —render()
Render the image in-memory and return the resource.
public
render() : resource
Tags
Return values
resource —| null Return the resource or null
resizeToHeight()
Resize image proportionally basing on the height of the image.
public
resizeToHeight(int $height) : Image|static
Parameters
- $height : int
Tags
Return values
Image|static —resizeToWidth()
Resize image proportionally basing on the width of the image.
public
resizeToWidth(int $width) : Image|static
Parameters
- $width : int
Tags
Return values
Image|static —rotate()
Rotate the image with a given angle.
public
rotate([int $angle = 0 ]) : Image|static
Parameters
- $angle : int = 0
Tags
Return values
Image|static —save()
Saves the image to specific path.
public
save([string $filename = null ]) : Image|static
Parameters
- $filename : string = null
-
if it's null save function will save the image in load path for default
Tags
Return values
Image|static —scale()
Scales the image.
public
scale([int|float $scale = 1 ]) : Image|static
Parameters
- $scale : int|float = 1
Tags
Return values
Image|static —setBackgroundColor()
Sets background color in RGB format.
public
setBackgroundColor(int $red, int $green, int $blue) : Figure|static
Parameters
- $red : int
-
red
- $green : int
-
green
- $blue : int
-
blue
Tags
Return values
Figure|static —setBoxHeight()
Sets height of box image.
public
setBoxHeight(int $height) : Image|static
Parameters
- $height : int
-
height
Tags
Return values
Image|static —setBoxLeft()
Sets left position of box image.
public
setBoxLeft(int $x) : Image|static
Parameters
- $x : int
-
left position
Tags
Return values
Image|static —setBoxTop()
Sets top position of box image.
public
setBoxTop(int $y) : Image|static
Parameters
- $y : int
-
top position
Tags
Return values
Image|static —setBoxWidth()
Sets width of box image.
public
setBoxWidth(int $width) : Image|static
Parameters
- $width : int
-
width
Tags
Return values
Image|static —setLeft()
Sets left position of image.
public
setLeft(int $x) : Image|static
Parameters
- $x : int
-
left
Tags
Return values
Image|static —setOpacity()
Sets opacity.
public
setOpacity(int $opacity) : Image|static
Parameters
- $opacity : int
-
Opacity value from 0 to 127
Tags
Return values
Image|static —setQuality()
Sets quality for image.
public
setQuality(int $quality) : Image|static
Parameters
- $quality : int
-
Quality value from 0 to 100
Tags
Return values
Image|static —setResource()
Sets image resource.
public
setResource(resource $resource) : Image|static
Parameters
- $resource : resource
-
resource
Tags
Return values
Image|static —setSize()
Sets size to figure.
public
setSize([int $width = 0 ][, int $height = 0 ]) : Figure|static
Parameters
- $width : int = 0
-
width
- $height : int = 0
-
height
Tags
Return values
Figure|static —setTop()
Sets top position of image.
public
setTop(int $y) : Image|static
Parameters
- $y : int
-
top
Tags
Return values
Image|static —toGIF()
Changes output format to GIF.
public
toGIF() : Image|static
Tags
Return values
Image|static —toJPG()
Changes output format to JPG.
public
toJPG() : Image|static
Tags
Return values
Image|static —toPNG()
Changes output format to PNG.
public
toPNG() : Image|static
Tags
Return values
Image|static —addOpacityFilter()
Add opacity filter to the current resource.
protected
addOpacityFilter() : void
Tags
Return values
void —createEllipse()
Creates a filled ellipse.
private
createEllipse(mixed $color) : void
Parameters
- $color : mixed
Tags
Return values
void —createRectangle()
Creates a filled rectangle.
private
createRectangle(mixed $color) : void
Parameters
- $color : mixed
Tags
Return values
void —fetchImageContentFromURL()
Fetch an image string content from URL.
private
fetchImageContentFromURL(string $url) : string
Parameters
- $url : string
-
image URL
Tags
Return values
string —String data
isImageStringByString()
Checks if string is Image string.
private
isImageStringByString(string $imagestring) : bool
Parameters
- $imagestring : string
-
image string
Tags
Return values
bool —loadImageFromFile()
Load an image file from path.
private
loadImageFromFile(string $filepath) : void
Parameters
- $filepath : string
-
File path
Tags
Return values
void —loadImageFromResource()
Load an image from a resource or `\GdImage`.
private
loadImageFromResource(string $resource) : void
Parameters
- $resource : string
-
image resource or
\GdImage
Tags
Return values
void —loadImageFromString()
Load an image from image string.
private
loadImageFromString(string $imagestring) : void
Parameters
- $imagestring : string
-
Image string
Tags
Return values
void —loadImageFromURL()
Load an image from URL.
private
loadImageFromURL(string $url) : void
Parameters
- $url : string
-
Image URL
Tags
Return values
void —outputBuffer()
Output the image to either the browser or a file.
private
outputBuffer([string $filename = null ][, bool $output = false ]) : Image|static
Parameters
- $filename : string = null
-
[Optional] Path to save image
- $output : bool = false
-
[Optional] true to output the image
Tags
Return values
Image|static —| resource
outputBufferByImage()
private
outputBufferByImage(mixed $filename, mixed $quality) : mixed
Parameters
- $filename : mixed
- $quality : mixed
Tags
Return values
mixed —resize()
Resizes the image.
private
resize(int $width, int $height[, int $x1 = 0 ][, int $y1 = 0 ][, int $dstX = 0 ][, int $dstY = 0 ][, bool $isCrop = false ]) : Image|static
Parameters
- $width : int
-
image's width
- $height : int
-
image's height
- $x1 : int = 0
-
[Optional] Left position
- $y1 : int = 0
-
[Optional] Top position
- $dstX : int = 0
-
[Optional] x-coordinate of destination point
- $dstY : int = 0
-
[Optional] y-coordinate of destination point
- $isCrop : bool = false
-
[Optional] if it's true resize function will crop the image