Properties

$mime

$mime : string

Mime type

Type

string

$dirname

$dirname : string

Name of directory path

Type

string

$basename

$basename : string

Basename of current file

Type

string

$extension

$extension : string

File extension of current file

Type

string

$filename

$filename : string

File name of current file

Type

string

$encoded

$encoded : string

Last image encoding result

Type

string

$driver

$driver : \Intervention\Image\AbstractDriver

Instance of current image driver

Type

AbstractDriver

$core

$core : mixed

Image resource/object of current image processor

Type

mixed

$backups

$backups : array

Array of Image resource backups of current image processor

Type

array

Methods

setFileInfoFromPath()

setFileInfoFromPath(string  $path) : mixed

Sets all instance properties from given path

Parameters

string $path

Returns

mixed —

filesize()

filesize() : mixed

Get file size

Returns

mixed —

basePath()

basePath() : string

Get fully qualified path

Returns

string —

__construct()

__construct(\Intervention\Image\AbstractDriver  $driver = null, mixed  $core = null) : mixed

Creates a new Image instance

Parameters

\Intervention\Image\AbstractDriver $driver
mixed $core

Returns

mixed —

__call()

__call(string  $name, array  $arguments) : mixed

Magic method to catch all image calls usually any AbstractCommand

Parameters

string $name
array $arguments

Returns

mixed —

encode()

encode(string  $format = null, int  $quality = 90) : \Intervention\Image\Image

Starts encoding of current image

Parameters

string $format
int $quality

Returns

\Intervention\Image\Image —

save()

save(string  $path = null, int  $quality = null, string  $format = null) : \Intervention\Image\Image

Saves encoded image in filesystem

Parameters

string $path
int $quality
string $format

Returns

\Intervention\Image\Image —

filter()

filter(\Intervention\Image\FiltersFilterInterface  $filter) : \Intervention\Image\Image

Runs a given filter on current image

Parameters

\Intervention\Image\FiltersFilterInterface $filter

Returns

\Intervention\Image\Image —

getDriver()

getDriver() : \Intervention\Image\AbstractDriver

Returns current image driver

Returns

\Intervention\Image\AbstractDriver —

setDriver()

setDriver(\Intervention\Image\AbstractDriver  $driver) : mixed

Sets current image driver

Parameters

\Intervention\Image\AbstractDriver $driver

Returns

mixed —

getCore()

getCore() : mixed

Returns current image resource/obj

Returns

mixed —

setCore()

setCore(mixed  $core) : mixed

Sets current image resource

Parameters

mixed $core

Returns

mixed —

getBackup()

getBackup(string  $name = null) : mixed

Returns current image backup

Parameters

string $name

Returns

mixed —

getBackups()

getBackups() : array

Returns all backups attached to image

Returns

array —

setBackup()

setBackup(mixed  $resource, string  $name = null) : self

Sets current image backup

Parameters

mixed $resource
string $name

Returns

self —

isEncoded()

isEncoded() : bool

Checks if current image is already encoded

Returns

bool —

getEncoded()

getEncoded() : string

Returns encoded image data of current image

Returns

string —

setEncoded()

setEncoded(string  $value) : mixed

Sets encoded image buffer

Parameters

string $value

Returns

mixed —

getWidth()

getWidth() : int

Calculates current image width

Returns

int —

width()

width() : int

Alias of getWidth()

Returns

int —

getHeight()

getHeight() : int

Calculates current image height

Returns

int —

height()

height() : int

Alias of getHeight

Returns

int —

mime()

mime() : string

Reads mime type

Returns

string —

__toString()

__toString() : string

Returns encoded image data in string conversion

Returns

string —

__clone()

__clone() : mixed

Cloning an image

Returns

mixed —

backup()

backup(string  $name = 'default') : \Intervention\Image\Image

Backups current image state as fallback for reset method under an optional name. Overwrites older state on every call, unless a different name is passed.

Parameters

string $name = 'default'

Returns

\Intervention\Image\Image —

blur()

blur(int  $amount = 1) : \Intervention\Image\Image

Apply a gaussian blur filter with a optional amount on the current image. Use values between 0 and 100.

Parameters

int $amount = 1

Returns

\Intervention\Image\Image —

brightness()

brightness(int  $level) : \Intervention\Image\Image

Changes the brightness of the current image by the given level. Use values between -100 for min. brightness. 0 for no change and +100 for max. brightness.

Parameters

int $level

Returns

\Intervention\Image\Image —

cache()

cache(\Closure  $callback, int  $lifetime = null, bool  $returnObj = false) : \Intervention\Image\Image

Method to create a new cached image instance from a Closure callback. Pass a lifetime in minutes for the callback and decide whether you want to get an Intervention Image instance as return value or just receive the image stream.

Parameters

\Closure $callback
int $lifetime = null
bool $returnObj = false

Returns

\Intervention\Image\Image —

canvas()

canvas(int  $width, int  $height, mixed  $bgcolor = null) : \Intervention\Image\Image

Factory method to create a new empty image instance with given width and height. You can define a background-color optionally. By default the canvas background is transparent.

Parameters

int $width
int $height
mixed $bgcolor = null

Returns

\Intervention\Image\Image —

circle()

circle(int  $diameter, int  $x, int  $y, \Closure  $callback = null) : \Intervention\Image\Image

Draw a circle at given x, y, coordinates with given diameter. You can define the appearance of the circle by an optional closure callback.

Parameters

int $diameter
int $x
int $y
\Closure $callback = null

Returns

\Intervention\Image\Image —

colorize()

colorize(int  $red, int  $green, int  $blue) : \Intervention\Image\Image

Change the RGB color values of the current image on the given channels red, green and blue. The input values are normalized so you have to include parameters from 100 for maximum color value. 0 for no change and -100 to take out all the certain color on the image.

Parameters

int $red
int $green
int $blue

Returns

\Intervention\Image\Image —

contrast()

contrast(int  $level) : \Intervention\Image\Image

Changes the contrast of the current image by the given level. Use values between -100 for min. contrast 0 for no change and +100 for max. contrast.

Parameters

int $level

Returns

\Intervention\Image\Image —

crop()

crop(int  $width, int  $height, int  $x = null, int  $y = null) : \Intervention\Image\Image

Cut out a rectangular part of the current image with given width and height. Define optional x,y coordinates to move the top-left corner of the cutout to a certain position.

Parameters

int $width
int $height
int $x = null
int $y = null

Returns

\Intervention\Image\Image —

destroy()

destroy() : void

Frees memory associated with the current image instance before the PHP script ends. Normally resources are destroyed automatically after the script is finished.

ellipse()

ellipse(int  $width, int  $height, int  $x, int  $y, \Closure  $callback = null) : \Intervention\Image\Image

Draw a colored ellipse at given x, y, coordinates. You can define width and height and set the appearance of the circle by an optional closure callback.

Parameters

int $width
int $height
int $x
int $y
\Closure $callback = null

Returns

\Intervention\Image\Image —

exif()

exif(string  $key = null) : mixed

Read Exif meta data from current image.

Parameters

string $key = null

Returns

mixed —

iptc()

iptc(string  $key = null) : mixed

Read Iptc meta data from current image.

Parameters

string $key = null

Returns

mixed —

fill()

fill(mixed  $filling, int  $x = null, int  $y = null) : \Intervention\Image\Image

Fill current image with given color or another image used as tile for filling. Pass optional x, y coordinates to start at a certain point.

Parameters

mixed $filling
int $x = null
int $y = null

Returns

\Intervention\Image\Image —

flip()

flip(string  $mode = 'h') : \Intervention\Image\Image

Mirror the current image horizontally or vertically by specifying the mode.

Parameters

string $mode = 'h'

Returns

\Intervention\Image\Image —

fit()

fit(int  $width, int  $height = null, \Closure  $callback = null, string  $position = 'center') : \Intervention\Image\Image

Combine cropping and resizing to format image in a smart way. The method will find the best fitting aspect ratio of your given width and height on the current image automatically, cut it out and resize it to the given dimension. You may pass an optional Closure callback as third parameter, to prevent possible upsizing and a custom position of the cutout as fourth parameter.

Parameters

int $width
int $height = null
\Closure $callback = null
string $position = 'center'

Returns

\Intervention\Image\Image —

gamma()

gamma(float  $correction) : \Intervention\Image\Image

Performs a gamma correction operation on the current image.

Parameters

float $correction

Returns

\Intervention\Image\Image —

greyscale()

greyscale() : \Intervention\Image\Image

Turns image into a greyscale version.

Returns

\Intervention\Image\Image —

heighten()

heighten(int  $height, \Closure  $callback = null) : \Intervention\Image\Image

Resizes the current image to new height, constraining aspect ratio. Pass an optional Closure callback as third parameter, to apply additional constraints like preventing possible upsizing.

Parameters

int $height
\Closure $callback = null

Returns

\Intervention\Image\Image —

insert()

insert(mixed  $source, string  $position = 'top-left', int  $x = 0, int  $y = 0) : \Intervention\Image\Image

Paste a given image source over the current image with an optional position and a offset coordinate. This method can be used to apply another image as watermark because the transparency values are maintained.

Parameters

mixed $source
string $position = 'top-left'
int $x = 0
int $y = 0

Returns

\Intervention\Image\Image —

interlace()

interlace(bool  $interlace = true) : \Intervention\Image\Image

Determine whether an image should be encoded in interlaced or standard mode by toggling interlace mode with a boolean parameter. If an JPEG image is set interlaced the image will be processed as a progressive JPEG.

Parameters

bool $interlace = true

Returns

\Intervention\Image\Image —

invert()

invert() : \Intervention\Image\Image

Reverses all colors of the current image.

Returns

\Intervention\Image\Image —

limitColors()

limitColors(int  $count, mixed  $matte = null) : \Intervention\Image\Image

Method converts the existing colors of the current image into a color table with a given maximum count of colors. The function preserves as much alpha channel information as possible and blends transarent pixels against a optional matte color.

Parameters

int $count
mixed $matte = null

Returns

\Intervention\Image\Image —

line()

line(int  $x1, int  $y1, int  $x2, int  $y2, \Closure  $callback = null) : \Intervention\Image\Image

Draw a line from x,y point 1 to x,y point 2 on current image. Define color and/or width of line in an optional Closure callback.

Parameters

int $x1
int $y1
int $x2
int $y2
\Closure $callback = null

Returns

\Intervention\Image\Image —

make()

make(mixed  $source) : \Intervention\Image\Image

Universal factory method to create a new image instance from source, which can be a filepath, a GD image resource, an Imagick object or a binary image data.

Parameters

mixed $source

Returns

\Intervention\Image\Image —

mask()

mask(mixed  $source, bool  $mask_with_alpha) : \Intervention\Image\Image

Apply a given image source as alpha mask to the current image to change current opacity. Mask will be resized to the current image size. By default a greyscale version of the mask is converted to alpha values, but you can set mask_with_alpha to apply the actual alpha channel. Any transparency values of the current image will be maintained.

Parameters

mixed $source
bool $mask_with_alpha

Returns

\Intervention\Image\Image —

opacity()

opacity(int  $transparency) : \Intervention\Image\Image

Set the opacity in percent of the current image ranging from 100% for opaque and 0% for full transparency.

Parameters

int $transparency

Returns

\Intervention\Image\Image —

orientate()

orientate() : \Intervention\Image\Image

This method reads the EXIF image profile setting 'Orientation' and performs a rotation on the image to display the image correctly.

Returns

\Intervention\Image\Image —

pickColor()

pickColor(int  $x, int  $y, string  $format = 'array') : mixed

Pick a color at point x, y out of current image and return in optional given format.

Parameters

int $x
int $y
string $format = 'array'

Returns

mixed —

pixel()

pixel(mixed  $color, int  $x, int  $y) : \Intervention\Image\Image

Draw a single pixel in given color on x, y position.

Parameters

mixed $color
int $x
int $y

Returns

\Intervention\Image\Image —

pixelate()

pixelate(int  $size) : \Intervention\Image\Image

Applies a pixelation effect to the current image with a given size of pixels.

Parameters

int $size

Returns

\Intervention\Image\Image —

polygon()

polygon(array  $points, \Closure  $callback = null) : \Intervention\Image\Image

Draw a colored polygon with given points. You can define the appearance of the polygon by an optional closure callback.

Parameters

array $points
\Closure $callback = null

Returns

\Intervention\Image\Image —

rectangle()

rectangle(int  $x1, int  $y1, int  $x2, int  $y2, \Closure  $callback = null) : \Intervention\Image\Image

Draw a colored rectangle on current image with top-left corner on x,y point 1 and bottom-right corner at x,y point 2. Define the overall appearance of the shape by passing a Closure callback as an optional parameter.

Parameters

int $x1
int $y1
int $x2
int $y2
\Closure $callback = null

Returns

\Intervention\Image\Image —

reset()

reset(string  $name = 'default') : \Intervention\Image\Image

Resets all of the modifications to a state saved previously by backup under an optional name.

Parameters

string $name = 'default'

Returns

\Intervention\Image\Image —

resize()

resize(int  $width = null, int  $height = null, \Closure  $callback = null) : \Intervention\Image\Image

Resizes current image based on given width and/or height. To contraint the resize command, pass an optional Closure callback as third parameter.

Parameters

int $width = null
int $height = null
\Closure $callback = null

Returns

\Intervention\Image\Image —

resizeCanvas()

resizeCanvas(int  $width, int  $height, string  $anchor = 'center', bool  $relative = false, mixed  $bgcolor = null) : \Intervention\Image\Image

Resize the boundaries of the current image to given width and height. An anchor can be defined to determine from what point of the image the resizing is going to happen. Set the mode to relative to add or subtract the given width or height to the actual image dimensions. You can also pass a background color for the emerging area of the image.

Parameters

int $width
int $height
string $anchor = 'center'
bool $relative = false
mixed $bgcolor = null

Returns

\Intervention\Image\Image —

response()

response(string  $format = null, int  $quality = 90) : mixed

Sends HTTP response with current image in given format and quality.

Parameters

string $format = null
int $quality = 90

Returns

mixed —

rotate()

rotate(float  $angle, mixed  $bgcolor = null) : \Intervention\Image\Image

Rotate the current image counter-clockwise by a given angle. Optionally define a background color for the uncovered zone after the rotation.

Parameters

float $angle
mixed $bgcolor = null

Returns

\Intervention\Image\Image —

sharpen()

sharpen(int  $amount = 10) : \Intervention\Image\Image

Sharpen current image with an optional amount. Use values between 0 and 100.

Parameters

int $amount = 10

Returns

\Intervention\Image\Image —

text()

text(string  $text, int  $x = 0, int  $y = 0, \Closure  $callback = null) : \Intervention\Image\Image

Write a text string to the current image at an optional x,y basepoint position. You can define more details like font-size, font-file and alignment via a callback as the fourth parameter.

Parameters

string $text
int $x = 0
int $y = 0
\Closure $callback = null

Returns

\Intervention\Image\Image —

widen()

widen(int  $width, \Closure  $callback = null) : \Intervention\Image\Image

Resizes the current image to new width, constraining aspect ratio. Pass an optional Closure callback as third parameter, to apply additional constraints like preventing possible upsizing.

Parameters

int $width
\Closure $callback = null

Returns

\Intervention\Image\Image —

stream()

stream(string  $format = null, int  $quality = 90) : \Psr\Http\Message\StreamInterface

Build PSR-7 compatible StreamInterface with current image in given format and quality.

Parameters

string $format = null
int $quality = 90

Returns

\Psr\Http\Message\StreamInterface —

psrResponse()

psrResponse(string  $format = null, int  $quality = 90) : \Psr\Http\Message\ResponseInterface

Build PSR-7 compatible ResponseInterface with current image in given format and quality.

Parameters

string $format = null
int $quality = 90

Returns

\Psr\Http\Message\ResponseInterface —

backupExists()

backupExists(string  $name) : bool

Checks if named backup exists

Parameters

string $name

Returns

bool —