Image class
Framework\Image\Image
Class Image.
Implements:
JsonSerializable, Stringable
Defined in libraries/image/src/Image.php
Properties #
- $filename
- Path to the image file.
- $type
- Image type. One of IMAGETYPE_* constants.
- $mime
- MIME type.
- $instance
- GdImage instance.
- $quality
- The image quality/compression level.
$filename
Path to the image file.
$type
Image type. One of IMAGETYPE_* constants.
$mime
MIME type.
$instance
GdImage instance.
$quality
The image quality/compression level.
Methods #
- __construct()
- Image constructor.
- __toString()
- -
- crop()
- Crops the image.
- destroy()
- Destroys the GdImage instance.
- filter()
- Applies a filter to the image.
- flatten()
- Flattens the image.
- flip()
- Flips the image.
- getDataUrl()
- Allow embed the image contents in a document.
- getExtension()
- Gets the file extension for image type.
- getHeight()
- Gets the image height.
- getInstance()
- Gets the GdImage instance.
- getMime()
- Gets the image MIME type.
- getQuality()
- Gets the image quality/compression level.
- getResolution()
- Gets the image resolution.
- getWidth()
- Gets the image width.
- isAcceptable()
- Indicates if a given filename has an acceptable image type.
- jsonSerialize()
- -
- opacity()
- Sets the image opacity level.
- render()
- Renders the image contents.
- rotate()
- Rotates the image with a given angle.
- save()
- Saves the image contents to a given filename.
- scale()
- Scales the image.
- send()
- Sends the image contents to the output buffer.
- setInstance()
- Sets the GdImage instance.
- setQuality()
- Sets the image quality/compression level.
- setResolution()
- Sets the image resolution.
- watermark()
- Adds a watermark to the image.
__construct()
Image constructor.
- string $filename - Path to the image file. Acceptable types are: GIF, JPEG and PNG
__toString()
crop()
Crops the image.
- int $width - Width in pixels
- int $height - Height in pixels
- int $marginLeft - Margin left in pixels
- int $marginTop - Margin top in pixels
destroy()
Destroys the GdImage instance.
filter()
Applies a filter to the image.
- int $type - IMG_FILTER_* constants
- int $arguments
flatten()
Flattens the image.
Replaces transparency with an RGB color.
- int $red
- int $green
- int $blue
flip()
Flips the image.
- string $direction - Allowed values are: h or horizontal. v or vertical. b or both.
getDataUrl()
Allow embed the image contents in a document.
getExtension()
Gets the file extension for image type.
getHeight()
Gets the image height.
getInstance()
Gets the GdImage instance.
getMime()
Gets the image MIME type.
getQuality()
Gets the image quality/compression level.
getResolution()
Gets the image resolution.
getWidth()
Gets the image width.
isAcceptable()
Indicates if a given filename has an acceptable image type.
- string $filename
jsonSerialize()
opacity()
Sets the image opacity level.
- int $opacity - Opacity percentage: from 0 to 100
render()
Renders the image contents.
rotate()
Rotates the image with a given angle.
- float $angle - Rotation angle, in degrees. Clockwise direction.
save()
Saves the image contents to a given filename.
- ?string $filename - Optional filename or null to use the original
scale()
Scales the image.
- int $width - Width in pixels
- int $height - Height in pixels. Use -1 to use a proportional height based on the width.
send()
Sends the image contents to the output buffer.
setInstance()
Sets the GdImage instance.
- GdImage $instance - GdImage instance
setQuality()
Sets the image quality/compression level.
- int $quality - The quality/compression level
setResolution()
Sets the image resolution.
- int $horizontal - The horizontal resolution in DPI
- int $vertical - The vertical resolution in DPI
watermark()
Adds a watermark to the image.
- \Framework\Image\Image $watermark - The image to use as watermark
- int $horizontalPosition - Horizontal position
- int $verticalPosition - Vertical position