PHP Класс Craft\ImagerService

Наследование: extends craft\BaseApplicationComponent
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$compositeKeyTranslate translate dictionary for composite modes. set in constructor if driver is imagick.
$configModel
$craftPositonTranslate translate dictionary for translating crafts built in position constants into relative format (width/height offset)
$ditherKeyTranslate translate dictionary for dither method
$filterKeyTranslate translate dictionary for resize method
$imageDriver
$imageInstance
$imagineInstance
$interlaceKeyTranslate translate dictionary for interlace method
$invalidatePaths
$taskCreated
$transformKeyTranslate translate dictionary for translating transform keys into filename markers

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

Метод Описание
__construct ( ) Constructor
deleteImageTransformCaches ( ) Clear all image transforms caches
deleteRemoteImageCaches ( ) Clear all remote image caches
executeOptimize ( $command, $file = '' ) Executes a shell command
fixSlashes ( $str, boolean | false $removeInitial = false, boolean | false $removeTrailing = false ) : mixed | string Fixes slashes in path
getCropSize ( Imagine\Image\Box $originalSize, $transform ) : Imagine\Image\Box Creates the destination crop size box
getResizeSize ( Imagine\Image\Box $originalSize, $transform ) : Imagine\Image\Box Creates the resize size box
getSetting ( $name, $transform = null ) : mixed Gets a plugin setting
hasSupportForWebP ( ) : boolean Checks for webp support in image driver
makeTask ( string $taskName, array $paths ) Registers a Task with Craft, taking into account if there is already one pending
postOptimize ( $type, $file ) Set up optimization
removeTransformsForAsset ( craft\AssetFileModel $asset ) Remove transforms for a given asset
runJpegoptim ( $file ) Run jpegoptim optimization
runJpegtran ( $file ) Run jpegtran optimization
runMozjpeg ( $file ) Run mozjpeg optimization
runOptipng ( $file ) Run optipng optimization
runTinyPng ( $file ) Runs TinyPNG optimization
transformImage ( craft\AssetFileModel | string $image, Array $transform, Array $transformDefaults, Array $configOverrides ) : craft\Image Do an image transform

Приватные методы

Метод Описание
_applyBackgroundColor ( Imagine\Image\ImageInterface &$imageInstance, $bgColor ) Apply background color to image when converting from transparent to non-transparent
_applyCustomFilter ( $imagick, $filterName ) Applies a custom predefined filter to image
_applyImageEffects ( $imageInstance, $effects ) Apply effects array to image instance
_applyLetterbox ( Imagine\Image\ImageInterface &$imageInstance, $transform ) Apply letterbox to image
_applyWatermark ( $imageInstance, $watermark ) Apply watermark to image
_colorBlend ( $imagickInstance, $color, integer $alpha = 1, integer $composite_flag = Imagick::COMPOSITE_COLORIZE ) Color blend filter, more advanced version of colorize.
_createImagineInstance ( ) Creates the Imagine instance depending on the image driver
_createTargetFilename ( string $filename, string $extension, $transform ) : string Creates the target filename
_createTransformFilestring ( $transform ) : string Creates additional file string that is appended to filename
_enforceMaxSize ( $width, $height, $originalSize, $maintainAspect, $zoomFactor = 1 ) : array Enforces a max size if allowUpscale is false
_getCropPoint ( Imagine\Image\Box $resizeSize, Imagine\Image\Box $cropSize, $transform ) : Imagine\Image\Point Gets crop point
_getCropZoomFactor ( $transform ) : float | integer Get the crop zoom factor
_getFilterMethod ( $transform ) : string Returns the filter method for resize operations
_getSaveOptions ( $extension, $transform ) : array Get the save options based on extension and transform
_getTransformedImage ( Imager_ImagePathsModel $paths, Array $transform ) : Imager_ImageModel Loads an image from a file system path, do transform, return transformed image as an Imager_ImageModel
_moveArrayKeyToPos ( $key, $pos, $arr ) : array Moves a named key in an associative array to a given position
_normalizeTransform ( $transform, $paths = null ) : mixed Normalize transform object and values
_saveAsWebp ( $imageInstance, $path, $sourceExtension, $saveOptions ) Saves image as webp
_saveTemporaryFile ( $imageInstance, $sourceExtension ) : string Save temporary file and return filename
_triggerTasksNow ( ) Method that triggers any pending tasks immediately.
_vignette ( $imagickInstance, string $color1 = 'none', string $color2 = 'black', float $crop_factor = 1.5 ) Create a vignette

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

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

Constructor
public __construct ( )

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

Clear all image transforms caches

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

Clear all remote image caches

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

Executes a shell command
public executeOptimize ( $command, $file = '' )
$command

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

Fixes slashes in path
static public fixSlashes ( $str, boolean | false $removeInitial = false, boolean | false $removeTrailing = false ) : mixed | string
$str
$removeInitial boolean | false
$removeTrailing boolean | false
Результат mixed | string

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

Creates the destination crop size box
public getCropSize ( Imagine\Image\Box $originalSize, $transform ) : Imagine\Image\Box
$originalSize Imagine\Image\Box
$transform
Результат Imagine\Image\Box

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

Creates the resize size box
public getResizeSize ( Imagine\Image\Box $originalSize, $transform ) : Imagine\Image\Box
$originalSize Imagine\Image\Box
$transform
Результат Imagine\Image\Box

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

Gets a plugin setting
Автор: André Elvan
public getSetting ( $name, $transform = null ) : mixed
$name String Setting name
Результат mixed Setting value

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

Checks for webp support in image driver
public hasSupportForWebP ( ) : boolean
Результат boolean

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

Registers a Task with Craft, taking into account if there is already one pending
public makeTask ( string $taskName, array $paths )
$taskName string The name of the Task you want to register
$paths array An array of paths that should go in that Tasks settings

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

Set up optimization
public postOptimize ( $type, $file )
$type
$file

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

Remove transforms for a given asset
public removeTransformsForAsset ( craft\AssetFileModel $asset )
$asset craft\AssetFileModel

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

Run jpegoptim optimization
public runJpegoptim ( $file )
$file

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

Run jpegtran optimization
public runJpegtran ( $file )
$file

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

Run mozjpeg optimization
public runMozjpeg ( $file )
$file

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

Run optipng optimization
public runOptipng ( $file )
$file

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

Runs TinyPNG optimization
public runTinyPng ( $file )
$file

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

Do an image transform
public transformImage ( craft\AssetFileModel | string $image, Array $transform, Array $transformDefaults, Array $configOverrides ) : craft\Image
$image craft\AssetFileModel | string
$transform Array
$transformDefaults Array
$configOverrides Array
Результат craft\Image

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

$compositeKeyTranslate публичное статическое свойство

translate dictionary for composite modes. set in constructor if driver is imagick.
public static $compositeKeyTranslate

$configModel публичное свойство

public $configModel

$craftPositonTranslate публичное статическое свойство

translate dictionary for translating crafts built in position constants into relative format (width/height offset)
public static $craftPositonTranslate

$ditherKeyTranslate публичное статическое свойство

translate dictionary for dither method
public static $ditherKeyTranslate

$filterKeyTranslate публичное статическое свойство

translate dictionary for resize method
public static $filterKeyTranslate

$imageDriver публичное свойство

public $imageDriver

$imageInstance публичное свойство

public $imageInstance

$imagineInstance публичное свойство

public $imagineInstance

$interlaceKeyTranslate публичное статическое свойство

translate dictionary for interlace method
public static $interlaceKeyTranslate

$invalidatePaths публичное свойство

public $invalidatePaths

$taskCreated публичное свойство

public $taskCreated

$transformKeyTranslate публичное статическое свойство

translate dictionary for translating transform keys into filename markers
public static $transformKeyTranslate