Graphics
in package
Handles image manipulation.
This class provides functionalities for working with images.
Table of Contents
Properties
- $data : string
- $isValid : bool
- $name : string
- $size : Size
- $transparency : int
- $type : string
- $_file : string
- The filename where the image is stored.
- $_history : array<string|int, mixed>
- The history of image operations.
- $_img : mixed
- The image resource.
- $_size : Size|null
- The size of the image.
- $_type : string
- The type of the image.
Methods
- __construct() : mixed
- Constructor.
- __destruct() : mixed
- Destructor.
- __get() : mixed
- Magic getter method.
- __set() : void
- Magic setter method.
- ApplyFilter() : bool|null
- Applies a filter to the image.
- Create() : Graphics
- Creates a Graphics object from data.
- Crop() : void
- Crops the image.
- Info() : ExtendedObject
- Retrieves information about an image file.
- LoadEmptyImage() : void
- Creates an empty image.
- LoadFromData() : void
- Loads an image from binary data.
- LoadFromFile() : void
- Loads an image from a file.
- Resize() : void
- Resizes the image.
- Rotate() : void
- Rotates the image.
- Save() : void
- Saves the image to a file.
- _getImageData() : string
- Retrieves the binary data of the image.
- _safeAlpha() : void
- Sets the alpha channel for the image.
Properties
$data read-only
public
string
$data
The image data.
$isValid read-only
public
bool
$isValid
Indicates whether the image is valid.
$name read-only
public
string
$name
The filename where the image is stored.
$size read-only
public
Size
$size
The size of the image.
$transparency read-only
public
int
$transparency
The transparency level of the image.
$type
public
string
$type
The type of the image.
$_file
The filename where the image is stored.
private
string
$_file
$_history
The history of image operations.
private
array<string|int, mixed>
$_history
= array()
$_img
The image resource.
private
mixed
$_img
$_size
The size of the image.
private
Size|null
$_size
= null
$_type
The type of the image.
private
string
$_type
Methods
__construct()
Constructor.
public
__construct() : mixed
__destruct()
Destructor.
public
__destruct() : mixed
__get()
Magic getter method.
public
__get(string $property) : mixed
Parameters
- $property : string
-
The property name.
Return values
mixed —The value of the property.
__set()
Magic setter method.
public
__set(string $property, mixed $value) : void
Parameters
- $property : string
-
The property name.
- $value : mixed
-
The value to set.
ApplyFilter()
Applies a filter to the image.
public
ApplyFilter(int $filter[, int $arg1 = 0 ][, int $arg2 = 0 ][, int $arg3 = 0 ]) : bool|null
This method applies the specified filter to the image with optional arguments.
Parameters
- $filter : int
-
The filter to apply.
- $arg1 : int = 0
-
The first optional argument for the filter.
- $arg2 : int = 0
-
The second optional argument for the filter.
- $arg3 : int = 0
-
The third optional argument for the filter.
Return values
bool|null —Returns true on success, false on failure, or null if the filter is not supported.
Create()
Creates a Graphics object from data.
public
static Create(string $data) : Graphics
This method creates a Graphics object from the provided data.
Parameters
- $data : string
-
The data to create the Graphics object from.
Return values
Graphics —A Graphics object initialized with the provided data.
Crop()
Crops the image.
public
Crop(Size $size[, Point|null $start = null ]) : void
This method crops the image to the specified size, starting from the optional start point.
Parameters
Info()
Retrieves information about an image file.
public
static Info(string $path) : ExtendedObject
This method retrieves information about the image file located at the specified path.
Parameters
- $path : string
-
The path to the image file.
Return values
ExtendedObject —An object containing information about the image.
LoadEmptyImage()
Creates an empty image.
public
LoadEmptyImage(Size $size) : void
This method creates an empty image with the specified size.
Parameters
- $size : Size
-
The size of the empty image.
LoadFromData()
Loads an image from binary data.
public
LoadFromData(string $data) : void
This method loads an image from the provided binary data.
Parameters
- $data : string
-
The binary data representing the image.
LoadFromFile()
Loads an image from a file.
public
LoadFromFile(string $file) : void
This method loads an image from the specified file.
Parameters
- $file : string
-
The path to the image file.
Resize()
Resizes the image.
public
Resize(Size $size) : void
This method resizes the image to the specified size.
Parameters
- $size : Size
-
The new size of the image.
Rotate()
Rotates the image.
public
Rotate([int $degree = 90 ]) : void
This method rotates the image clockwise by the specified degree.
Parameters
- $degree : int = 90
-
The degree by which to rotate the image. Default is 90.
Save()
Saves the image to a file.
public
Save(string $file) : void
This method saves the image to the specified file.
Parameters
- $file : string
-
The path to save the image file.
_getImageData()
Retrieves the binary data of the image.
private
_getImageData() : string
This method retrieves the binary data of the image.
Return values
string —The binary data of the image.
_safeAlpha()
Sets the alpha channel for the image.
private
_safeAlpha() : void
This method ensures that the alpha channel is properly set for the image.