PHP Класс 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');
Устаревший: Deprecated since Contao 4.3, to be removed in Contao 5.0. Use the Imagine library instead.
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$gdResource resource The GD resource handle

Открытые методы

Метод Описание
__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

Описание методов

__construct() публичный Метод

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

__destruct() публичный Метод

Destroy the GD resource to free memory
public __destruct ( )

convertToPaletteImage() публичный Метод

Convert a true color image to a palette image with 256 colors and preserve transparency
public convertToPaletteImage ( ) : static
Результат static

copyTo() публичный Метод

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
Результат static

countColors() публичный Метод

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
Результат integer The number of image colors

fromDimensions() публичный статический Метод

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
Результат static The GD image object

fromFile() публичный статический Метод

Get the GD image object from an image file
public static fromFile ( contao\File $file ) : static
$file contao\File The file object
Результат static The GD image object

getResource() публичный Метод

Get the GD resource handle
public getResource ( ) : resource
Результат resource The GD resource handle

isSemitransparent() публичный Метод

Detect if the image contains semitransparent pixels
public isSemitransparent ( ) : boolean
Результат boolean True if the image contains semitransparent pixels

saveToFile() публичный Метод

Save the GD image to a file
public saveToFile ( string $path ) : static
$path string The image path
Результат static

setResource() публичный Метод

Set the GD resource handle
public setResource ( resource $gdResource ) : static
$gdResource resource The GD resource handle
Результат static

Описание свойств

$gdResource защищенное свойство

The GD resource handle
protected resource $gdResource
Результат resource