Back to Joomla project (class list)

Class Image - list of methods

Class to manipulate an image.
Package: Joomla\CMS\Image
Copyright: (C) 2017 Open Source Matters, Inc.
License: GNU General Public License version 2 or later; see LICENSE
Located at: Joomla/Image/Image.php
Project: Joomla

Method Summary

public
(mixed $source = null)

Class constructor.
Parameters
  • mixed $source Either a file path for a source image or a GD resource handler for an image.
Since
  • 1.7.3
-
  • \RuntimeException
Show source code of this method: __construct Source Code

public resource
()

Get the image resource handle
Returns
  • resource
Since
  • 3.8.0
-
  • \LogicException if an image has not been loaded into the instance
Show source code of this method: getHandle Source Code

public static \stdClass
(mixed $path)

Method to return a properties object for an image given a filesystem path.
Parameters
  • string $path The filesystem path to the image for which to get properties.
Returns
  • \stdClass
Since
  • 2.5.0
-
  • \InvalidArgumentException
  • \RuntimeException
Show source code of this method: getImageFileProperties Source Code

public mixed
()

Method to detect whether an image's orientation is landscape, portrait or square.
Returns
  • mixed Orientation string or null.
Since
  • 3.4.2
Show source code of this method: getOrientation Source Code

private static string
(int $width, int $height)

Compare width and height integers to determine image orientation.
Parameters
  • int $width The width value to use for calculation
  • int $height The height value to use for calculation
Returns
  • string Orientation string
Since
  • 3.4.2
Show source code of this method: getOrientationString Source Code

public array
(mixed $thumbSizes, mixed $creationMethod = self::SCALE_INSIDE)

Method to generate thumbnails from the current image. It allows creation by resizing or cropping the original image.
Parameters
  • mixed $thumbSizes String or array of strings. Example: $thumbSizes = array('150x75','250x150');
  • int $creationMethod 1-3 resize $scaleMethod | 4 create cropping | 5 resize then crop
Returns
  • array
Since
  • 2.5.0
-
  • \LogicException
  • \InvalidArgumentException
Show source code of this method: generateThumbs Source Code

public array
(mixed $thumbSizes, mixed $creationMethod = self::SCALE_INSIDE, mixed $thumbsFolder = null)

Method to create thumbnails from the current image and save them to disk. It allows creation by resizing or cropping the original image.
Parameters
  • mixed $thumbSizes string or array of strings. Example: $thumbSizes = array('150x75','250x150');
  • int $creationMethod 1-3 resize $scaleMethod | 4 create cropping
  • string $thumbsFolder destination thumbs folder. null generates a thumbs folder in the image folder
Returns
  • array
Since
  • 2.5.0
-
  • \LogicException
  • \InvalidArgumentException
Show source code of this method: createThumbs Source Code

public \Joomla\CMS\Image\Image
(mixed $width, mixed $height, mixed $left = null, mixed $top = null, mixed $createNew = true)

Method to crop the current image.
Parameters
  • 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.
  • int $left The number of pixels from the left to start cropping.
  • int $top The number of pixels from the top to start cropping.
  • bool $createNew If true the current image will be cloned, cropped and returned; else the current image will be cropped and returned.
Returns
  • \Joomla\CMS\Image\Image
Since
  • 2.5.0
-
  • \LogicException
Show source code of this method: crop Source Code

public \Joomla\CMS\Image\Image
(mixed $type, array $options = [])

Method to apply a filter to the image by type. Two examples are: grayscale and sketchy.
Parameters
  • string $type The name of the image filter to apply.
  • array $options An array of options for the filter.
Returns
  • \Joomla\CMS\Image\Image
Since
  • 2.5.0
-
  • \Joomla\CMS\Image\Filter
  • \LogicException
Show source code of this method: filter Source Code

public int
()

Method to get the height of the image in pixels.
Returns
  • int
Since
  • 2.5.0
-
  • \LogicException
Show source code of this method: getHeight Source Code

public int
()

Method to get the width of the image in pixels.
Returns
  • int
Since
  • 2.5.0
-
  • \LogicException
Show source code of this method: getWidth Source Code

public string
()

Method to return the path
Returns
  • string
Since
  • 2.5.0
Show source code of this method: getPath Source Code

public bool
()

Method to determine whether or not an image has been loaded into the object.
Returns
  • bool
Since
  • 2.5.0
Show source code of this method: isLoaded Source Code

public bool
()

Method to determine whether or not the image has transparency.
Returns
  • bool
Since
  • 2.5.0
-
  • \LogicException
Show source code of this method: isTransparent Source Code

public void
(mixed $path)

Method to load a file into the Image object as the resource.
Parameters
  • string $path The filesystem path to load as an image.
Returns
  • void
Since
  • 2.5.0
-
  • \InvalidArgumentException
  • \RuntimeException
Show source code of this method: loadFile Source Code

public \Joomla\CMS\Image\Image
(mixed $width, mixed $height, mixed $createNew = true, mixed $scaleMethod = self::SCALE_INSIDE)

Method to resize the current image.
Parameters
  • 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.
  • bool $createNew If true the current image will be cloned, resized and returned; else the current image will be resized and returned.
  • int $scaleMethod Which method to use for scaling
Returns
  • \Joomla\CMS\Image\Image
Since
  • 2.5.0
-
  • \LogicException
Show source code of this method: resize Source Code

public \Joomla\CMS\Image\Image
(mixed $width, mixed $height, mixed $createNew = true)

Method to crop an image after resizing it to maintain proportions without having to do all the set up work.
Parameters
  • int $width The desired width of the image in pixels or a percentage.
  • int $height The desired height of the image in pixels or a percentage.
  • bool $createNew If true the current image will be cloned, resized, cropped and returned.
Returns
  • \Joomla\CMS\Image\Image
Since
  • 2.5.0
Show source code of this method: cropResize Source Code

public \Joomla\CMS\Image\Image
(mixed $angle, mixed $background = -1, mixed $createNew = true)

Method to rotate the current image.
Parameters
  • mixed $angle The angle of rotation for the image
  • int $background The background color to use when areas are added due to rotation
  • bool $createNew If true the current image will be cloned, rotated and returned; else the current image will be rotated and returned.
Returns
  • \Joomla\CMS\Image\Image
Since
  • 2.5.0
-
  • \LogicException
Show source code of this method: rotate Source Code

public \Joomla\CMS\Image\Image
(mixed $mode, mixed $createNew = true)

Method to flip the current image.
Parameters
  • int $mode The flip mode for flipping the image {@link http://php.net/imageflip#refsect1-function.imageflip-parameters}
  • bool $createNew If true the current image will be cloned, flipped and returned; else the current image will be flipped and returned.
Returns
  • \Joomla\CMS\Image\Image
Since
  • 3.4.2
-
  • \LogicException
Show source code of this method: flip Source Code

public \Joomla\CMS\Image\Image
(\Joomla\CMS\Image\Image $watermark, mixed $transparency = 50, mixed $bottomMargin = 0, mixed $rightMargin = 0)

Watermark the image
Parameters
  • \Joomla\CMS\Image\Image $watermark The Image object containing the watermark graphic
  • int $transparency The transparency to use for the watermark graphic
  • int $bottomMargin The margin from the bottom of this image
  • int $rightMargin The margin from the right side of this image
Returns
  • \Joomla\CMS\Image\Image
Since
  • 3.8.0
-
  • https://secure.php.net/manual/en/image.examples-watermark.php
Show source code of this method: watermark Source Code

public bool
(mixed $path, mixed $type = IMAGETYPE_JPEG, array $options = [])

Method to write the current image out to a file or output directly.
Parameters
  • mixed $path The filesystem path to save the image. When null, the raw image stream will be outputted directly.
  • int $type The image type to save the file as.
  • array $options The image type options to use in saving the file. For PNG and JPEG formats use `quality` key to set compression level (0..9 and 0..100)
Returns
  • bool
Since
  • 2.5.0
-
  • http://www.php.net/manual/image.constants.php
  • \LogicException
Show source code of this method: toFile Source Code

protected \Joomla\CMS\Image\ImageFilter
(mixed $type)

Method to get an image filter instance of a specified type.
Parameters
  • string $type The image filter type to get.
Returns
  • \Joomla\CMS\Image\ImageFilter
Since
  • 2.5.0
-
  • \RuntimeException
Show source code of this method: getFilterInstance Source Code

protected \stdClass
(mixed $width, mixed $height, mixed $scaleMethod)

Method to get the new dimensions for a resized image.
Parameters
  • int $width The width of the resized image in pixels.
  • int $height The height of the resized image in pixels.
  • int $scaleMethod The method to use for scaling
Returns
  • \stdClass
Since
  • 2.5.0
-
  • \InvalidArgumentException If width, height or both given as zero
Show source code of this method: prepareDimensions Source Code

protected int
(mixed $height, mixed $width)

Method to sanitize a height value.
Parameters
  • mixed $height The input height value to sanitize.
  • mixed $width The input width value for reference.
Returns
  • int
Since
  • 2.5.0
Show source code of this method: sanitizeHeight Source Code

protected int
(mixed $offset)

Method to sanitize an offset value like left or top.
Parameters
  • mixed $offset An offset value.
Returns
  • int
Since
  • 2.5.0
Show source code of this method: sanitizeOffset Source Code

protected int
(mixed $width, mixed $height)

Method to sanitize a width value.
Parameters
  • mixed $width The input width value to sanitize.
  • mixed $height The input height value for reference.
Returns
  • int
Since
  • 2.5.0
Show source code of this method: sanitizeWidth Source Code

public bool
()

Method to destroy an image handle and free the memory associated with the handle
Returns
  • bool True on success, false on failure or if no image is loaded
Since
  • 2.5.0
Show source code of this method: destroy Source Code

public
()

Method to call the destroy() method one last time to free any memory when the object is unset
Since
  • 2.5.0
-
  • \Joomla\CMS\Image\Image::destroy()
Show source code of this method: __destruct Source Code

public void
(mixed $quality = true)

Method for set option of generate thumbnail method
Parameters
  • bool $quality True for best quality. False for best speed.
Returns
  • void
Since
  • 3.7.0
Show source code of this method: setThumbnailGenerate Source Code

Properties Summary

protected resource
$handle
Since
  • 2.5.0
protected string
$path
Since
  • 2.5.0
protected static array
$formats
Since
  • 2.5.0
protected bool
$generateBestQuality
Since
  • 3.7.0

Constants Summary

public
$SCALE_FILL
Since
  • 2.5.0
public
$SCALE_INSIDE
Since
  • 2.5.0
public
$SCALE_OUTSIDE
Since
  • 2.5.0
public
$CROP
Since
  • 2.5.0
public
$CROP_RESIZE
Since
  • 2.5.0
public
$SCALE_FIT
Since
  • 2.5.0
public
$ORIENTATION_LANDSCAPE
Since
  • 3.4.2
public
$ORIENTATION_PORTRAIT
Since
  • 3.4.2
public
$ORIENTATION_SQUARE
Since
  • 3.4.2

Tags Summary

Since
1.7.3