PHP 클래스 Craft\ImagerService

상속: extends craft\BaseApplicationComponent
파일 보기 프로젝트 열기: aelvan/Imager-Craft 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$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