Documentation

Core_Image_Gd extends Core_Image
in package

Image helper

Tags
subpackage

Core

version
7.x
author

Hostmake LLC

copyright

© 2005-2024 ООО "Хостмэйк" (Hostmake LLC), http://www.hostcms.ru

Table of Contents

Properties

$instance  : mixed
The singleton instances.
$_config  : mixed
Driver's configuration

Methods

addWatermark()  : bool
Добавление watermark на изображение. Если файл watermark не существует, метод скопирует исходное изображение
avatar()  : mixed
Create avatar
exifImagetype()  : mixed
Implement exifImagetype function
getImageSize()  : mixed
Get image size
getImageType()  : mixed
Get Image Type: 0 = UNKNOWN, 1 = GIF, 2 = JPG, 3 = PNG, 4 = SWF, 5 = PSD, 6 = BMP, 7 = TIFF (orden de bytes intel), 8 = TIFF (orden de bytes motorola), 9 = JPC, 10 = JP2, 11 = JPX, 12 = JB2, 13 = SWC, 14 = IFF, 15 = WBMP, 16 = XBM, 17 = ICO, 18 = WEBP, 19 = AVIF, 20 = COUNT
getImagetypeByFormat()  : int|null
Get IMAGETYPE_xxx by $outputFormat
getVersion()  : string
Get GD version
imagepalettetotruecolor()  : bool
Function imagepalettetotruecolor() (PHP 5 >= 5.5.0, PHP 7, PHP 8)
instance()  : object
Register an existing instance as a singleton.
isAvailable()  : bool
Check GD-Module Availability
resizeImage()  : bool
Пропорциональное масштабирование изображения
setTransparency()  : mixed
Установка прозрачности для $image_target, равной прозрачности $image_source
_addWatermark()  : GdImage
Добавление водяного знака
_getDriverName()  : srting
Get full driver name

Properties

$instance

The singleton instances.

public static mixed $instance = array()

$_config

Driver's configuration

protected static mixed $_config = \NULL

Methods

addWatermark()

Добавление watermark на изображение. Если файл watermark не существует, метод скопирует исходное изображение

public addWatermark(string $source, string $target, string $watermark[, string $watermarkX = NULL ][, string $watermarkY = NULL ][, string|null $outputFormat = NULL ]) : bool
Parameters
$source : string

путь к файлу источнику

$target : string

путь к файлу получателю

$watermark : string

путь к файлу watermark в формате PNG

$watermarkX : string = NULL

позиция по оси X (в пикселях или процентах)

$watermarkY : string = NULL

позиция по оси Y (в пикселях или процентах)

$outputFormat : string|null = NULL

формат, в котором сохранять изображение, по умолчанию NULL равен формату исходного

addWatermark($source, $target, $watermark); ?>
Return values
bool

avatar()

Create avatar

public static avatar(string $initials[, string $bgColor = '#f44336' ][, int $width = 130 ][, int $height = 130 ]) : mixed
Parameters
$initials : string
$bgColor : string = '#f44336'
$width : int = 130
$height : int = 130

exifImagetype()

Implement exifImagetype function

public static exifImagetype(string $path) : mixed
Parameters
$path : string

getImageSize()

Get image size

public getImageSize(string $path) : mixed
Parameters
$path : string

path

getImageType()

Get Image Type: 0 = UNKNOWN, 1 = GIF, 2 = JPG, 3 = PNG, 4 = SWF, 5 = PSD, 6 = BMP, 7 = TIFF (orden de bytes intel), 8 = TIFF (orden de bytes motorola), 9 = JPC, 10 = JP2, 11 = JPX, 12 = JB2, 13 = SWC, 14 = IFF, 15 = WBMP, 16 = XBM, 17 = ICO, 18 = WEBP, 19 = AVIF, 20 = COUNT

public getImageType(string $path) : mixed
Parameters
$path : string

getImagetypeByFormat()

Get IMAGETYPE_xxx by $outputFormat

public static getImagetypeByFormat(string $outputFormat) : int|null
Parameters
$outputFormat : string

Output Format, e.g. 'webp'

Return values
int|null

getVersion()

Get GD version

public getVersion() : string
Return values
string

imagepalettetotruecolor()

Function imagepalettetotruecolor() (PHP 5 >= 5.5.0, PHP 7, PHP 8)

public imagepalettetotruecolor(GdImage &$src) : bool
Parameters
$src : GdImage
Return values
bool

instance()

Register an existing instance as a singleton.

public static instance([string $name = 'default' ]) : object
Parameters
$name : string = 'default'

driver's name

Return values
object

isAvailable()

Check GD-Module Availability

public isAvailable() : bool
Return values
bool

resizeImage()

Пропорциональное масштабирование изображения

public resizeImage(string $sourceFile, int $maxWidth, int $maxHeight, string $targetFile[, int $quality = NULL ][, int $preserveAspectRatio = TRUE ][, string|null $outputFormat = NULL ]) : bool
Parameters
$sourceFile : string

путь к исходному файлу

$maxWidth : int

максимальная ширина картинки

$maxHeight : int

максимальная высота картинки

$targetFile : string

путь к результирующему файлу

$quality : int = NULL

качество JPEG/PNG файла, если не передано, то берется из констант

$preserveAspectRatio : int = TRUE

сохранять пропорции изображения

$outputFormat : string|null = NULL

формат, в котором сохранять изображение, по умолчанию NULL равен формату исходного

resizeImage($sourceFile, 100, 50, $targetFile); ?>
Return values
bool

setTransparency()

Установка прозрачности для $image_target, равной прозрачности $image_source

public setTransparency( $image_target,  $image_source) : mixed
Parameters
$image_target :

Ресурс изображения получателя

$image_source :

Ресурс изображения источника

_addWatermark()

Добавление водяного знака

protected _addWatermark(GdImage $sourceResource, GdImage $watermarkResource[, int $watermarkX = NULL ][, int $watermarkY = NULL ]) : GdImage
Parameters
$sourceResource : GdImage

исходное изображение

$watermarkResource : GdImage

водяной знак

$watermarkX : int = NULL

позиция по оси X

$watermarkY : int = NULL

позиция по оси Y

Return values
GdImage

_getDriverName()

Get full driver name

protected static _getDriverName(string $driver) : srting
Parameters
$driver : string

driver name

Return values
srting

        
On this page

Search results