Image
extends File
in package
Table of Contents
Properties
- $basename : string
- Basename of current file
- $dirname : string
- Name of directory path
- $encoded : string
- Last image encoding result
- $extension : string
- File extension of current file
- $filename : string
- File name of current file
- $mime : string
- Mime type
- $backups : array<string|int, mixed>
- Array of Image resource backups of current image processor
- $core : mixed
- Image resource/object of current image processor
- $driver : AbstractDriver
- Instance of current image driver
Methods
- __call() : mixed
- Magic method to catch all image calls usually any AbstractCommand
- __clone() : mixed
- Cloning an image
- __construct() : mixed
- Creates a new Image instance
- __toString() : string
- Returns encoded image data in string conversion
- backup() : Image
- basePath() : string
- Get fully qualified path
- blur() : Image
- brightness() : Image
- cache() : Image
- canvas() : Image
- circle() : Image
- colorize() : Image
- contrast() : Image
- crop() : Image
- destroy() : void
- ellipse() : Image
- encode() : Image
- Starts encoding of current image
- exif() : mixed
- filesize() : mixed
- Get file size
- fill() : Image
- filter() : Image
- Runs a given filter on current image
- fit() : Image
- flip() : Image
- gamma() : Image
- getBackup() : mixed
- Returns current image backup
- getBackups() : array<string|int, mixed>
- Returns all backups attached to image
- getCore() : mixed
- Returns current image resource/obj
- getDriver() : AbstractDriver
- Returns current image driver
- getEncoded() : string
- Returns encoded image data of current image
- getHeight() : int
- Calculates current image height
- getWidth() : int
- Calculates current image width
- greyscale() : Image
- height() : int
- Alias of getHeight
- heighten() : Image
- insert() : Image
- interlace() : Image
- invert() : Image
- iptc() : mixed
- isEncoded() : bool
- Checks if current image is already encoded
- limitColors() : Image
- line() : Image
- make() : Image
- mask() : Image
- mime() : string
- Reads mime type
- opacity() : Image
- orientate() : Image
- pickColor() : mixed
- pixel() : Image
- pixelate() : Image
- polygon() : Image
- psrResponse() : ResponseInterface
- rectangle() : Image
- reset() : Image
- resize() : Image
- resizeCanvas() : Image
- response() : mixed
- rotate() : Image
- save() : Image
- Saves encoded image in filesystem
- setBackup() : self
- Sets current image backup
- setCore() : mixed
- Sets current image resource
- setDriver() : mixed
- Sets current image driver
- setEncoded() : mixed
- Sets encoded image buffer
- setFileInfoFromPath() : mixed
- Sets all instance properties from given path
- sharpen() : Image
- stream() : StreamInterface
- text() : Image
- trim() : Image
- widen() : Image
- width() : int
- Alias of getWidth()
- backupExists() : bool
- Checks if named backup exists
Properties
$basename
Basename of current file
public
string
$basename
$dirname
Name of directory path
public
string
$dirname
$encoded
Last image encoding result
public
string
$encoded
= ''
$extension
File extension of current file
public
string
$extension
$filename
File name of current file
public
string
$filename
$mime
Mime type
public
string
$mime
$backups
Array of Image resource backups of current image processor
protected
array<string|int, mixed>
$backups
= []
$core
Image resource/object of current image processor
protected
mixed
$core
$driver
Instance of current image driver
protected
AbstractDriver
$driver
Methods
__call()
Magic method to catch all image calls usually any AbstractCommand
public
__call(string $name, array<string|int, mixed> $arguments) : mixed
Parameters
- $name : string
- $arguments : array<string|int, mixed>
__clone()
Cloning an image
public
__clone() : mixed
__construct()
Creates a new Image instance
public
__construct([AbstractDriver $driver = null ][, mixed $core = null ]) : mixed
Parameters
- $driver : AbstractDriver = null
- $core : mixed = null
__toString()
Returns encoded image data in string conversion
public
__toString() : string
Return values
stringbackup()
public
backup([string $name = = '\'\\\'default\\\'\'' ]) : 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
- $name : string = = '\'\\\'default\\\'\''
Return values
ImagebasePath()
Get fully qualified path
public
basePath() : string
Return values
stringblur()
public
blur([int $amount = = '1' ]) : Image
Apply a gaussian blur filter with a optional amount on the current image. Use values between 0 and 100.
Parameters
- $amount : int = = '1'
Return values
Imagebrightness()
public
brightness(int $level) : 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
- $level : int
Return values
Imagecache()
public
cache(Closure $callback[, int $lifetime = = 'null' ][, bool $returnObj = = 'false' ]) : 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
- $callback : Closure
- $lifetime : int = = 'null'
- $returnObj : bool = = 'false'
Return values
Imagecanvas()
public
canvas(int $width, int $height[, mixed $bgcolor = = 'null' ]) : 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
- $width : int
- $height : int
- $bgcolor : mixed = = 'null'
Return values
Imagecircle()
public
circle(int $radius, int $x, int $y[, Closure $callback = = 'null' ]) : Image
Draw a circle at given x, y, coordinates with given radius. You can define the appearance of the circle by an optional closure callback.
Parameters
- $radius : int
- $x : int
- $y : int
- $callback : Closure = = 'null'
Return values
Imagecolorize()
public
colorize(int $red, int $green, int $blue) : 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
- $red : int
- $green : int
- $blue : int
Return values
Imagecontrast()
public
contrast(int $level) : 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
- $level : int
Return values
Imagecrop()
public
crop(int $width, int $height[, int $x = = 'null' ][, int $y = = 'null' ]) : 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
- $width : int
- $height : int
- $x : int = = 'null'
- $y : int = = 'null'
Return values
Imagedestroy()
public
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()
public
ellipse(int $width, int $height, int $x, int $y[, Closure $callback = = 'null' ]) : 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
- $width : int
- $height : int
- $x : int
- $y : int
- $callback : Closure = = 'null'
Return values
Imageencode()
Starts encoding of current image
public
encode([string $format = null ][, int $quality = 90 ]) : Image
Parameters
- $format : string = null
- $quality : int = 90
Return values
Imageexif()
public
exif([string $key = = 'null' ]) : mixed
Read Exif meta data from current image.
Parameters
- $key : string = = 'null'
filesize()
Get file size
public
filesize() : mixed
fill()
public
fill(mixed $filling[, int $x = = 'null' ][, int $y = = 'null' ]) : 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
- $filling : mixed
- $x : int = = 'null'
- $y : int = = 'null'
Return values
Imagefilter()
Runs a given filter on current image
public
filter(FiltersFilterInterface $filter) : Image
Parameters
- $filter : FiltersFilterInterface
Return values
Imagefit()
public
fit(int $width[, int $height = = 'null' ][, Closure $callback = = 'null' ][, string $position = = '\'\\\'center\\\'\'' ]) : 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
- $width : int
- $height : int = = 'null'
- $callback : Closure = = 'null'
- $position : string = = '\'\\\'center\\\'\''
Return values
Imageflip()
public
flip([string $mode = = '\'\\\'h\\\'\'' ]) : Image
Mirror the current image horizontally or vertically by specifying the mode.
Parameters
- $mode : string = = '\'\\\'h\\\'\''
Return values
Imagegamma()
public
gamma(float $correction) : Image
Performs a gamma correction operation on the current image.
Parameters
- $correction : float
Return values
ImagegetBackup()
Returns current image backup
public
getBackup([string $name = null ]) : mixed
Parameters
- $name : string = null
getBackups()
Returns all backups attached to image
public
getBackups() : array<string|int, mixed>
Return values
array<string|int, mixed>getCore()
Returns current image resource/obj
public
getCore() : mixed
getDriver()
Returns current image driver
public
getDriver() : AbstractDriver
Return values
AbstractDrivergetEncoded()
Returns encoded image data of current image
public
getEncoded() : string
Return values
stringgetHeight()
Calculates current image height
public
getHeight() : int
Return values
intgetWidth()
Calculates current image width
public
getWidth() : int
Return values
intgreyscale()
public
greyscale() : Image
Turns image into a greyscale version.
Return values
Imageheight()
Alias of getHeight
public
height() : int
Return values
intheighten()
public
heighten(int $height[, Closure $callback = = 'null' ]) : 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
- $height : int
- $callback : Closure = = 'null'
Return values
Imageinsert()
public
insert(mixed $source[, string $position = = '\'\\\'top-left\\\'\'' ][, int $x = = '0' ][, int $y = = '0' ]) : 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
- $source : mixed
- $position : string = = '\'\\\'top-left\\\'\''
- $x : int = = '0'
- $y : int = = '0'
Return values
Imageinterlace()
public
interlace([bool $interlace = = 'true' ]) : 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
- $interlace : bool = = 'true'
Return values
Imageinvert()
public
invert() : Image
Reverses all colors of the current image.
Return values
Imageiptc()
public
iptc([string $key = = 'null' ]) : mixed
Read Iptc meta data from current image.
Parameters
- $key : string = = 'null'
isEncoded()
Checks if current image is already encoded
public
isEncoded() : bool
Return values
boollimitColors()
public
limitColors(int $count[, mixed $matte = = 'null' ]) : 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
- $count : int
- $matte : mixed = = 'null'
Return values
Imageline()
public
line(int $x1, int $y1, int $x2, int $y2[, Closure $callback = = 'null' ]) : 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
- $x1 : int
- $y1 : int
- $x2 : int
- $y2 : int
- $callback : Closure = = 'null'
Return values
Imagemake()
public
make(mixed $source) : 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
- $source : mixed
Return values
Imagemask()
public
mask(mixed $source, bool $mask_with_alpha) : 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
- $source : mixed
- $mask_with_alpha : bool
Return values
Imagemime()
Reads mime type
public
mime() : string
Return values
stringopacity()
public
opacity(int $transparency) : Image
Set the opacity in percent of the current image ranging from 100% for opaque and 0% for full transparency.
Parameters
- $transparency : int
Return values
Imageorientate()
public
orientate() : Image
This method reads the EXIF image profile setting 'Orientation' and performs a rotation on the image to display the image correctly.
Return values
ImagepickColor()
public
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
- $x : int
- $y : int
- $format : string = = '\'\\\'array\\\'\''
pixel()
public
pixel(mixed $color, int $x, int $y) : Image
Draw a single pixel in given color on x, y position.
Parameters
- $color : mixed
- $x : int
- $y : int
Return values
Imagepixelate()
public
pixelate(int $size) : Image
Applies a pixelation effect to the current image with a given size of pixels.
Parameters
- $size : int
Return values
Imagepolygon()
public
polygon(array<string|int, mixed> $points[, Closure $callback = = 'null' ]) : Image
Draw a colored polygon with given points. You can define the appearance of the polygon by an optional closure callback.
Parameters
- $points : array<string|int, mixed>
- $callback : Closure = = 'null'
Return values
ImagepsrResponse()
public
psrResponse([string $format = = 'null' ][, int $quality = = '90' ]) : ResponseInterface
Build PSR-7 compatible ResponseInterface with current image in given format and quality.
Parameters
- $format : string = = 'null'
- $quality : int = = '90'
Return values
ResponseInterfacerectangle()
public
rectangle(int $x1, int $y1, int $x2, int $y2[, Closure $callback = = 'null' ]) : 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
- $x1 : int
- $y1 : int
- $x2 : int
- $y2 : int
- $callback : Closure = = 'null'
Return values
Imagereset()
public
reset([string $name = = '\'\\\'default\\\'\'' ]) : Image
Resets all of the modifications to a state saved previously by backup under an optional name.
Parameters
- $name : string = = '\'\\\'default\\\'\''
Return values
Imageresize()
public
resize([int $width = = 'null' ][, int $height = = 'null' ][, Closure $callback = = 'null' ]) : 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
- $width : int = = 'null'
- $height : int = = 'null'
- $callback : Closure = = 'null'
Return values
ImageresizeCanvas()
public
resizeCanvas(int $width, int $height[, string $anchor = = '\'\\\'center\\\'\'' ][, bool $relative = = 'false' ][, mixed $bgcolor = = 'null' ]) : 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
- $width : int
- $height : int
- $anchor : string = = '\'\\\'center\\\'\''
- $relative : bool = = 'false'
- $bgcolor : mixed = = 'null'
Return values
Imageresponse()
public
response([string $format = = 'null' ][, int $quality = = '90' ]) : mixed
Sends HTTP response with current image in given format and quality.
Parameters
- $format : string = = 'null'
- $quality : int = = '90'
rotate()
public
rotate(float $angle[, mixed $bgcolor = = 'null' ]) : Image
Rotate the current image counter-clockwise by a given angle. Optionally define a background color for the uncovered zone after the rotation.
Parameters
- $angle : float
- $bgcolor : mixed = = 'null'
Return values
Imagesave()
Saves encoded image in filesystem
public
save([string $path = null ][, int $quality = null ][, string $format = null ]) : Image
Parameters
- $path : string = null
- $quality : int = null
- $format : string = null
Return values
ImagesetBackup()
Sets current image backup
public
setBackup(mixed $resource[, string $name = null ]) : self
Parameters
- $resource : mixed
- $name : string = null
Return values
selfsetCore()
Sets current image resource
public
setCore(mixed $core) : mixed
Parameters
- $core : mixed
setDriver()
Sets current image driver
public
setDriver(AbstractDriver $driver) : mixed
Parameters
- $driver : AbstractDriver
setEncoded()
Sets encoded image buffer
public
setEncoded(string $value) : mixed
Parameters
- $value : string
setFileInfoFromPath()
Sets all instance properties from given path
public
setFileInfoFromPath(string $path) : mixed
Parameters
- $path : string
sharpen()
public
sharpen([int $amount = = '10' ]) : Image
Sharpen current image with an optional amount. Use values between 0 and 100.
Parameters
- $amount : int = = '10'
Return values
Imagestream()
public
stream([string $format = = 'null' ][, int $quality = = '90' ]) : StreamInterface
Build PSR-7 compatible StreamInterface with current image in given format and quality.
Parameters
- $format : string = = 'null'
- $quality : int = = '90'
Return values
StreamInterfacetext()
public
text(string $text[, int $x = = '0' ][, int $y = = '0' ][, Closure $callback = = 'null' ]) : 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
- $text : string
- $x : int = = '0'
- $y : int = = '0'
- $callback : Closure = = 'null'
Return values
Imagetrim()
public
trim([string $base = = '\'\\\'top-left\\\'\'' ][, array<string|int, mixed> $away = = '[\'\\\'top\\\'\', \'\\\'bottom\\\'\', \'\\\'left\\\'\', \'\\\'right\\\'\']' ][, int $tolerance = = '0' ][, int $feather = = '0' ]) : Image
Trim away image space in given color. Define an optional base to pick a color at a certain position and borders that should be trimmed away. You can also set an optional tolerance level, to trim similar colors and add a feathering border around the trimed image.
Parameters
- $base : string = = '\'\\\'top-left\\\'\''
- $away : array<string|int, mixed> = = '[\'\\\'top\\\'\', \'\\\'bottom\\\'\', \'\\\'left\\\'\', \'\\\'right\\\'\']'
- $tolerance : int = = '0'
- $feather : int = = '0'
Return values
Imagewiden()
public
widen(int $width[, Closure $callback = = 'null' ]) : 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
- $width : int
- $callback : Closure = = 'null'
Return values
Imagewidth()
Alias of getWidth()
public
width() : int
Return values
intbackupExists()
Checks if named backup exists
private
backupExists(string $name) : bool
Parameters
- $name : string