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.
static stdClass
getImageFileProperties
(string $path)
-
string
$path: The filesystem path to the image for which to get properties.
Class constructor.
JImage
__construct
([mixed $source = null])
-
mixed
$source: Either a file path for a source image or a GD resource handler for an image.
Method to call the destroy() method one last time to free any memory when the object is unset
void
__destruct
()
Method to create thumbnails from the current image and save them to disk. It allows creation by resizing or croppping the original image.
array
createThumbs
(mixed $thumbSizes, [integer $creationMethod = self::SCALE_INSIDE], [string $thumbsFolder = null])
-
mixed
$thumbSizes: string or array of strings. Example: $thumbSizes = array('150x75','250x150');
-
integer
$creationMethod: 1-3 resize $scaleMethod | 4 create croppping
-
string
$thumbsFolder: destination thumbs folder. null generates a thumbs folder in the image folder
Method to crop the current image.
JImage
crop
(
mixed $width,
mixed $height, [
integer $left =
null], [
integer $top =
null], [
boolean $createNew =
true])
-
mixed
$width: The width of the image section to crop in pixels or a percentage.
-
mixed
$height: The height of the image section to crop in pixels or a percentage.
-
integer
$left: The number of pixels from the left to start cropping.
-
integer
$top: The number of pixels from the top to start cropping.
-
boolean
$createNew: If true the current image will be cloned, cropped and returned; else the current image will be cropped and returned.
Method to crop an image after resizing it to maintain proportions without having to do all the set up work.
object JImage
cropResize
(
integer $width,
integer $height, [
integer $createNew =
true])
-
integer
$width: The desired width of the image in pixels or a percentage.
-
integer
$height: The desired height of the image in pixels or a percentage.
-
integer
$createNew: If true the current image will be cloned, resized, cropped and returned.
Method to destroy an image handle and free the memory associated with the handle
boolean
destroy
()
Method to apply a filter to the image by type. Two examples are: grayscale and sketchy.
JImage
filter
(
string $type, [
array $options =
array()])
-
string
$type: The name of the image filter to apply.
-
array
$options: An array of options for the filter.
Method to generate thumbnails from the current image. It allows creation by resizing or cropping the original image.
array
generateThumbs
(mixed $thumbSizes, [integer $creationMethod = self::SCALE_INSIDE])
-
mixed
$thumbSizes: String or array of strings. Example: $thumbSizes = array('150x75','250x150');
-
integer
$creationMethod: 1-3 resize $scaleMethod | 4 create croppping | 5 resize then crop
Method to get an image filter instance of a specified type.
-
string
$type: The image filter type to get.
Method to get the height of the image in pixels.
integer
getHeight
()
Method to return the path
string
getPath
()
Method to get the width of the image in pixels.
integer
getWidth
()
Method to determine whether or not an image has been loaded into the object.
boolean
isLoaded
()
Method to determine whether or not the image has transparency.
bool
isTransparent
()
Method to load a file into the JImage object as the resource.
void
loadFile
(string $path)
-
string
$path: The filesystem path to load as an image.
Method to get the new dimensions for a resized image.
stdClass
prepareDimensions
(integer $width, integer $height, integer $scaleMethod)
-
integer
$width: The width of the resized image in pixels.
-
integer
$height: The height of the resized image in pixels.
-
integer
$scaleMethod: The method to use for scaling
Method to resize the current image.
JImage
resize
(
mixed $width,
mixed $height, [
boolean $createNew =
true], [
integer $scaleMethod =
self::SCALE_INSIDE])
-
mixed
$width: The width of the resized image in pixels or a percentage.
-
mixed
$height: The height of the resized image in pixels or a percentage.
-
boolean
$createNew: If true the current image will be cloned, resized and returned; else the current image will be resized and returned.
-
integer
$scaleMethod: Which method to use for scaling
Method to rotate the current image.
JImage
rotate
(
mixed $angle, [
integer $background =
-1], [
boolean $createNew =
true])
-
mixed
$angle: The angle of rotation for the image
-
integer
$background: The background color to use when areas are added due to rotation
-
boolean
$createNew: If true the current image will be cloned, rotated and returned; else the current image will be rotated and returned.
Method to sanitize a height value.
integer
sanitizeHeight
(mixed $height, mixed $width)
-
mixed
$height: The input height value to sanitize.
-
mixed
$width: The input width value for reference.
Method to sanitize an offset value like left or top.
integer
sanitizeOffset
(mixed $offset)
-
mixed
$offset: An offset value.
Method to sanitize a width value.
integer
sanitizeWidth
(mixed $width, mixed $height)
-
mixed
$width: The input width value to sanitize.
-
mixed
$height: The input height value for reference.
Method to write the current image out to a file.
boolean
toFile
(string $path, [integer $type = IMAGETYPE_JPEG], [array $options = array()])
-
string
$path: The filesystem path to save the image.
-
integer
$type: The image type to save the file as.
-
array
$options: The image type options to use in saving the file.