Methods |
public
static
|
version(): string
Returns the library version
Returns the library version
Returns
|
#
|
public
static
|
path(): string
Returns the path to the library
Returns the path to the library
|
#
|
public
static
|
checkGD()
Checks whether the gd library is loaded, and throws an exception otherwise
Checks whether the gd library is loaded, and throws an exception otherwise
|
#
|
public
static
|
registerCustomMapper(string $mapper_class_name, string $mime_type, string $extension)
Registers a custom mapper for image loading and saving
Registers a custom mapper for image loading and saving
Example:
\WideImage\WideImage::registerCustomMapper('\WideImage\Mapper\TGA', 'image/tga', 'tga');
|
#
|
public
static
|
load(mixed $source): Image|PaletteImage|TrueColorImage
Loads an image from a file, URL, HTML input file field, binary string, or a valid image handle.
The image format is…
Loads an image from a file, URL, HTML input file field, binary string, or a valid image handle.
The image format is auto-detected.
Currently supported formats: PNG, GIF, JPG, BMP, TGA, GD, GD2.
This function analyzes the input and decides whether to use WideImage::loadFromHandle(),
WideImage::loadFromFile(), WideImage::loadFromUpload() or WideImage::loadFromString(),
all of which you can also call directly to spare WideImage some guessing.
Arrays are supported for upload fields; it returns an array of loaded images.
To load only a single image from an array field, use WideImage::loadFromUpload('img', $i),
where $i is the index of the image you want to load.
$img = WideImage::load('http://url/image.png'); // image URL
$img = WideImage::load('/path/to/image.png'); // local file path
$img = WideImage::load('img'); // upload field name
$img = WideImage::load(imagecreatetruecolor(10, 10)); // a GD resource
$img = WideImage::load($image_data); // binary string containing image data
Parameters
$source |
File name, url, HTML file input field name, binary string, or a GD image resource
|
|
#
|
public
static
|
loadFromFile(string $uri): Image|PaletteImage|TrueColorImage
Create and load an image from a file or URL. The image format is auto-detected.
Create and load an image from a file or URL. The image format is auto-detected.
Parameters
|
#
|
public
static
|
loadFromString(string $string): Image|PaletteImage|TrueColorImage
Create and load an image from a string. Format is auto-detected.
Create and load an image from a string. Format is auto-detected.
Parameters
$string |
Binary data, i.e. from BLOB field in the database
|
|
#
|
public
static
|
loadFromHandle(resource $handle): Image|PaletteImage|TrueColorImage
Create and load an image from an image handle.
Create and load an image from an image handle.
Note: the resulting image object takes ownership of the passed
handle. When the newly-created image object is destroyed, the handle is
destroyed too, so it's not a valid image handle anymore. In order to
preserve the handle for use after object destruction, you have to call
\WideImage\Image::releaseHandle() on the created image instance prior to its
destruction.
$handle = imagecreatefrompng('file.png');
$image = WideImage::loadFromHandle($handle);
Parameters
$handle |
A valid GD image resource
|
|
#
|
public
static
|
loadFromUpload($field_name, int $index = null): Image
This method loads a file from the $_FILES array. The image format is auto-detected.
This method loads a file from the $_FILES array. The image format is auto-detected.
You only have to pass the field name as the parameter. For array fields, this function will
return an array of image objects, unless you specify the $index parameter, which will
load the desired image.
Parameters
$index |
The index of the file to load (if the input field is an array)
|
Returns
|
#
|
public
static
|
createPaletteImage(int $width, int $height): PaletteImage
Factory method for creating a palette image
Factory method for creating a palette image
|
#
|
public
static
|
createTrueColorImage(int $width, int $height): TrueColorImage
Factory method for creating a true-color image
Factory method for creating a true-color image
|
#
|
public
static
|
isValidImageHandle(mixed $handle): bool
Check whether the given handle is a valid GD resource
Check whether the given handle is a valid GD resource
Parameters
$handle |
The variable to check
|
|
#
|
public
static
|
assertValidImageHandle(mixed $handle)
Throws exception if the handle isn't a valid GD resource
Throws exception if the handle isn't a valid GD resource
Parameters
$handle |
The variable to check
|
|
#
|