PHP Класс Elgg\ImageService

С версии: 2.3
Показать файл Открыть проект

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

Метод Описание
__construct ( Imagine\Image\ImagineInterface $imagine, Config $config ) Constructor
normalizeResizeParameters ( integer $width, integer $height, array $params = [] ) : array Calculate the parameters for resizing an image
resize ( string $source, string $destination = null, array $params = [] ) : boolean Crop and resize an image

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

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

Constructor
public __construct ( Imagine\Image\ImagineInterface $imagine, Config $config )
$imagine Imagine\Image\ImagineInterface Imagine interface
$config Config Elgg config

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

Calculate the parameters for resizing an image
public normalizeResizeParameters ( integer $width, integer $height, array $params = [] ) : array
$width integer Natural width of the image
$height integer Natural height of the image
$params array Resize parameters - 'w' maximum width of the resized image - 'h' maximum height of the resized image - 'upscale' allow upscaling - 'square' constrain to a square - 'x1', 'y1', 'x2', 'y2' cropping coordinates
Результат array

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

Crop and resize an image
public resize ( string $source, string $destination = null, array $params = [] ) : boolean
$source string Path to source image
$destination string Path to destination If not set, will modify the source image
$params array An array of cropping/resizing parameters - INT 'w' represents the width of the new image With upscaling disabled, this is the maximum width of the new image (in case the source image is smaller than the expected width) - INT 'h' represents the height of the new image With upscaling disabled, this is the maximum height - INT 'x1', 'y1', 'x2', 'y2' represent optional cropping coordinates. The source image will first be cropped to these coordinates, and then resized to match width/height parameters - BOOL 'square' - square images will fill the bounding box (width x height). In Imagine's terms, this equates to OUTBOUND mode - BOOL 'upscale' - if enabled, smaller images will be upscaled to fit the bounding box.
Результат boolean