ImagesService

Type
Class
Namespace
Craft
Inherits
Craft\ImagesService » Craft\BaseApplicationComponent » CApplicationComponent » CComponent
Implements
IApplicationComponent
Since
1.0

Service for image operations.

See also http://craftcms.com

View source

Public Properties

PropertyDescription
$behaviorsarray – The behaviors that should be attached to this component.

Public Methods

MethodDescription
__call()Calls the named method which is not a class method.
__get()Returns a property value, an event handler list or a behavior based on its name.
__isset()Checks if a property value is null.
__set()Sets value of a component property.
__unset()Sets a component property to be null.
asa()Returns the named behavior object.
attachBehavior()Attaches a behavior to this component.
attachBehaviors()Attaches a list of behaviors to the component.
attachEventHandler()Attaches an event handler to an event.
canGetProperty()Determines whether a property can be read.
canSetProperty()Determines whether a property can be set.
checkMemoryForImage()Determines if there is enough memory to process this image.
cleanImage()Cleans an image by it's path, clearing embedded potentially malicious embedded code.
detachBehavior()Detaches a behavior from the component.
detachBehaviors()Detaches all behaviors from the component.
detachEventHandler()Detaches an existing event handler.
disableBehavior()Disables an attached behavior.
disableBehaviors()Disables all behaviors attached to this component.
enableBehavior()Enables an attached behavior.
enableBehaviors()Enables all behaviors attached to this component.
evaluateExpression()Evaluates a PHP expression or callback under the context of this component.
getEventHandlers()Returns the list of attached event handlers for an event.
getExifData()Get EXIF metadata for a file by it's path.
getIsInitialized()Checks if this application component has been initialized.
hasEvent()Determines whether an event is defined.
hasEventHandler()Checks whether the named event has attached handlers.
hasProperty()Determines whether a property is defined.
init()Initializes the application component.
isGd()Returns whether image manipulations will be performed using GD or not.
isImagick()Returns whether image manipulations will be performed using Imagick or not.
isInitialized()Checks if this application component has been initialized yet, or not.
loadImage()Loads an image from a file system path.
raiseEvent()Raises an event.
rotateImageByExifData()Rotate image according to it's EXIF data.
stripOrientationFromExifData()Strip orientation from EXIF data for an image at a path.

checkMemoryForImage()

Determines if there is enough memory to process this image. The code was adapted from http://www.php.net/manual/en/function.imagecreatefromjpeg.php#64155. It will first attempt to do it with available memory. If that fails, Craft will bump the memory to amount defined by the phpMaxMemoryLimit config setting, then try again.

View source

Arguments

  • $filePath (string) – The path to the image file.
  • $toTheMax (boolean) – If set to true, will set the PHP memory to the config setting phpMaxMemoryLimit.

Returns

boolean

Signature

public boolean checkMemoryForImage ( $filePath, $toTheMax = false )

cleanImage()

Cleans an image by it's path, clearing embedded potentially malicious embedded code.

View source

Arguments

Returns

boolean

Throws

Signature

public boolean cleanImage ( $filePath )

getExifData()

Get EXIF metadata for a file by it's path.

View source

Arguments

  • $filePath

Returns

array

Signature

public array getExifData ( $filePath )

isGd()

Returns whether image manipulations will be performed using GD or not.

View source

Returns

boolean, null

Signature

public boolean, null isGd ( )

isImagick()

Returns whether image manipulations will be performed using Imagick or not.

View source

Returns

boolean

Signature

public boolean isImagick ( )

loadImage()

Loads an image from a file system path.

View source

Arguments

  • $path (string)
  • $rasterize (boolean) – Whether or not the image will be rasterized if it's an SVG
  • $svgSize (integer) – The size SVG should be scaled up to, if rasterized

Returns

Craft\BaseImage

Throws

Signature

public Craft\BaseImage loadImage ( $path, $rasterize = false, $svgSize = 1000 )

rotateImageByExifData()

Rotate image according to it's EXIF data.

View source

Arguments

Returns

boolean

Signature

public boolean rotateImageByExifData ( $filePath )

stripOrientationFromExifData()

Strip orientation from EXIF data for an image at a path.

View source

Arguments

  • $filePath

Returns

boolean

Signature

public boolean stripOrientationFromExifData ( $filePath )