Image
class Image implements Stringable (View source)
Traits
Properties
| static protected array | $macros | The registered string macros. |
from Macroable |
| protected | $pipeline | The image processing pipeline. |
|
| protected | $driver | The driver override. |
|
| protected | $processed | Whether the image has been processed. |
|
| protected | $hashName | The cached hash name. |
Methods
Apply the callback if the given "value" is (or resolves to) truthy.
Apply the callback if the given "value" is (or resolves to) falsy.
Mix another object into the class.
Dynamically handle calls to the class.
Dynamically handle calls to the class.
Create a new image instance.
Crop the image to the given dimensions and position.
Resize the image to the given dimensions.
Rotate the image clockwise by the given angle.
Flip the image vertically.
Flip the image horizontally.
Set the optimization options.
Store the processed image on a filesystem disk.
Store the processed image on a filesystem disk with public visibility.
Store the processed image on a filesystem disk with a given name.
Store the processed image on a filesystem disk with public visibility and a given name.
Get a hashed filename with the correct extension.
Process the image and return the raw bytes.
Process the image and return as a base64 encoded string.
Process the image and return as a data URI.
Get the file extension based on the MIME type.
Get the MIME type of the processed image.
Get the dimensions of the processed image.
Get the width of the processed image.
Get the height of the processed image.
Use the Imagick driver for processing.
Resolve the image processing driver.
Get the underlying uploaded file instance.
Prevent serialization of the image.
Get the string representation of the image.
Get the string representation of the image.
Details
$this|TWhenReturnType
when($value = null, callable|null $callback = null, callable|null $default = null)
Apply the callback if the given "value" is (or resolves to) truthy.
$this|TUnlessReturnType
unless($value = null, callable|null $callback = null, callable|null $default = null)
Apply the callback if the given "value" is (or resolves to) falsy.
static void
macro(string $name, object|callable $macro)
Register a custom macro.
static void
mixin(object $mixin, bool $replace = true)
Mix another object into the class.
static bool
hasMacro(string $name)
Checks if macro is registered.
static void
flushMacros()
Flush the existing macros.
static mixed
__callStatic(string $method, array $parameters)
Dynamically handle calls to the class.
mixed
__call(string $method, array $parameters)
Dynamically handle calls to the class.
__construct(Closure|string $contents, UploadedFile|null $file = null)
Create a new image instance.
Image
cover(int $width, int $height)
Set the cover dimensions.
Image
contain(int $width, int $height, string|null $background = null)
Set the contain dimensions.
Image
crop(int $width, int $height, int $x = 0, int $y = 0)
Crop the image to the given dimensions and position.
Image
resize(int|null $width = null, int|null $height = null)
Resize the image to the given dimensions.
Image
rotate(float $angle, string|null $background = null)
Rotate the image clockwise by the given angle.
Image
scale(int|null $width = null, int|null $height = null)
Set the scale dimensions.
Image
orient()
Auto-orient the image based on EXIF data.
Image
blur(int $amount = 5)
Apply a blur effect.
Image
grayscale()
Convert the image to grayscale.
Image
sharpen(int $amount = 10)
Sharpen the image.
Image
flipVertically()
Flip the image vertically.
Image
flipHorizontally()
Flip the image horizontally.
Image
flip()
Flip the image vertically.
Image
flop()
Flip the image horizontally.
Image
transform(Transformation $transformation)
Add a transformation to the image pipeline.
Image
optimize(string $format = 'webp', int $quality = ImageOutputOptions::DEFAULT_QUALITY)
Set the optimization options.
Image
quality(int $quality)
Set the output quality.
Image
toWebp()
Convert the image to WebP format.
Image
toJpg()
Convert the image to JPEG format.
Image
toJpeg()
Convert the image to JPEG format.
protected Image
toFormat(string $format)
Set the output format.
string|false
store(string $path = '', string|null $disk = null, array $options = [])
Store the processed image on a filesystem disk.
string|false
storePublicly(string $path = '', string|null $disk = null, array $options = [])
Store the processed image on a filesystem disk with public visibility.
string|false
storeAs(string $path, string|null $name = null, string|null $disk = null, array $options = [])
Store the processed image on a filesystem disk with a given name.
string|false
storePubliclyAs(string $path, string|null $name = null, string|null $disk = null, array $options = [])
Store the processed image on a filesystem disk with public visibility and a given name.
string
hashName(string $path = '')
Get a hashed filename with the correct extension.
string
toBytes()
Process the image and return the raw bytes.
string
toBase64()
Process the image and return as a base64 encoded string.
string
toDataUri()
Process the image and return as a data URI.
string
extension()
Get the file extension based on the MIME type.
string
mimeType()
Get the MIME type of the processed image.
array
dimensions()
Get the dimensions of the processed image.
int
width()
Get the width of the processed image.
int
height()
Get the height of the processed image.
Image
using(string $driver)
Set the driver to use for processing.
Image
usingGd()
Use the GD driver for processing.
Image
usingImagick()
Use the Imagick driver for processing.
protected Driver
resolveDriver()
Resolve the image processing driver.
UploadedFile|null
file()
Get the underlying uploaded file instance.
protected Image
newClone()
Create an immutable clone with copied options.
protected Image
withOutput(Closure $callback)
Create an immutable clone with updated output options.
protected Image
withClone(Closure $callback)
Create an immutable clone with the given callback applied.
never
__serialize()
Prevent serialization of the image.
string
toString()
Get the string representation of the image.
string
__toString()
Get the string representation of the image.