class ImageManager extends Manager

Traits

Properties

protected Repository $config

The configuration repository instance.

from  Manager
protected Closure> $customCreators

The registered custom driver creators.

from  Manager
protected array<array-key, mixed> $drivers

The array of created "drivers".

from  Manager
protected Transformation>, callable>> $transformationHandlers

The registered transformation handlers.

Methods

Closure|null
bindCallbackToSelf(Closure $callback)

Bind the provided callback to the class instance.

__construct(Container $container)

Create a new manager instance.

from  Manager
string|null
getDefaultDriver()

Get the default image driver name.

mixed
driver(UnitEnum|string|null $driver = null)

Get a driver instance.

from  Manager
mixed
createDriver(string $driver)

Create a new driver instance.

mixed
callCustomCreator(string $driver)

Call a custom driver creator.

from  Manager
extend(string $driver, Closure $callback)

Register a custom driver creator Closure.

from  Manager
array
getDrivers()

Get all of the created "drivers".

from  Manager
getContainer()

Get the container instance used by the manager.

from  Manager
setContainer(Container $container)

Set the container instance used by the manager.

from  Manager
forgetDrivers()

Forget all of the resolved driver instances.

from  Manager
mixed
__call(string $method, array $parameters)

Dynamically call the default driver instance.

from  Manager
fromBytes(string $contents)

Create an image instance from raw bytes.

fromStream(mixed $stream)

Create an image instance from a stream.

fromBase64(string $base64)

Create an image instance from a base64 encoded string.

fromPath(string $path)

Create an image instance from a file path.

fromStorage(string $path, UnitEnum|string|null $disk = null)

Create an image instance from a storage disk path.

fromUpload(UploadedFile $file)

Create an image instance from an uploaded file.

fromUrl(string $url)

Create an image instance from a URL.

createGdDriver()

Create the GD image driver.

createImagickDriver()

Create the Imagick image driver.

transformUsing(string $driver, string $transformation, callable $callback)

Register a transformation handler for the given driver.

void
applyTransformationHandlers(string $driver, Driver $instance)

Apply registered transformation handlers to the given driver instance.

Details

protected Closure|null bindCallbackToSelf(Closure $callback)

Bind the provided callback to the class instance.

Parameters

Closure $callback

Return Value

Closure|null

Exceptions

ReflectionException

in Manager at line 41
__construct(Container $container)

Create a new manager instance.

Parameters

Container $container

at line 185
string|null getDefaultDriver()

Get the default image driver name.

Return Value

string|null

in Manager at line 57
mixed driver(UnitEnum|string|null $driver = null)

Get a driver instance.

Parameters

UnitEnum|string|null $driver

Return Value

mixed

Exceptions

InvalidArgumentException

at line 115
protected mixed createDriver(string $driver)

Create a new driver instance.

Parameters

string $driver

Return Value

mixed

Exceptions

InvalidArgumentException

in Manager at line 110
protected mixed callCustomCreator(string $driver)

Call a custom driver creator.

Parameters

string $driver

Return Value

mixed

in Manager at line 126
Manager extend(string $driver, Closure $callback)

Register a custom driver creator Closure.

Anonymous closures run in this manager's class scope; non-static closures also receive the manager as $this.

Boot-only. The callback persists in the singleton's customCreators array for the worker lifetime and applies to every subsequent driver resolution.

Parameters

string $driver
Closure $callback

Return Value

Manager

in Manager at line 145
array getDrivers()

Get all of the created "drivers".

Return Value

array

in Manager at line 153
Container getContainer()

Get the container instance used by the manager.

Return Value

Container

in Manager at line 167
Manager setContainer(Container $container)

Set the container instance used by the manager.

Tests only. Swaps the singleton's container and configuration references; per-request use races across coroutines and breaks every concurrent driver resolution through this manager.

Parameters

Container $container

Return Value

Manager

in Manager at line 184
Manager forgetDrivers()

Forget all of the resolved driver instances.

Boot or tests only. Clears the singleton's driver cache; concurrent coroutines may already hold references that next resolution will not share.

Return Value

Manager

in Manager at line 194
mixed __call(string $method, array $parameters)

Dynamically call the default driver instance.

Parameters

string $method
array $parameters

Return Value

mixed

at line 32
Image fromBytes(string $contents)

Create an image instance from raw bytes.

Parameters

string $contents

Return Value

Image

at line 42
Image fromStream(mixed $stream)

Create an image instance from a stream.

Parameters

mixed $stream

Return Value

Image

at line 58
Image fromBase64(string $base64)

Create an image instance from a base64 encoded string.

Parameters

string $base64

Return Value

Image

at line 74
Image fromPath(string $path)

Create an image instance from a file path.

Parameters

string $path

Return Value

Image

at line 84
Image fromStorage(string $path, UnitEnum|string|null $disk = null)

Create an image instance from a storage disk path.

Parameters

string $path
UnitEnum|string|null $disk

Return Value

Image

at line 95
Image fromUpload(UploadedFile $file)

Create an image instance from an uploaded file.

Parameters

UploadedFile $file

Return Value

Image

at line 103
Image fromUrl(string $url)

Create an image instance from a URL.

Parameters

string $url

Return Value

Image

at line 138
protected GdDriver createGdDriver()

Create the GD image driver.

Return Value

GdDriver

at line 146
protected ImagickDriver createImagickDriver()

Create the Imagick image driver.

Return Value

ImagickDriver

at line 158
ImageManager transformUsing(string $driver, string $transformation, callable $callback)

Register a transformation handler for the given driver.

Boot-only. The handler persists on a cached driver for the worker lifetime and affects every subsequent image processed by that driver.

Parameters

string $driver
string $transformation
callable $callback

Return Value

ImageManager

at line 175
protected void applyTransformationHandlers(string $driver, Driver $instance)

Apply registered transformation handlers to the given driver instance.

Parameters

string $driver
Driver $instance

Return Value

void