PHP Class Contao\GdImage

The class handles GD images. Usage: $source = GdImage::fromFile($objFile); $target = GdImage::fromDimensions(100, 100); $source->copyTo($target, 0, 0, 100, 100); $target->convertToPaletteImage() ->saveToFile('image.jpg');
Deprecation: Deprecated since Contao 4.3, to be removed in Contao 5.0. Use the Imagine library instead.
Afficher le fichier Open project: contao/core-bundle Class Usage Examples

Protected Properties

Свойство Type Description
$gdResource resource The GD resource handle

Méthodes publiques

Méthode Description
__construct ( resource $gdResource ) Create a new object to handle a GD image
__destruct ( ) Destroy the GD resource to free memory
convertToPaletteImage ( ) : static Convert a true color image to a palette image with 256 colors and preserve transparency
copyTo ( self $gdImage, integer $x, integer $y, integer $width, integer $height ) : static Save the GD image to a file
countColors ( integer $max = null ) : integer Count the number of colors in the image
fromDimensions ( integer $width, integer $height ) : static Get the GD image object for the specified dimensions
fromFile ( contao\File $file ) : static Get the GD image object from an image file
getResource ( ) : resource Get the GD resource handle
isSemitransparent ( ) : boolean Detect if the image contains semitransparent pixels
saveToFile ( string $path ) : static Save the GD image to a file
setResource ( resource $gdResource ) : static Set the GD resource handle

Method Details

__construct() public méthode

Create a new object to handle a GD image
public __construct ( resource $gdResource )
$gdResource resource The GD resource handle

__destruct() public méthode

Destroy the GD resource to free memory
public __destruct ( )

convertToPaletteImage() public méthode

Convert a true color image to a palette image with 256 colors and preserve transparency
public convertToPaletteImage ( ) : static
Résultat static

copyTo() public méthode

Save the GD image to a file
public copyTo ( self $gdImage, integer $x, integer $y, integer $width, integer $height ) : static
$gdImage self The target GD image
$x integer The target X coordinate
$y integer The target Y coordinate
$width integer The target width
$height integer The target height
Résultat static

countColors() public méthode

Count the number of colors in the image
public countColors ( integer $max = null ) : integer
$max integer Stop parsing the image if more colors than $max were found
Résultat integer The number of image colors

fromDimensions() public static méthode

Get the GD image object for the specified dimensions
public static fromDimensions ( integer $width, integer $height ) : static
$width integer The image width
$height integer The image height
Résultat static The GD image object

fromFile() public static méthode

Get the GD image object from an image file
public static fromFile ( contao\File $file ) : static
$file contao\File The file object
Résultat static The GD image object

getResource() public méthode

Get the GD resource handle
public getResource ( ) : resource
Résultat resource The GD resource handle

isSemitransparent() public méthode

Detect if the image contains semitransparent pixels
public isSemitransparent ( ) : boolean
Résultat boolean True if the image contains semitransparent pixels

saveToFile() public méthode

Save the GD image to a file
public saveToFile ( string $path ) : static
$path string The image path
Résultat static

setResource() public méthode

Set the GD resource handle
public setResource ( resource $gdResource ) : static
$gdResource resource The GD resource handle
Résultat static

Property Details

$gdResource protected_oe property

The GD resource handle
protected resource $gdResource
Résultat resource