JImage
Class to manipulate an image.
| package |
Joomla.Platform |
|---|---|
| subpackage |
Image |
| since |
11.3 |
Methods
__construct
Class constructor.
__construct(mixed $source = null)
| since |
11.3 |
|---|---|
| throws |
|
Arguments
- $source
mixedEither a file path for a source image or a GD resource handler for an image.
crop
Method to crop the current image.
crop(mixed $width, mixed $height, integer $left, integer $top, boolean $createNew = true) : \JImage
| since |
11.3 |
|---|---|
| throws |
|
Arguments
- $width
mixedThe width of the image section to crop in pixels or a percentage.- $height
mixedThe height of the image section to crop in pixels or a percentage.- $left
integerThe number of pixels from the left to start cropping.- $top
integerThe number of pixels from the top to start cropping.- $createNew
booleanIf true the current image will be cloned, cropped and returned; else the current image will be cropped and returned.
Response
filter
Method to apply a filter to the image by type. Two examples are: grayscale and sketchy.
filter(string $type, array $options = array()) : \JImage
| since |
11.3 |
|---|---|
| see | \JImageFilter |
| throws |
|
Arguments
- $type
stringThe name of the image filter to apply.- $options
arrayAn array of options for the filter.
Response
getFilterInstance
Method to get an image filter instance of a specified type.
getFilterInstance(string $type) : \JImageFilter
| since |
11.3 |
|---|---|
| throws |
|
Arguments
- $type
stringThe image filter type to get.
Response
getHeight
Method to get the height of the image in pixels.
getHeight() : integer
| since |
11.3 |
|---|---|
| throws |
|
Response
integer
getImageFileProperties
Method to return a properties object for an image given a filesystem path. The result object has values for image width, height, type, attributes, mime type, bits, and channels.
getImageFileProperties(string $path) : object
| since |
11.3 |
|---|---|
| throws |
|
Arguments
- $path
stringThe filesystem path to the image for which to get properties.
Response
object
getPath
Method to return the path
getPath() : string
| since |
11.3 |
|---|
Response
string
getWidth
Method to get the width of the image in pixels.
getWidth() : integer
| since |
11.3 |
|---|---|
| throws |
|
Response
integer
isLoaded
Method to determine whether or not an image has been loaded into the object.
isLoaded() : boolean
| since |
11.3 |
|---|
Response
boolean
isTransparent
Method to determine whether or not the image has transparency.
isTransparent() : boolean
| since |
11.3 |
|---|---|
| throws |
|
Response
boolean
loadFile
Method to load a file into the JImage object as the resource.
loadFile(string $path) : void
| since |
11.3 |
|---|---|
| throws |
|
Arguments
- $path
stringThe 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) : object
| since |
11.3 |
|---|---|
| throws |
|
Arguments
- $width
integerThe width of the resized image in pixels.- $height
integerThe height of the resized image in pixels.- $scaleMethod
integerThe method to use for scaling
Response
object
resize
Method to resize the current image.
resize(mixed $width, mixed $height, boolean $createNew = true, integer $scaleMethod = self::SCALE_INSIDE) : \JImage
| since |
11.3 |
|---|---|
| throws |
|
Arguments
- $width
mixedThe width of the resized image in pixels or a percentage.- $height
mixedThe height of the resized image in pixels or a percentage.- $createNew
booleanIf true the current image will be cloned, resized and returned; else the current image will be resized and returned.- $scaleMethod
integerWhich method to use for scaling
Response
rotate
Method to rotate the current image.
rotate(mixed $angle, integer $background = -1, boolean $createNew = true) : \JImage
| since |
11.3 |
|---|---|
| throws |
|
Arguments
- $angle
mixedThe angle of rotation for the image- $background
integerThe background color to use when areas are added due to rotation- $createNew
booleanIf 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 |
11.3 |
|---|
Arguments
- $height
mixedThe input height value to sanitize.- $width
mixedThe input width value for reference.
Response
integer
sanitizeOffset
Method to sanitize an offset value like left or top.
sanitizeOffset(mixed $offset) : integer
| since |
11.3 |
|---|
Arguments
- $offset
mixedAn offset value.
Response
integer
sanitizeWidth
Method to sanitize a width value.
sanitizeWidth(mixed $width, mixed $height) : integer
| since |
11.3 |
|---|
Arguments
- $width
mixedThe input width value to sanitize.- $height
mixedThe input height value for reference.
Response
integer
toFile
Method to write the current image out to a file.
toFile(string $path, integer $type = IMAGETYPE_JPEG, array $options = array()) : void
| see | |
|---|---|
| since |
11.3 |
| throws |
|
Arguments
- $path
stringThe filesystem path to save the image.- $type
integerThe image type to save the file as.- $options
arrayThe image type options to use in saving the file.
Constants
SCALE_FILL
| Value | 1 |
|---|---|
| const |
integer |
| since |
11.3 |
Type(s)
SCALE_INSIDE
| Value | 2 |
|---|---|
| const |
integer |
| since |
11.3 |
Type(s)
SCALE_OUTSIDE
| Value | 3 |
|---|---|
| const |
integer |
| since |
11.3 |
Type(s)
Properties
handle
The image resource handle.
| since |
11.3 |
|---|
Type(s)
resource
path
The source image path.
| since |
11.3 |
|---|
Type(s)
string
formats
Whether or not different image formats are supported.
| since |
11.3 |
|---|
Type(s)
array