# Models

# CraftTransformedImageModel

The model returned by the craft.imager.transformImage method.

# Public attributes

url: URL to the image.
path: System path to the image file.
extension: File extension.
mimeType: File mime type.
width: Width of the image.
height: Height of the image.
size: Size of the image in bytes.

# Public methods

getUrl() [string]
URL to the image.

getPath() [string]
System path to the image file.

getExtension() [string]
File extension.

getMimeType() [string]
File mime type.

getWidth() [string]
Width of the image.

getHeight() [string]
Height of the image.

getSize($unit='b', $precision='2') [float]
Size of the image. Example:

{{ image.getSize() }} B 
{{ image.getSize('k') }} KB 
{{ image.getSize('m', 10) }} MB 
{{ image.getSize('g', 10) }} GB

getDataUri() [string]
Returns a data uri with the image base64 encoded as a string.

getBase64Encoded() [string]
Returns a string of the base64 encoded image data.


# ImgixTransformedImageModel

The model returned by the craft.imager.transformImage method if Imgix is enabled. This model has the same signature as the CraftTransformedImageModel for compabilities sake, but does return empty strings for some of its attributes that are not applicable, or not possible to determine.

In addition it adds getPalette() which can be used to interface with Imgix' color palette functionality.

# Public attributes

url: URL to the image.
path: Returns an empty string.
extension: Returns an empty string.
mimeType: Returns an empty string.
width: Width of the image.
height: Height of the image.
size: Returns an empty string.

# Public methods

getUrl() [string]
URL to the image.

getPath() [string]
Returns an empty string.

getExtension() [string]
Returns an empty string.

getMimeType() [string]
Returns an empty string.

getWidth() [string]
Width of the image.

getHeight() [string]
Height of the image.

getSize($unit='b', $precision='2') [float]
Returns an empty string.

getDataUri() [string]
Returns an empty string.

getBase64Encoded() [string]
Returns an empty string.

getPalette($format='json', $colors=6, $cssPrefix='') [string|object]
This method is a wrapper for Imgix' color palette functionality. It returns either an object, if the format requested was 'json', and a string if the format was 'css'. Refer to the Imgix documentation to see what data is returned.

Note: The data fetched from Imgix is cached in Craft's data cache for the default cache duration, to avoid extrenous calls to Imgix.