Joomla Platform  13.1
Documentation des API du framework Joomla Platform
 Tout Classes Espaces de nommage Fichiers Fonctions Variables Pages
Référence de la classe JImage

Liste de tous les membres

Fonctions membres publiques

 __construct ($source=null)
 generateThumbs ($thumbSizes, $creationMethod=self::SCALE_INSIDE)
 createThumbs ($thumbSizes, $creationMethod=self::SCALE_INSIDE, $thumbsFolder=null)
 crop ($width, $height, $left=null, $top=null, $createNew=true)
 filter ($type, array $options=array())
 getHeight ()
 getWidth ()
 getPath ()
 isLoaded ()
 isTransparent ()
 loadFile ($path)
 resize ($width, $height, $createNew=true, $scaleMethod=self::SCALE_INSIDE)
 cropResize ($width, $height, $createNew=true)
 rotate ($angle, $background=-1, $createNew=true)
 toFile ($path, $type=IMAGETYPE_JPEG, array $options=array())
 destroy ()
 __destruct ()

Fonctions membres publiques statiques

static getImageFileProperties ($path)

Attributs publics

const SCALE_FILL = 1
const SCALE_INSIDE = 2
const SCALE_OUTSIDE = 3
const CROP = 4
const CROP_RESIZE = 5
const SCALE_FIT = 6

Fonctions membres protégées

 getFilterInstance ($type)
 prepareDimensions ($width, $height, $scaleMethod)
 sanitizeHeight ($height, $width)
 sanitizeOffset ($offset)
 sanitizeWidth ($width, $height)

Attributs protégés

 $handle
 $path = null

Attributs protégés statiques

static $formats = array()

Description détaillée

Définition à la ligne 19 du fichier image.php.


Documentation des constructeurs et destructeur

JImage::__construct (   $source = null)

Class constructor.

Paramètres:
mixed$sourceEither a file path for a source image or a GD resource handler for an image.
Depuis:
11.3
Exceptions:
RuntimeException

Définition à la ligne 83 du fichier image.php.

Références JLog\add(), et JLog\ERROR.

{
// Verify that GD support for PHP is available.
if (!extension_loaded('gd'))
{
// @codeCoverageIgnoreStart
JLog::add('The GD extension for PHP is not available.', JLog::ERROR);
throw new RuntimeException('The GD extension for PHP is not available.');
// @codeCoverageIgnoreEnd
}
// Determine which image types are supported by GD, but only once.
if (!isset(self::$formats[IMAGETYPE_JPEG]))
{
$info = gd_info();
self::$formats[IMAGETYPE_JPEG] = ($info['JPEG Support']) ? true : false;
self::$formats[IMAGETYPE_PNG] = ($info['PNG Support']) ? true : false;
self::$formats[IMAGETYPE_GIF] = ($info['GIF Read Support']) ? true : false;
}
// If the source input is a resource, set it as the image handle.
if (is_resource($source) && (get_resource_type($source) == 'gd'))
{
$this->handle = &$source;
}
elseif (!empty($source) && is_string($source))
{
// If the source input is not empty, assume it is a path and populate the image handle.
$this->loadFile($source);
}
}

+ Voici le graphe d'appel pour cette fonction :

JImage::__destruct ( )

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

Voir également:
JImage::destroy()
Depuis:
12.3

Définition à la ligne 1043 du fichier image.php.

{
$this->destroy();
}

Documentation des fonctions membres

JImage::createThumbs (   $thumbSizes,
  $creationMethod = self::SCALE_INSIDE,
  $thumbsFolder = null 
)

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

Paramètres:
mixed$thumbSizesstring or array of strings. Example: $thumbSizes = array('150x75','250x150');
integer$creationMethod1-3 resize $scaleMethod | 4 create croppping
string$thumbsFolderdestination thumbs folder. null generates a thumbs folder in the image folder
Renvoie:
array
Depuis:
12.2
Exceptions:
LogicException
InvalidArgumentException

Définition à la ligne 246 du fichier image.php.

{
// Make sure the resource handle is valid.
if (!$this->isLoaded())
{
throw new LogicException('No valid image was loaded.');
}
// No thumbFolder set -> we will create a thumbs folder in the current image folder
if (is_null($thumbsFolder))
{
$thumbsFolder = dirname($this->getPath()) . '/thumbs';
}
// Check destination
if (!is_dir($thumbsFolder) && (!is_dir(dirname($thumbsFolder)) || !@mkdir($thumbsFolder)))
{
throw new InvalidArgumentException('Folder does not exist and cannot be created: ' . $thumbsFolder);
}
// Process thumbs
$thumbsCreated = array();
if ($thumbs = $this->generateThumbs($thumbSizes, $creationMethod))
{
// Parent image properties
$imgProperties = self::getImageFileProperties($this->getPath());
foreach ($thumbs as $thumb)
{
// Get thumb properties
$thumbWidth = $thumb->getWidth();
$thumbHeight = $thumb->getHeight();
// Generate thumb name
$filename = pathinfo($this->getPath(), PATHINFO_FILENAME);
$fileExtension = pathinfo($this->getPath(), PATHINFO_EXTENSION);
$thumbFileName = $filename . '_' . $thumbWidth . 'x' . $thumbHeight . '.' . $fileExtension;
// Save thumb file to disk
$thumbFileName = $thumbsFolder . '/' . $thumbFileName;
if ($thumb->toFile($thumbFileName, $imgProperties->type))
{
// Return JImage object with thumb path to ease further manipulation
$thumb->path = $thumbFileName;
$thumbsCreated[] = $thumb;
}
}
}
return $thumbsCreated;
}
JImage::crop (   $width,
  $height,
  $left = null,
  $top = null,
  $createNew = true 
)

Method to crop the current image.

Paramètres:
mixed$widthThe width of the image section to crop in pixels or a percentage.
mixed$heightThe height of the image section to crop in pixels or a percentage.
integer$leftThe number of pixels from the left to start cropping.
integer$topThe number of pixels from the top to start cropping.
boolean$createNewIf true the current image will be cloned, cropped and returned; else the current image will be cropped and returned.
Renvoie:
JImage
Depuis:
11.3
Exceptions:
LogicException

Définition à la ligne 315 du fichier image.php.

{
// Make sure the resource handle is valid.
if (!$this->isLoaded())
{
throw new LogicException('No valid image was loaded.');
}
// Sanitize width.
$width = $this->sanitizeWidth($width, $height);
// Sanitize height.
$height = $this->sanitizeHeight($height, $width);
// Autocrop offsets
if (is_null($left))
{
$left = round(($this->getWidth() - $width) / 2);
}
if (is_null($top))
{
$top = round(($this->getHeight() - $height) / 2);
}
// Sanitize left.
$left = $this->sanitizeOffset($left);
// Sanitize top.
$top = $this->sanitizeOffset($top);
// Create the new truecolor image handle.
$handle = imagecreatetruecolor($width, $height);
// Allow transparency for the new image handle.
imagealphablending($handle, false);
imagesavealpha($handle, true);
if ($this->isTransparent())
{
// Get the transparent color values for the current image.
$rgba = imageColorsForIndex($this->handle, imagecolortransparent($this->handle));
$color = imageColorAllocate($this->handle, $rgba['red'], $rgba['green'], $rgba['blue']);
// Set the transparent color values for the new image.
imagecolortransparent($handle, $color);
imagefill($handle, 0, 0, $color);
imagecopyresized($handle, $this->handle, 0, 0, $left, $top, $width, $height, $width, $height);
}
else
{
imagecopyresampled($handle, $this->handle, 0, 0, $left, $top, $width, $height, $width, $height);
}
// If we are cropping to a new image, create a new JImage object.
if ($createNew)
{
// @codeCoverageIgnoreStart
$new = new JImage($handle);
return $new;
// @codeCoverageIgnoreEnd
}
// Swap out the current handle for the new image handle.
else
{
// Free the memory from the current handle
$this->destroy();
$this->handle = $handle;
return $this;
}
}
JImage::cropResize (   $width,
  $height,
  $createNew = true 
)

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

Paramètres:
integer$widthThe desired width of the image in pixels or a percentage.
integer$heightThe desired height of the image in pixels or a percentage.
integer$createNewIf true the current image will be cloned, resized, cropped and returned.
Renvoie:
object JImage Object for chaining.
Depuis:
12.3

Définition à la ligne 742 du fichier image.php.

{
$width = $this->sanitizeWidth($width, $height);
$height = $this->sanitizeHeight($height, $width);
if (($this->getWidth() / $width) < ($this->getHeight() / $height))
{
$this->resize($width, 0, false);
}
else
{
$this->resize(0, $height, false);
}
return $this->crop($width, $height, null, null, $createNew);
}
JImage::destroy ( )

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

Renvoie:
boolean True on success, false on failure or if no image is loaded
Depuis:
12.3

Définition à la ligne 1026 du fichier image.php.

{
if ($this->isLoaded())
{
return imagedestroy($this->handle);
}
return false;
}
JImage::filter (   $type,
array  $options = array() 
)

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

Paramètres:
string$typeThe name of the image filter to apply.
array$optionsAn array of options for the filter.
Renvoie:
JImage
Depuis:
11.3
Voir également:
JImageFilter
Exceptions:
LogicException

Définition à la ligne 404 du fichier image.php.

{
// Make sure the resource handle is valid.
if (!$this->isLoaded())
{
throw new LogicException('No valid image was loaded.');
}
// Get the image filter instance.
$filter = $this->getFilterInstance($type);
// Execute the image filter.
$filter->execute($options);
return $this;
}
JImage::generateThumbs (   $thumbSizes,
  $creationMethod = self::SCALE_INSIDE 
)

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

Paramètres:
mixed$thumbSizesString or array of strings. Example: $thumbSizes = array('150x75','250x150');
integer$creationMethod1-3 resize $scaleMethod | 4 create croppping | 5 resize then crop
Renvoie:
array
Depuis:
12.2
Exceptions:
LogicException
InvalidArgumentException

Définition à la ligne 175 du fichier image.php.

{
// Make sure the resource handle is valid.
if (!$this->isLoaded())
{
throw new LogicException('No valid image was loaded.');
}
// Accept a single thumbsize string as parameter
if (!is_array($thumbSizes))
{
$thumbSizes = array($thumbSizes);
}
// Process thumbs
$generated = array();
if (!empty($thumbSizes))
{
foreach ($thumbSizes as $thumbSize)
{
// Desired thumbnail size
$size = explode('x', strtolower($thumbSize));
if (count($size) != 2)
{
throw new InvalidArgumentException('Invalid thumb size received: ' . $thumbSize);
}
$thumbWidth = $size[0];
$thumbHeight = $size[1];
switch ($creationMethod)
{
// Case for self::CROP
case 4:
$thumb = $this->crop($thumbWidth, $thumbHeight, null, null, true);
break;
// Case for self::CROP_RESIZE
case 5:
$thumb = $this->cropResize($thumbWidth, $thumbHeight, true);
break;
default:
$thumb = $this->resize($thumbWidth, $thumbHeight, true, $creationMethod);
break;
}
// Store the thumb in the results array
$generated[] = $thumb;
}
}
return $generated;
}
JImage::getFilterInstance (   $type)
protected

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

Paramètres:
string$typeThe image filter type to get.
Renvoie:
JImageFilter
Depuis:
11.3
Exceptions:
RuntimeException

Définition à la ligne 865 du fichier image.php.

Références JLog\add(), et JLog\ERROR.

{
// Sanitize the filter type.
$type = strtolower(preg_replace('#[^A-Z0-9_]#i', '', $type));
// Verify that the filter type exists.
$className = 'JImageFilter' . ucfirst($type);
if (!class_exists($className))
{
JLog::add('The ' . ucfirst($type) . ' image filter is not available.', JLog::ERROR);
throw new RuntimeException('The ' . ucfirst($type) . ' image filter is not available.');
}
// Instantiate the filter object.
$instance = new $className($this->handle);
// Verify that the filter type is valid.
if (!($instance instanceof JImageFilter))
{
// @codeCoverageIgnoreStart
JLog::add('The ' . ucfirst($type) . ' image filter is not valid.', JLog::ERROR);
throw new RuntimeException('The ' . ucfirst($type) . ' image filter is not valid.');
// @codeCoverageIgnoreEnd
}
return $instance;
}

+ Voici le graphe d'appel pour cette fonction :

JImage::getHeight ( )

Method to get the height of the image in pixels.

Renvoie:
integer
Depuis:
11.3
Exceptions:
LogicException

Définition à la ligne 429 du fichier image.php.

{
// Make sure the resource handle is valid.
if (!$this->isLoaded())
{
throw new LogicException('No valid image was loaded.');
}
return imagesy($this->handle);
}
static JImage::getImageFileProperties (   $path)
static

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.

Paramètres:
string$pathThe filesystem path to the image for which to get properties.
Renvoie:
stdClass
Depuis:
11.3
Exceptions:
InvalidArgumentException
RuntimeException

Définition à la ligne 129 du fichier image.php.

{
// Make sure the file exists.
if (!file_exists($path))
{
throw new InvalidArgumentException('The image file does not exist.');
}
// Get the image file information.
$info = getimagesize($path);
if (!$info)
{
// @codeCoverageIgnoreStart
throw new RuntimeException('Unable to get properties for the image.');
// @codeCoverageIgnoreEnd
}
// Build the response object.
$properties = (object) array(
'width' => $info[0],
'height' => $info[1],
'type' => $info[2],
'attributes' => $info[3],
'bits' => isset($info['bits']) ? $info['bits'] : null,
'channels' => isset($info['channels']) ? $info['channels'] : null,
'mime' => $info['mime']
);
return $properties;
}
JImage::getPath ( )

Method to return the path

Renvoie:
string
Depuis:
11.3

Définition à la ligne 466 du fichier image.php.

{
return $this->path;
}
JImage::getWidth ( )

Method to get the width of the image in pixels.

Renvoie:
integer
Depuis:
11.3
Exceptions:
LogicException

Définition à la ligne 448 du fichier image.php.

{
// Make sure the resource handle is valid.
if (!$this->isLoaded())
{
throw new LogicException('No valid image was loaded.');
}
return imagesx($this->handle);
}
JImage::isLoaded ( )

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

Renvoie:
boolean
Depuis:
11.3

Définition à la ligne 478 du fichier image.php.

{
// Make sure the resource handle is valid.
if (!is_resource($this->handle) || (get_resource_type($this->handle) != 'gd'))
{
return false;
}
return true;
}
JImage::isTransparent ( )

Method to determine whether or not the image has transparency.

Renvoie:
bool
Depuis:
11.3
Exceptions:
LogicException

Définition à la ligne 497 du fichier image.php.

{
// Make sure the resource handle is valid.
if (!$this->isLoaded())
{
throw new LogicException('No valid image was loaded.');
}
return (imagecolortransparent($this->handle) >= 0);
}
JImage::loadFile (   $path)

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

Paramètres:
string$pathThe filesystem path to load as an image.
Renvoie:
void
Depuis:
11.3
Exceptions:
InvalidArgumentException
RuntimeException

Définition à la ligne 519 du fichier image.php.

Références JLog\add(), et JLog\ERROR.

{
// Destroy the current image handle if it exists
$this->destroy();
// Make sure the file exists.
if (!file_exists($path))
{
throw new InvalidArgumentException('The image file does not exist.');
}
// Get the image properties.
// Attempt to load the image based on the MIME-Type
switch ($properties->mime)
{
case 'image/gif':
// Make sure the image type is supported.
if (empty(self::$formats[IMAGETYPE_GIF]))
{
// @codeCoverageIgnoreStart
JLog::add('Attempting to load an image of unsupported type GIF.', JLog::ERROR);
throw new RuntimeException('Attempting to load an image of unsupported type GIF.');
// @codeCoverageIgnoreEnd
}
// Attempt to create the image handle.
$handle = imagecreatefromgif($path);
if (!is_resource($handle))
{
// @codeCoverageIgnoreStart
throw new RuntimeException('Unable to process GIF image.');
// @codeCoverageIgnoreEnd
}
$this->handle = $handle;
break;
case 'image/jpeg':
// Make sure the image type is supported.
if (empty(self::$formats[IMAGETYPE_JPEG]))
{
// @codeCoverageIgnoreStart
JLog::add('Attempting to load an image of unsupported type JPG.', JLog::ERROR);
throw new RuntimeException('Attempting to load an image of unsupported type JPG.');
// @codeCoverageIgnoreEnd
}
// Attempt to create the image handle.
$handle = imagecreatefromjpeg($path);
if (!is_resource($handle))
{
// @codeCoverageIgnoreStart
throw new RuntimeException('Unable to process JPG image.');
// @codeCoverageIgnoreEnd
}
$this->handle = $handle;
break;
case 'image/png':
// Make sure the image type is supported.
if (empty(self::$formats[IMAGETYPE_PNG]))
{
// @codeCoverageIgnoreStart
JLog::add('Attempting to load an image of unsupported type PNG.', JLog::ERROR);
throw new RuntimeException('Attempting to load an image of unsupported type PNG.');
// @codeCoverageIgnoreEnd
}
// Attempt to create the image handle.
$handle = imagecreatefrompng($path);
if (!is_resource($handle))
{
// @codeCoverageIgnoreStart
throw new RuntimeException('Unable to process PNG image.');
// @codeCoverageIgnoreEnd
}
$this->handle = $handle;
// Set transparency for non-transparent PNGs.
if (!$this->isTransparent())
{
// Assign to black which is default for transparent PNGs
$transparency = imagecolorallocatealpha($handle, 0, 0, 0, 127);
imagecolortransparent($handle, $transparency);
}
break;
default:
JLog::add('Attempting to load an image of unsupported type: ' . $properties->mime, JLog::ERROR);
throw new InvalidArgumentException('Attempting to load an image of unsupported type: ' . $properties->mime);
break;
}
// Set the filesystem path to the source image.
$this->path = $path;
}

+ Voici le graphe d'appel pour cette fonction :

JImage::prepareDimensions (   $width,
  $height,
  $scaleMethod 
)
protected

Method to get the new dimensions for a resized image.

Paramètres:
integer$widthThe width of the resized image in pixels.
integer$heightThe height of the resized image in pixels.
integer$scaleMethodThe method to use for scaling
Renvoie:
stdClass
Depuis:
11.3
Exceptions:
InvalidArgumentExceptionIf width, height or both given as zero

Définition à la ligne 907 du fichier image.php.

{
// Instantiate variables.
$dimensions = new stdClass;
switch ($scaleMethod)
{
case self::SCALE_FILL:
$dimensions->width = (int) round($width);
$dimensions->height = (int) round($height);
break;
case self::SCALE_INSIDE:
case self::SCALE_OUTSIDE:
case self::SCALE_FIT:
$rx = ($width > 0) ? ($this->getWidth() / $width) : 0;
$ry = ($height > 0) ? ($this->getHeight() / $height) : 0;
if ($scaleMethod != self::SCALE_OUTSIDE)
{
$ratio = max($rx, $ry);
}
else
{
$ratio = min($rx, $ry);
}
$dimensions->width = (int) round($this->getWidth() / $ratio);
$dimensions->height = (int) round($this->getHeight() / $ratio);
break;
default:
throw new InvalidArgumentException('Invalid scale method.');
break;
}
return $dimensions;
}
JImage::resize (   $width,
  $height,
  $createNew = true,
  $scaleMethod = self::SCALE_INSIDE 
)

Method to resize the current image.

Paramètres:
mixed$widthThe width of the resized image in pixels or a percentage.
mixed$heightThe height of the resized image in pixels or a percentage.
boolean$createNewIf true the current image will be cloned, resized and returned; else the current image will be resized and returned.
integer$scaleMethodWhich method to use for scaling
Renvoie:
JImage
Depuis:
11.3
Exceptions:
LogicException

Définition à la ligne 645 du fichier image.php.

{
// Make sure the resource handle is valid.
if (!$this->isLoaded())
{
throw new LogicException('No valid image was loaded.');
}
// Sanitize width.
$width = $this->sanitizeWidth($width, $height);
// Sanitize height.
$height = $this->sanitizeHeight($height, $width);
// Prepare the dimensions for the resize operation.
$dimensions = $this->prepareDimensions($width, $height, $scaleMethod);
// Instantiate offset.
$offset = new stdClass;
$offset->x = $offset->y = 0;
// Center image if needed and create the new truecolor image handle.
if ($scaleMethod == self::SCALE_FIT)
{
// Get the offsets
$offset->x = round(($width - $dimensions->width) / 2);
$offset->y = round(($height - $dimensions->height) / 2);
$handle = imagecreatetruecolor($width, $height);
// Make image transparent, otherwise cavas outside initial image would default to black
if (!$this->isTransparent())
{
$transparency = imagecolorAllocateAlpha($this->handle, 0, 0, 0, 127);
imagecolorTransparent($this->handle, $transparency);
}
}
else
{
$handle = imagecreatetruecolor($dimensions->width, $dimensions->height);
}
// Allow transparency for the new image handle.
imagealphablending($handle, false);
imagesavealpha($handle, true);
if ($this->isTransparent())
{
// Get the transparent color values for the current image.
$rgba = imageColorsForIndex($this->handle, imagecolortransparent($this->handle));
$color = imageColorAllocateAlpha($this->handle, $rgba['red'], $rgba['green'], $rgba['blue'], $rgba['alpha']);
// Set the transparent color values for the new image.
imagecolortransparent($handle, $color);
imagefill($handle, 0, 0, $color);
imagecopyresized($handle, $this->handle, $offset->x, $offset->y, 0, 0, $dimensions->width, $dimensions->height, $this->getWidth(), $this->getHeight());
}
else
{
imagecopyresampled($handle, $this->handle, $offset->x, $offset->y, 0, 0, $dimensions->width, $dimensions->height, $this->getWidth(), $this->getHeight());
}
// If we are resizing to a new image, create a new JImage object.
if ($createNew)
{
// @codeCoverageIgnoreStart
$new = new JImage($handle);
return $new;
// @codeCoverageIgnoreEnd
}
// Swap out the current handle for the new image handle.
else
{
// Free the memory from the current handle
$this->destroy();
$this->handle = $handle;
return $this;
}
}
JImage::rotate (   $angle,
  $background = -1,
  $createNew = true 
)

Method to rotate the current image.

Paramètres:
mixed$angleThe angle of rotation for the image
integer$backgroundThe background color to use when areas are added due to rotation
boolean$createNewIf true the current image will be cloned, rotated and returned; else the current image will be rotated and returned.
Renvoie:
JImage
Depuis:
11.3
Exceptions:
LogicException

Définition à la ligne 772 du fichier image.php.

{
// Make sure the resource handle is valid.
if (!$this->isLoaded())
{
throw new LogicException('No valid image was loaded.');
}
// Sanitize input
$angle = (float) $angle;
// Create the new truecolor image handle.
$handle = imagecreatetruecolor($this->getWidth(), $this->getHeight());
// Allow transparency for the new image handle.
imagealphablending($handle, false);
imagesavealpha($handle, true);
// Copy the image
imagecopy($handle, $this->handle, 0, 0, 0, 0, $this->getWidth(), $this->getHeight());
// Rotate the image
$handle = imagerotate($handle, $angle, $background);
// If we are resizing to a new image, create a new JImage object.
if ($createNew)
{
// @codeCoverageIgnoreStart
$new = new JImage($handle);
return $new;
// @codeCoverageIgnoreEnd
}
// Swap out the current handle for the new image handle.
else
{
// Free the memory from the current handle
$this->destroy();
$this->handle = $handle;
return $this;
}
}
JImage::sanitizeHeight (   $height,
  $width 
)
protected

Method to sanitize a height value.

Paramètres:
mixed$heightThe input height value to sanitize.
mixed$widthThe input width value for reference.
Renvoie:
integer
Depuis:
11.3

Définition à la ligne 956 du fichier image.php.

{
// If no height was given we will assume it is a square and use the width.
$height = ($height === null) ? $width : $height;
// If we were given a percentage, calculate the integer value.
if (preg_match('/^[0-9]+(\.[0-9]+)?\%$/', $height))
{
$height = (int) round($this->getHeight() * (float) str_replace('%', '', $height) / 100);
}
// Else do some rounding so we come out with a sane integer value.
else
{
$height = (int) round((float) $height);
}
return $height;
}
JImage::sanitizeOffset (   $offset)
protected

Method to sanitize an offset value like left or top.

Paramètres:
mixed$offsetAn offset value.
Renvoie:
integer
Depuis:
11.3

Définition à la ligne 984 du fichier image.php.

{
return (int) round((float) $offset);
}
JImage::sanitizeWidth (   $width,
  $height 
)
protected

Method to sanitize a width value.

Paramètres:
mixed$widthThe input width value to sanitize.
mixed$heightThe input height value for reference.
Renvoie:
integer
Depuis:
11.3

Définition à la ligne 999 du fichier image.php.

{
// If no width was given we will assume it is a square and use the height.
$width = ($width === null) ? $height : $width;
// If we were given a percentage, calculate the integer value.
if (preg_match('/^[0-9]+(\.[0-9]+)?\%$/', $width))
{
$width = (int) round($this->getWidth() * (float) str_replace('%', '', $width) / 100);
}
// Else do some rounding so we come out with a sane integer value.
else
{
$width = (int) round((float) $width);
}
return $width;
}
JImage::toFile (   $path,
  $type = IMAGETYPE_JPEG,
array  $options = array() 
)

Method to write the current image out to a file.

Paramètres:
string$pathThe filesystem path to save the image.
integer$typeThe image type to save the file as.
array$optionsThe image type options to use in saving the file.
Renvoie:
boolean
Voir également:
http://www.php.net/manual/image.constants.php
Depuis:
11.3
Exceptions:
LogicException

Définition à la ligne 831 du fichier image.php.

{
// Make sure the resource handle is valid.
if (!$this->isLoaded())
{
throw new LogicException('No valid image was loaded.');
}
switch ($type)
{
case IMAGETYPE_GIF:
return imagegif($this->handle, $path);
break;
case IMAGETYPE_PNG:
return imagepng($this->handle, $path, (array_key_exists('quality', $options)) ? $options['quality'] : 0);
break;
case IMAGETYPE_JPEG:
default:
return imagejpeg($this->handle, $path, (array_key_exists('quality', $options)) ? $options['quality'] : 100);
}
}

Documentation des données membres

JImage::$formats = array()
staticprotected

Définition à la ligne 73 du fichier image.php.

JImage::$handle
protected

Définition à la ligne 61 du fichier image.php.

JImage::$path = null
protected

Définition à la ligne 67 du fichier image.php.

const JImage::CROP = 4

integer

Depuis:
12.2

Définition à la ligne 43 du fichier image.php.

const JImage::CROP_RESIZE = 5

integer

Depuis:
12.3

Définition à la ligne 49 du fichier image.php.

const JImage::SCALE_FILL = 1

integer

Depuis:
11.3

Définition à la ligne 25 du fichier image.php.

const JImage::SCALE_FIT = 6

integer

Depuis:
3.2

Définition à la ligne 55 du fichier image.php.

const JImage::SCALE_INSIDE = 2

integer

Depuis:
11.3

Définition à la ligne 31 du fichier image.php.

const JImage::SCALE_OUTSIDE = 3

integer

Depuis:
11.3

Définition à la ligne 37 du fichier image.php.


La documentation de cette classe a été générée à partir du fichier suivant :