Adapter
in package
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
autorotate()
Rote the image based on the rotation exif tag
public
abstract autorotate() : Adapter
Return values
Adaptercrop()
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
Adapterresize()
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
Adapterrotate()
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
Return values
Adaptersave()
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