trait DimensionsTrait (View source)

Trait for methods regarding the dimensions of an asset

Properties

protected int $width
protected int $height

Methods

int
getWidth()

Width of the image in pixels

int
getHeight()

Height of the image in pixels

bool
hasDimensions()

Does the asset have dimensions

float
getAspectRatio(bool $respectOrientation = false)

Edge / aspect ratio of the image

string
getOrientation()

Orientation of this image, i.e. portrait, landscape or square

bool
isOrientationSquare()

Whether this image is square aspect ratio and therefore has a square orientation

bool
isOrientationLandscape()

Whether this image is in landscape orientation

bool
isOrientationPortrait()

Whether this image is in portrait orientation

Details

int getWidth()

Width of the image in pixels

Return Value

int

int getHeight()

Height of the image in pixels

Return Value

int

bool hasDimensions()

Does the asset have dimensions

Return Value

bool

float getAspectRatio(bool $respectOrientation = false)

Edge / aspect ratio of the image

Parameters

bool $respectOrientation

If false (the default), orientation is disregarded and always a value >= 1 is returned (like usual in "4 / 3" or "16 / 9")

Return Value

float

string getOrientation()

Orientation of this image, i.e. portrait, landscape or square

Return Value

string

One of this interface's ORIENTATION_* constants.

bool isOrientationSquare()

Whether this image is square aspect ratio and therefore has a square orientation

Return Value

bool

bool isOrientationLandscape()

Whether this image is in landscape orientation

Return Value

bool

bool isOrientationPortrait()

Whether this image is in portrait orientation

Return Value

bool