class CropImageAdjustment extends AbstractImageAdjustment (View source)

An adjustment for cropping an image

Properties

protected int $position
protected ImageVariant $imageVariant from  AbstractImageAdjustment
protected int $x
protected int $y
protected int $width
protected int $height
protected string $aspectRatioAsString

Methods

__construct(array $options = [])

Constructs this adjustment

void
setImageVariant(ImageVariant $imageVariant)

Sets the image variant this adjustment belongs to

int
getPosition()

No description

setPosition(int $position)

No description

void
setHeight(int $height = null)

Sets height

int|null
getHeight()

Returns height

void
setWidth(int $width = null)

Sets width

int|null
getWidth()

Returns width

void
setX(int $x = null)

Sets x

int|null
getX()

Returns x

void
setY(int $y = null)

Sets y

int|null
getY()

Returns y

void
setAspectRatio($aspectRatio = null)

This setter accepts strings in order to make configuration / mapping of settings easier.

AspectRatio|null
getAspectRatio()

No description

static array
calculateDimensionsByAspectRatio(int $originalWidth, int $originalHeight, AspectRatio $desiredAspectRatio)

Calculates the actual position and dimensions of the cropping area based on the given image dimensions and desired aspect ratio.

bool
canBeApplied(ImageInterface $image)

Check if this Adjustment can or should be applied to its ImageVariant.

ImageInterface
applyToImage(ImageInterface $image)

Applies this adjustment to the given Imagine Image object

void
refit(ImageInterface $image)

Refits the crop proportions to be the maximum size within the image boundaries.

Details

__construct(array $options = [])

Constructs this adjustment

Parameters

array $options

configuration options - depends on the actual adjustment

Exceptions

InvalidArgumentException

void setImageVariant(ImageVariant $imageVariant)

Sets the image variant this adjustment belongs to

Parameters

ImageVariant $imageVariant

Return Value

void

int getPosition()

No description

Return Value

int

setPosition(int $position)

No description

Parameters

int $position

void setHeight(int $height = null)

Sets height

Parameters

int $height

Return Value

void

int|null getHeight()

Returns height

Return Value

int|null

void setWidth(int $width = null)

Sets width

Parameters

int $width

Return Value

void

int|null getWidth()

Returns width

Return Value

int|null

void setX(int $x = null)

Sets x

Parameters

int $x

Return Value

void

int|null getX()

Returns x

Return Value

int|null

void setY(int $y = null)

Sets y

Parameters

int $y

Return Value

void

int|null getY()

Returns y

Return Value

int|null

void setAspectRatio($aspectRatio = null)

This setter accepts strings in order to make configuration / mapping of settings easier.

Parameters

$aspectRatio

Return Value

void

AspectRatio|null getAspectRatio()

No description

Return Value

AspectRatio|null

static array calculateDimensionsByAspectRatio(int $originalWidth, int $originalHeight, AspectRatio $desiredAspectRatio)

Calculates the actual position and dimensions of the cropping area based on the given image dimensions and desired aspect ratio.

Parameters

int $originalWidth

Width of the original image

int $originalHeight

Height of the original image

AspectRatio $desiredAspectRatio

The desired aspect ratio

Return Value

array

Returns an array containing x, y, width and height

bool canBeApplied(ImageInterface $image)

Check if this Adjustment can or should be applied to its ImageVariant.

Parameters

ImageInterface $image

Return Value

bool

ImageInterface applyToImage(ImageInterface $image)

internal  Should never be used outside of the media package. Rely on the ImageService to apply your adjustments.
 

Applies this adjustment to the given Imagine Image object

Parameters

ImageInterface $image

Return Value

ImageInterface

void refit(ImageInterface $image)

Refits the crop proportions to be the maximum size within the image boundaries.

Parameters

ImageInterface $image

Return Value

void