splitbrain/slika

Adapter
in package

AbstractYes

Base class for image adapters. Defines what image processing adapters need to provide

Table of Contents

Properties

$imagepath  : string
$options  : array<string|int, mixed>

Methods

__construct()  : mixed
New Slika Adapter
autorotate()  : Adapter
Rote the image based on the rotation exif tag
crop()  : Adapter
Resize to the given dimension, cropping the image as needed
resize()  : Adapter
Resize to make image fit the given dimension (maintaining the aspect ratio)
rotate()  : Adapter
Rotate and/or flip the image
save()  : void
Save the new file

Properties

$imagepath

protected string $imagepath

path to the image

$options

protected array<string|int, mixed> $options

Adapter Options

Methods

__construct()

New Slika Adapter

public __construct(string $imagepath[, array<string|int, mixed> $options = [] ]) : mixed
Parameters
$imagepath : string

path to the original image

$options : array<string|int, mixed> = []

set options

Tags
throws
Exception

autorotate()

Rote the image based on the rotation exif tag

public abstract autorotate() : Adapter
Return values
Adapter

crop()

Resize to the given dimension, cropping the image as needed

public abstract crop(int $width, int $height[, bool $upscale = true ]) : Adapter

You may omit one of the dimensions to use a square area

Parameters
$width : int

in pixels

$height : int

in pixels

$upscale : bool = true

when false, an image smaller than the target area is cropped but never enlarged

Return values
Adapter

resize()

Resize to make image fit the given dimension (maintaining the aspect ratio)

public abstract resize(int|string $width, int|string $height[, bool $upscale = true ]) : Adapter

You may omit one of the dimensions to auto calculate it based on the aspect ratio

Parameters
$width : int|string

in pixels or %

$height : int|string

in pixels or %

$upscale : bool = true

when false, an image smaller than the target is kept at its original size

Return values
Adapter

rotate()

Rotate and/or flip the image

public abstract rotate(int $orientation) : Adapter

This expects an orientation flag as stored in EXIF data. For typical operations, Slika::ROTATE_* constants are defined.

Parameters
$orientation : int

Exif rotation flags

Tags
see
https://stackoverflow.com/a/53697440

for info on the rotation constants

Return values
Adapter

save()

Save the new file

public abstract save(string $path[, string $extension = '' ]) : void
Parameters
$path : string
$extension : string = ''

The type of image to save, empty for original

On this page

Search results