Image
Extends \Joomla\Image\ImageClass to manipulate an image.
since |
1.7.3 |
---|
Methods
__construct
Class constructor.
__construct(mixed $source = null)
since |
1.0 |
---|---|
throws |
|
Arguments
- $source
mixed
Either a file path for a source image or a GD resource handler for an image.
__destruct
Method to call the destroy() method one last time to free any memory when the object is unset
__destruct()
see | \Joomla\Image\Image::destroy() |
---|---|
since |
1.0 |
createThumbs
Method to create thumbnails from the current image and save them to disk. It allows creation by resizing or cropping the original image.
createThumbs(mixed $thumbSizes, integer $creationMethod = self::SCALE_INSIDE, string $thumbsFolder = null) : array
since |
1.0 |
---|---|
throws |
|
Arguments
- $thumbSizes
mixed
string or array of strings. Example: $thumbSizes = array('150x75','250x150');- $creationMethod
integer
1-3 resize $scaleMethod | 4 create cropping- $thumbsFolder
string
destination thumbs folder. null generates a thumbs folder in the image folder
Response
array
crop
Method to crop the current image.
crop(mixed $width, mixed $height, integer $left = null, integer $top = null, boolean $createNew = true) : \Joomla\Image\Image
since |
1.0 |
---|---|
throws |
|
Arguments
- $width
mixed
The width of the image section to crop in pixels or a percentage.- $height
mixed
The height of the image section to crop in pixels or a percentage.- $left
integer
The number of pixels from the left to start cropping.- $top
integer
The number of pixels from the top to start cropping.- $createNew
boolean
If true the current image will be cloned, cropped and returned; else the current image will be cropped and returned.
Response
cropResize
Method to crop an image after resizing it to maintain proportions without having to do all the set up work.
cropResize(integer $width, integer $height, integer $createNew = true) : \Joomla\Image\Image
since |
1.0 |
---|
Arguments
- $width
integer
The desired width of the image in pixels or a percentage.- $height
integer
The desired height of the image in pixels or a percentage.- $createNew
integer
If true the current image will be cloned, resized, cropped and returned.
Response
destroy
Method to destroy an image handle and free the memory associated with the handle
destroy() : boolean
since |
1.0 |
---|
Response
boolean
True on success, false on failure or if no image is loaded
filter
Method to apply a filter to the image by type. Two examples are: grayscale and sketchy.
filter(string $type, array $options = array()) : \Joomla\Image\Image
since |
1.0 |
---|---|
see | \Joomla\Image\Joomla\Image\Filter |
throws |
|
Arguments
- $type
string
The name of the image filter to apply.- $options
array
An array of options for the filter.
Response
flip
Method to flip the current image.
flip(integer $mode, boolean $createNew = true) : \Joomla\Image\Image
since |
1.2.0 |
---|---|
throws |
|
Arguments
- $mode
integer
The flip mode for flipping the image {@link https://www.php.net/imageflip#refsect1-function.imageflip-parameters}- $createNew
boolean
If true the current image will be cloned, flipped and returned; else the current image will be flipped and returned.
Response
generateThumbs
Method to generate thumbnails from the current image. It allows creation by resizing or cropping the original image.
generateThumbs(mixed $thumbSizes, integer $creationMethod = self::SCALE_INSIDE) : array
since |
1.0 |
---|---|
throws |
|
Arguments
- $thumbSizes
mixed
String or array of strings. Example: $thumbSizes = array('150x75','250x150');- $creationMethod
integer
1-3 resize $scaleMethod | 4 create cropping | 5 resize then crop
Response
array
getFilterInstance
Method to get an image filter instance of a specified type.
getFilterInstance(string $type) : \Joomla\Image\ImageFilter
since |
1.0 |
---|---|
throws |
|
Arguments
- $type
string
The image filter type to get.
Response
getHandle
Get the image resource handle
getHandle() : resource
since |
1.3.0 |
---|---|
throws |
|
Response
resource
getHeight
Method to get the height of the image in pixels.
getHeight() : integer
since |
1.0 |
---|---|
throws |
|
Response
integer
getImageFileProperties
Method to return a properties object for an image given a filesystem path.
getImageFileProperties(string $path) : \stdClass
The result object has values for image width, height, type, attributes, mime type, bits, and channels.
since |
1.0 |
---|---|
throws |
|
Arguments
- $path
string
The filesystem path to the image for which to get properties.
Response
\stdClass
getLogger
Get the logger.
getLogger() : \Psr\Log\LoggerInterface
since |
1.0 |
---|
Response
\Psr\Log\LoggerInterface
getOrientation
Method to detect whether an image's orientation is landscape, portrait or square.
getOrientation() : mixed
The orientation will be returned as a string.
since |
1.2.0 |
---|
Response
mixed
Orientation string or null.
getOrientationString
Compare width and height integers to determine image orientation.
getOrientationString(integer $width, integer $height) : string
since |
1.2.0 |
---|
Arguments
- $width
integer
The width value to use for calculation- $height
integer
The height value to use for calculation
Response
string
Orientation string
getPath
Method to return the path
getPath() : string
since |
1.0 |
---|
Response
string
getWidth
Method to get the width of the image in pixels.
getWidth() : integer
since |
1.0 |
---|---|
throws |
|
Response
integer
isLoaded
Method to determine whether or not an image has been loaded into the object.
isLoaded() : boolean
since |
1.0 |
---|
Response
boolean
isTransparent
Method to determine whether or not the image has transparency.
isTransparent() : boolean
since |
1.0 |
---|---|
throws |
|
Response
boolean
isValidImage
isValidImage(mixed $handle) : boolean
Arguments
- $handle
mixed
A potential image handle
Response
boolean
loadFile
Method to load a file into the Image object as the resource.
loadFile(string $path) : void
since |
1.0 |
---|---|
throws |
|
Arguments
- $path
string
The filesystem path to load as an image.
prepareDimensions
Method to get the new dimensions for a resized image.
prepareDimensions(integer $width, integer $height, integer $scaleMethod) : \stdClass
since |
1.0 |
---|---|
throws |
|
Arguments
- $width
integer
The width of the resized image in pixels.- $height
integer
The height of the resized image in pixels.- $scaleMethod
integer
The method to use for scaling
Response
\stdClass
resize
Method to resize the current image.
resize(mixed $width, mixed $height, boolean $createNew = true, integer $scaleMethod = self::SCALE_INSIDE) : \Joomla\Image\Image
since |
1.0 |
---|---|
throws |
|
Arguments
- $width
mixed
The width of the resized image in pixels or a percentage.- $height
mixed
The height of the resized image in pixels or a percentage.- $createNew
boolean
If true the current image will be cloned, resized and returned; else the current image will be resized and returned.- $scaleMethod
integer
Which method to use for scaling
Response
rotate
Method to rotate the current image.
rotate(mixed $angle, integer $background = -1, boolean $createNew = true) : \Joomla\Image\Image
since |
1.0 |
---|---|
throws |
|
Arguments
- $angle
mixed
The angle of rotation for the image- $background
integer
The background color to use when areas are added due to rotation- $createNew
boolean
If true the current image will be cloned, rotated and returned; else the current image will be rotated and returned.
Response
sanitizeHeight
Method to sanitize a height value.
sanitizeHeight(mixed $height, mixed $width) : integer
since |
1.0 |
---|
Arguments
- $height
mixed
The input height value to sanitize.- $width
mixed
The input width value for reference.
Response
integer
sanitizeOffset
Method to sanitize an offset value like left or top.
sanitizeOffset(mixed $offset) : integer
since |
1.0 |
---|
Arguments
- $offset
mixed
An offset value.
Response
integer
sanitizeWidth
Method to sanitize a width value.
sanitizeWidth(mixed $width, mixed $height) : integer
since |
1.0 |
---|
Arguments
- $width
mixed
The input width value to sanitize.- $height
mixed
The input height value for reference.
Response
integer
setLogger
Sets a logger instance on the object
setLogger(\Psr\Log\LoggerInterface $logger) : \Joomla\Image\Image
since |
1.0 |
---|
Arguments
- $logger
\Psr\Log\LoggerInterface
A PSR-3 compliant logger.
Response
\Joomla\Image\Image
This object for message chaining.
setThumbnailGenerate
Method for set option of generate thumbnail method
setThumbnailGenerate(boolean $quality = true) : void
since |
1.4.0 |
---|
Arguments
- $quality
boolean
True for best quality. False for best speed.
toFile
Method to write the current image out to a file or output directly.
toFile(mixed $path, integer $type = IMAGETYPE_JPEG, array $options = array()) : boolean
link | |
---|---|
since |
1.0 |
throws |
|
Arguments
- $path
mixed
The filesystem path to save the image. When null, the raw image stream will be outputted directly.- $type
integer
The image type to save the file as.- $options
array
The image type options to use in saving the file. For PNG and JPEG formats usequality
key to set compression level (0..9 and 0..100)
Response
boolean
watermark
Watermark the image
watermark(\Joomla\Image\Image $watermark, integer $transparency = 50, integer $bottomMargin, integer $rightMargin) : \Joomla\Image\Image
since |
1.3.0 |
---|---|
link |
Arguments
- $watermark
\Joomla\Image\Image
The Image object containing the watermark graphic- $transparency
integer
The transparency to use for the watermark graphic- $bottomMargin
integer
The margin from the bottom of this image- $rightMargin
integer
The margin from the right side of this image
Response
Constants
SCALE_FILL
Value | 1 |
---|---|
const |
integer |
since |
1.0 |
Type(s)
SCALE_INSIDE
Value | 2 |
---|---|
const |
integer |
since |
1.0 |
Type(s)
SCALE_OUTSIDE
Value | 3 |
---|---|
const |
integer |
since |
1.0 |
Type(s)
CROP
Value | 4 |
---|---|
const |
integer |
since |
1.0 |
Type(s)
CROP_RESIZE
Value | 5 |
---|---|
const |
integer |
since |
1.0 |
Type(s)
SCALE_FIT
Value | 6 |
---|---|
const |
integer |
since |
1.0 |
Type(s)
ORIENTATION_LANDSCAPE
Value | 'landscape' |
---|---|
const |
string |
since |
1.2.0 |
Type(s)
ORIENTATION_PORTRAIT
Value | 'portrait' |
---|---|
const |
string |
since |
1.2.0 |
Type(s)
ORIENTATION_SQUARE
Value | 'square' |
---|---|
const |
string |
since |
1.2.0 |
Type(s)
Properties
handle
The image resource handle.
since |
1.0 |
---|
Type(s)
resource|\GdImage
path
The source image path.
since |
1.0 |
---|
Type(s)
string
formats
Whether or not different image formats are supported.
since |
1.0 |
---|
Type(s)
array
logger
Logger object
since |
1.0 |
---|
Type(s)
\Psr\Log\LoggerInterface
generateBestQuality
Flag if an image should use the best quality available. Disable for improved performance.
since |
1.4.0 |
---|
Type(s)
boolean