Joomla CMS  4.2.2
Documentation des API du CMS Joomla en version 4.2.2
Référence de la classe Image

Fonctions membres publiques

 __construct ($source=null)
 
 getHandle ()
 
 getOrientation ()
 
 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=[])
 
 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)
 
 flip ($mode, $createNew=true)
 
 watermark (Image $watermark, $transparency=50, $bottomMargin=0, $rightMargin=0)
 
 toFile ($path, $type=IMAGETYPE_JPEG, array $options=[])
 
 destroy ()
 
 __destruct ()
 
 setThumbnailGenerate ($quality=true)
 

Fonctions membres publiques statiques

static getImageFileProperties ($path)
 

Champs de données

const SCALE_FILL = 1
 
const SCALE_INSIDE = 2
 
const SCALE_OUTSIDE = 3
 
const CROP = 4
 
const CROP_RESIZE = 5
 
const SCALE_FIT = 6
 
const ORIENTATION_LANDSCAPE = 'landscape'
 
const ORIENTATION_PORTRAIT = 'portrait'
 
const ORIENTATION_SQUARE = 'square'
 

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
 
 $generateBestQuality = true
 

Attributs protégés statiques

static $formats = []
 

Fonctions membres privées statiques

static getOrientationString (int $width, int $height)
 

Description détaillée

Class to manipulate an image.

Depuis
1.7.3

Documentation des constructeurs et destructeur

◆ __construct()

__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
1.7.3
Exceptions

If the source input is a resource, set it as the image handle.

Références $info, et elseif.

◆ __destruct()

__destruct ( )

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

Voir également
Image::destroy()
Depuis
2.5.0

Documentation des fonctions membres

◆ createThumbs()

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 cropping the original image.

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

◆ crop()

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
Image
Depuis
2.5.0
Exceptions

Références $color, $height, $this, et $width.

◆ cropResize()

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.
boolean$createNewIf true the current image will be cloned, resized, cropped and returned.
Renvoie
Image
Depuis
2.5.0

Références $height, $width, et null.

◆ destroy()

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
2.5.0

◆ filter()

filter (   $type,
array  $options = [] 
)

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
Image
Depuis
2.5.0
Voir également
Exceptions

Références $options, $this, et $type.

◆ flip()

flip (   $mode,
  $createNew = true 
)

Method to flip the current image.

Paramètres
integer$modeThe flip mode for flipping the image http://php.net/imageflip#refsect1-function.imageflip-parameters
boolean$createNewIf true the current image will be cloned, flipped and returned; else the current image will be flipped and returned.
Renvoie
Image
Depuis
3.4.2
Exceptions

Références $mode, et $this.

◆ generateThumbs()

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 cropping | 5 resize then crop
Renvoie
array
Depuis
2.5.0
Exceptions

Références $size, et null.

◆ getFilterInstance()

getFilterInstance (   $type)
protected

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

Paramètres
string$typeThe image filter type to get.
Renvoie
ImageFilter
Depuis
2.5.0
Exceptions

Références $className, et $type.

◆ getHandle()

getHandle ( )

Get the image resource handle

Renvoie
resource
Depuis
3.8.0
Exceptions

Référencé par Image\watermark().

◆ getHeight()

getHeight ( )

Method to get the height of the image in pixels.

Renvoie
integer
Depuis
2.5.0
Exceptions

Référencé par Image\watermark().

◆ getImageFileProperties()

static 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
Depuis
2.5.0
Exceptions

Références $info, $path, et null.

Référencé par Checkfiles\checkImages(), et LocalAdapter\getPathInformation().

◆ getOrientation()

getOrientation ( )

Method to detect whether an image's orientation is landscape, portrait or square.

The orientation will be returned as a string.

Renvoie
mixed Orientation string or null.
Depuis
3.4.2

Références null.

◆ getOrientationString()

static getOrientationString ( int  $width,
int  $height 
)
staticprivate

Compare width and height integers to determine image orientation.

Paramètres
integer$widthThe width value to use for calculation
integer$heightThe height value to use for calculation
Renvoie
string Orientation string
Depuis
3.4.2

Références $height, et $width.

◆ getPath()

getPath ( )

Method to return the path

Renvoie
string
Depuis
2.5.0

Références $path.

◆ getWidth()

getWidth ( )

Method to get the width of the image in pixels.

Renvoie
integer
Depuis
2.5.0
Exceptions

Référencé par Image\watermark().

◆ isLoaded()

isLoaded ( )

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

Renvoie
boolean
Depuis
2.5.0

Make sure the resource handle is valid.

◆ isTransparent()

isTransparent ( )

Method to determine whether or not the image has transparency.

Renvoie
boolean
Depuis
2.5.0
Exceptions

◆ loadFile()

loadFile (   $path)

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

Paramètres
string$pathThe filesystem path to load as an image.
Renvoie
void
Depuis
2.5.0
Exceptions

Check if handle has been created successfully

Références $path, $type, et path.

◆ prepareDimensions()

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
Depuis
2.5.0
Exceptions

Références $height, et $width.

◆ resize()

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
Image
Depuis
2.5.0
Exceptions

Références $color, $height, Joomla\Database\Query\$offset, $this, et $width.

◆ rotate()

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
Image
Depuis
2.5.0
Exceptions

Références $this.

◆ sanitizeHeight()

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
2.5.0

Références $height, $width, et null.

◆ sanitizeOffset()

sanitizeOffset (   $offset)
protected

Method to sanitize an offset value like left or top.

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

Références Joomla\Database\Query\$offset.

◆ sanitizeWidth()

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
2.5.0

Références $height, $width, et null.

◆ setThumbnailGenerate()

setThumbnailGenerate (   $quality = true)

Method for set option of generate thumbnail method

Paramètres
boolean$qualityTrue for best quality. False for best speed.
Renvoie
void
Depuis
3.7.0

◆ toFile()

toFile (   $path,
  $type = IMAGETYPE_JPEG,
array  $options = [] 
)

Method to write the current image out to a file or output directly.

Paramètres
mixed$pathThe filesystem path to save the image. When null, the raw image stream will be outputted directly.
integer$typeThe image type to save the file as.
array$optionsThe 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)
Renvoie
boolean

2.5.0

Références $options, $path, et $type.

◆ watermark()

watermark ( Image  $watermark,
  $transparency = 50,
  $bottomMargin = 0,
  $rightMargin = 0 
)

Watermark the image

Paramètres
Image$watermarkThe Image object containing the watermark graphic
integer$transparencyThe transparency to use for the watermark graphic
integer$bottomMarginThe margin from the bottom of this image
integer$rightMarginThe margin from the right side of this image
Renvoie
Image
Depuis
3.8.0 https://secure.php.net/manual/en/image.examples-watermark.php

Références $this, Image\getHandle(), Image\getHeight(), et Image\getWidth().

Documentation des champs

◆ $formats

$formats = []
staticprotected

◆ $generateBestQuality

$generateBestQuality = true
protected

◆ $handle

$handle
protected

◆ $path

$path = null
protected

◆ CROP

const CROP = 4

integer

Depuis
2.5.0

◆ CROP_RESIZE

const CROP_RESIZE = 5

integer

Depuis
2.5.0

◆ ORIENTATION_LANDSCAPE

const ORIENTATION_LANDSCAPE = 'landscape'

string

Depuis
3.4.2

◆ ORIENTATION_PORTRAIT

const ORIENTATION_PORTRAIT = 'portrait'

string

Depuis
3.4.2

◆ ORIENTATION_SQUARE

const ORIENTATION_SQUARE = 'square'

string

Depuis
3.4.2

◆ SCALE_FILL

const SCALE_FILL = 1

integer

Depuis
2.5.0

Référencé par TemplateModel\resizeImage().

◆ SCALE_FIT

const SCALE_FIT = 6

integer

Depuis
2.5.0

◆ SCALE_INSIDE

const SCALE_INSIDE = 2

integer

Depuis
2.5.0

◆ SCALE_OUTSIDE

const SCALE_OUTSIDE = 3

integer

Depuis
2.5.0

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