Class JImage

Description

Class to manipulate an image.

  • since: 11.3

Located in /libraries/joomla/image/image.php (line 19)


	
			
Class Constant Summary
Variable Summary
 static array $formats
 resource $handle
 string $path
Method Summary
 static stdClass getImageFileProperties (string $path)
 JImage __construct ([mixed $source = null])
 void __destruct ()
 array createThumbs (mixed $thumbSizes, [integer $creationMethod = self::SCALE_INSIDE], [string $thumbsFolder = null])
 JImage crop (mixed $width, mixed $height, [integer $left = null], [integer $top = null], [boolean $createNew = true])
 object JImage cropResize (integer $width, integer $height, [integer $createNew = true])
 boolean destroy ()
 JImage filter (string $type, [array $options = array()])
 array generateThumbs (mixed $thumbSizes, [integer $creationMethod = self::SCALE_INSIDE])
 integer getHeight ()
 string getPath ()
 integer getWidth ()
 boolean isLoaded ()
 bool isTransparent ()
 void loadFile (string $path)
 stdClass prepareDimensions (integer $width, integer $height, integer $scaleMethod)
 JImage resize (mixed $width, mixed $height, [boolean $createNew = true], [integer $scaleMethod = self::SCALE_INSIDE])
 JImage rotate (mixed $angle, [integer $background = -1], [boolean $createNew = true])
 integer sanitizeHeight (mixed $height, mixed $width)
 integer sanitizeOffset (mixed $offset)
 integer sanitizeWidth (mixed $width, mixed $height)
 boolean toFile (string $path, [integer $type = IMAGETYPE_JPEG], [array $options = array()])
Variables
static array $formats = array() (line 73)
  • var: Whether or not different image formats are supported.
  • since: 11.3
  • access: protected
resource $handle (line 61)
  • var: The image resource handle.
  • since: 11.3
  • access: protected
string $path = null (line 67)
  • var: The source image path.
  • since: 11.3
  • access: protected
Methods
static getImageFileProperties (line 129)

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.

  • since: 11.3
  • throws: InvalidArgumentException
  • throws: RuntimeException
  • access: public
static stdClass getImageFileProperties (string $path)
  • string $path: The filesystem path to the image for which to get properties.
Constructor __construct (line 83)

Class constructor.

  • since: 11.3
  • throws: RuntimeException
  • access: public
JImage __construct ([mixed $source = null])
  • mixed $source: Either a file path for a source image or a GD resource handler for an image.
Destructor __destruct (line 1043)

Method to call the destroy() method one last time to free any memory when the object is unset

void __destruct ()
createThumbs (line 246)

Method to create thumbnails from the current image and save them to disk. It allows creation by resizing or croppping the original image.

  • throws: LogicException
  • throws: InvalidArgumentException
  • since: 12.2
  • access: public
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
crop (line 315)

Method to crop the current image.

  • since: 11.3
  • throws: LogicException
  • access: public
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.
cropResize (line 742)

Method to crop an image after resizing it to maintain proportions without having to do all the set up work.

  • return: Object for chaining.
  • since: 12.3
  • access: public
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.
destroy (line 1026)

Method to destroy an image handle and free the memory associated with the handle

  • return: True on success, false on failure or if no image is loaded
  • since: 12.3
  • access: public
boolean destroy ()
filter (line 404)

Method to apply a filter to the image by type. Two examples are: grayscale and sketchy.

  • see: JImageFilter
  • since: 11.3
  • throws: LogicException
  • access: public
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.
generateThumbs (line 175)

Method to generate thumbnails from the current image. It allows creation by resizing or cropping the original image.

  • throws: LogicException
  • throws: InvalidArgumentException
  • since: 12.2
  • access: public
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
getFilterInstance (line 865)

Method to get an image filter instance of a specified type.

  • since: 11.3
  • throws: RuntimeException
  • access: protected
JImageFilter getFilterInstance (string $type)
  • string $type: The image filter type to get.
getHeight (line 429)

Method to get the height of the image in pixels.

  • since: 11.3
  • throws: LogicException
  • access: public
integer getHeight ()
getPath (line 466)

Method to return the path

  • since: 11.3
  • access: public
string getPath ()
getWidth (line 448)

Method to get the width of the image in pixels.

  • since: 11.3
  • throws: LogicException
  • access: public
integer getWidth ()
isLoaded (line 478)

Method to determine whether or not an image has been loaded into the object.

  • since: 11.3
  • access: public
boolean isLoaded ()
isTransparent (line 497)

Method to determine whether or not the image has transparency.

  • since: 11.3
  • throws: LogicException
  • access: public
bool isTransparent ()
loadFile (line 519)

Method to load a file into the JImage object as the resource.

  • throws: InvalidArgumentException
  • throws: RuntimeException
  • since: 11.3
  • access: public
void loadFile (string $path)
  • string $path: The filesystem path to load as an image.
prepareDimensions (line 907)

Method to get the new dimensions for a resized image.

  • since: 11.3
  • throws: InvalidArgumentException If width, height or both given as zero
  • access: protected
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
resize (line 645)

Method to resize the current image.

  • since: 11.3
  • throws: LogicException
  • access: public
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
rotate (line 772)

Method to rotate the current image.

  • since: 11.3
  • throws: LogicException
  • access: public
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.
sanitizeHeight (line 956)

Method to sanitize a height value.

  • since: 11.3
  • access: protected
integer sanitizeHeight (mixed $height, mixed $width)
  • mixed $height: The input height value to sanitize.
  • mixed $width: The input width value for reference.
sanitizeOffset (line 984)

Method to sanitize an offset value like left or top.

  • since: 11.3
  • access: protected
integer sanitizeOffset (mixed $offset)
  • mixed $offset: An offset value.
sanitizeWidth (line 999)

Method to sanitize a width value.

  • since: 11.3
  • access: protected
integer sanitizeWidth (mixed $width, mixed $height)
  • mixed $width: The input width value to sanitize.
  • mixed $height: The input height value for reference.
toFile (line 831)

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.
Class Constants
CROP = 4 (line 43)
  • since: 12.2
CROP_RESIZE = 5 (line 49)
  • since: 12.3
SCALE_FILL = 1 (line 25)
  • since: 11.3
SCALE_FIT = 6 (line 55)
  • since: 3.2
SCALE_INSIDE = 2 (line 31)
  • since: 11.3
SCALE_OUTSIDE = 3 (line 37)
  • since: 11.3

Documentation generated on Tue, 19 Nov 2013 15:05:16 +0100 by phpDocumentor 1.4.3