Documentation

Image
in package
uses SmartObject

Basic manipulation with images. Supported types are JPEG, PNG, GIF, WEBP, AVIF and BMP.

$image = Image::fromFile('nette.jpg'); $image->resize(150, 100); $image->sharpen(); $image->send();

Table of Contents

Constants

AVIF  = \Nette\Utils\ImageType::AVIF
image types
BMP  = \Nette\Utils\ImageType::BMP
image types
Cover  = 0b1000
Resizes to the smallest possible size to completely cover specified width and height and reserves aspect ratio
EMPTY_GIF  = self::EmptyGIF
EmptyGIF  = "GIF89a\x01\x00\x01\x00\x80\x00\x00\x00\x00\x00\x00\x00\x00!\xf9\x04\x01\x00\x00\x00\x00,\x00\x00\x00\x00\x01\x00\x01\x00\x00\x02\x02D\x01\x00;"
EXACT  = self::Cover
FILL  = self::OrBigger
FIT  = self::OrSmaller
GIF  = \Nette\Utils\ImageType::GIF
image types
JPEG  = \Nette\Utils\ImageType::JPEG
image types
OrBigger  = 0b100
Resizes while bounding the smaller dimension to the specified width or height and preserves aspect ratio
OrSmaller  = 0b0
Resizes to fit into a specified width and height and preserves aspect ratio
PNG  = \Nette\Utils\ImageType::PNG
image types
SHRINK_ONLY  = self::ShrinkOnly
ShrinkOnly  = 0b1
Prevent from getting resized to a bigger size than the original
Stretch  = 0b10
Resizes to a specified width and height without keeping aspect ratio
STRETCH  = self::Stretch
WEBP  = \Nette\Utils\ImageType::WEBP
image types
Formats  = [\Nette\Utils\ImageType::JPEG => 'jpeg', \Nette\Utils\ImageType::PNG => 'png', \Nette\Utils\ImageType::GIF => 'gif', \Nette\Utils\ImageType::WEBP => 'webp', \Nette\Utils\ImageType::AVIF => 'avif', \Nette\Utils\ImageType::BMP => 'bmp']

Properties

$height  : positive-int
$imageResource  : GdImage
$width  : positive-int
$image  : GdImage

Methods

__call()  : mixed
Call to undefined method.
__callStatic()  : mixed
__clone()  : mixed
__construct()  : mixed
Wraps GD image.
__get()  : mixed
__isset()  : bool
__set()  : void
__sleep()  : array<string|int, mixed>
Prevents serialization.
__toString()  : string
Outputs image to string.
__unset()  : void
affine()  : Image
alphaBlending()  : void
antialias()  : void
arc()  : void
calculateCutout()  : array<string|int, mixed>
Calculates dimensions of cutout in image. Arguments accepts pixels or percent.
calculateSize()  : array<string|int, mixed>
Calculates dimensions of resized image. Width and height accept pixels or percent.
calculateTextBox()  : array<string|int, mixed>
Calculates the bounding box for a TrueType text. Returns keys left, top, width and height.
colorAllocate()  : int
colorAllocateAlpha()  : int
colorAt()  : int
colorClosest()  : int
colorClosestAlpha()  : int
colorClosestHWB()  : int
colorDeallocate()  : void
colorExact()  : int
colorExactAlpha()  : int
colorMatch()  : void
colorResolve()  : int
colorResolveAlpha()  : int
colorSet()  : void
colorsForIndex()  : array<string|int, mixed>
colorsTotal()  : int
colorTransparent()  : int
convolution()  : void
copy()  : void
copyMerge()  : void
copyMergeGray()  : void
copyResampled()  : void
copyResized()  : void
crop()  : static
Crops image. Arguments accepts pixels or percent.
cropAuto()  : Image
detectTypeFromFile()  : ImageType::*|null
Returns the type of image from file.
detectTypeFromString()  : ImageType::*|null
Returns the type of image from string.
ellipse()  : void
extensionToType()  : ImageType::*
Returns the image type for given file extension.
fill()  : void
filledArc()  : void
filledEllipse()  : void
filledPolygon()  : void
filledRectangle()  : void
filledRectangleWH()  : void
Draw a filled rectangle.
fillToBorder()  : void
filter()  : void
flip()  : void
fromBlank()  : static
Creates a new true color image of the given dimensions. The default color is black.
fromFile()  : static
Reads an image from a file and returns its type in $type.
fromString()  : static
Reads an image from a string and returns its type in $type.
ftText()  : array<string|int, mixed>
gammaCorrect()  : void
getClip()  : array<string|int, mixed>
getHeight()  : positive-int
Returns image height.
getImageResource()  : GdImage
Returns image GD resource.
getInterpolation()  : int
getSupportedTypes()  : array<string|int, ImageType>
getWidth()  : positive-int
Returns image width.
interlace()  : int
isTrueColor()  : bool
isTypeSupported()  : bool
layerEffect()  : void
line()  : void
openPolygon()  : void
paletteCopy()  : void
paletteToTrueColor()  : void
place()  : static
Puts another image into this image. Left and top accepts pixels or percent.
polygon()  : void
rectangle()  : void
rectangleWH()  : void
Draw a rectangle.
resize()  : static
Scales an image. Width and height accept pixels or percent.
resolution()  : mixed
resolveColor()  : int
rgb()  : array<string|int, mixed>
Returns RGB color (0..255) and transparency (0..127).
rotate()  : Image
save()  : void
Saves image to the file. Quality is in the range 0..100 for JPEG (default 85), WEBP (default 80) and AVIF (default 30) and 0..9 for PNG (default 9).
saveAlpha()  : void
scale()  : Image
send()  : void
Outputs image to browser. Quality is in the range 0..100 for JPEG (default 85), WEBP (default 80) and AVIF (default 30) and 0..9 for PNG (default 9).
setBrush()  : void
setClip()  : void
setInterpolation()  : void
setPixel()  : void
setStyle()  : void
setThickness()  : void
setTile()  : void
sharpen()  : static
Sharpens image a little bit.
toString()  : string
Outputs image to string. Quality is in the range 0..100 for JPEG (default 85), WEBP (default 80) and AVIF (default 30) and 0..9 for PNG (default 9).
trueColorToPalette()  : void
ttfText()  : array<string|int, mixed>
typeToExtension()  : value-of
Returns the file extension for the given image type.
typeToMimeType()  : string
Returns the mime type for the given image type.
setImageResource()  : static
Sets image resource.
ensureExtension()  : void
invokeSafe()  : static
isPercent()  : bool
output()  : void
Outputs image to browser or file.

Constants

AVIF

image types

public mixed AVIF = \Nette\Utils\ImageType::AVIF

BMP

image types

public mixed BMP = \Nette\Utils\ImageType::BMP

Cover

Resizes to the smallest possible size to completely cover specified width and height and reserves aspect ratio

public mixed Cover = 0b1000

EMPTY_GIF

use Image::EmptyGIF

public mixed EMPTY_GIF = self::EmptyGIF

EmptyGIF

public mixed EmptyGIF = "GIF89a\x01\x00\x01\x00\x80\x00\x00\x00\x00\x00\x00\x00\x00!\xf9\x04\x01\x00\x00\x00\x00,\x00\x00\x00\x00\x01\x00\x01\x00\x00\x02\x02D\x01\x00;"

EXACT

use Image::Cover

public mixed EXACT = self::Cover

FILL

use Image::OrBigger

public mixed FILL = self::OrBigger

FIT

use Image::OrSmaller

public mixed FIT = self::OrSmaller

GIF

image types

public mixed GIF = \Nette\Utils\ImageType::GIF

JPEG

image types

public mixed JPEG = \Nette\Utils\ImageType::JPEG

OrBigger

Resizes while bounding the smaller dimension to the specified width or height and preserves aspect ratio

public mixed OrBigger = 0b100

OrSmaller

Resizes to fit into a specified width and height and preserves aspect ratio

public mixed OrSmaller = 0b0

PNG

image types

public mixed PNG = \Nette\Utils\ImageType::PNG

SHRINK_ONLY

use Image::ShrinkOnly

public mixed SHRINK_ONLY = self::ShrinkOnly

ShrinkOnly

Prevent from getting resized to a bigger size than the original

public mixed ShrinkOnly = 0b1

Stretch

Resizes to a specified width and height without keeping aspect ratio

public mixed Stretch = 0b10

STRETCH

use Image::Stretch

public mixed STRETCH = self::Stretch

WEBP

image types

public mixed WEBP = \Nette\Utils\ImageType::WEBP

Formats

private mixed Formats = [\Nette\Utils\ImageType::JPEG => 'jpeg', \Nette\Utils\ImageType::PNG => 'png', \Nette\Utils\ImageType::GIF => 'gif', \Nette\Utils\ImageType::WEBP => 'webp', \Nette\Utils\ImageType::AVIF => 'avif', \Nette\Utils\ImageType::BMP => 'bmp']

Properties

$height read-only

public positive-int $height

$imageResource read-only

public GdImage $imageResource

$width read-only

public positive-int $width

$image

private GdImage $image

Methods

__call()

Call to undefined method.

public __call(string $name, array<string|int, mixed> $args) : mixed
Parameters
$name : string
$args : array<string|int, mixed>
Tags
throws
MemberAccessException

__callStatic()

public static __callStatic(string $name, array<string|int, mixed> $args) : mixed
Parameters
$name : string
$args : array<string|int, mixed>
Tags
throws
MemberAccessException

__clone()

public __clone() : mixed

__construct()

Wraps GD image.

public __construct(GdImage $image) : mixed
Parameters
$image : GdImage

__isset()

public __isset(string $name) : bool
Parameters
$name : string
Return values
bool

__set()

public __set(string $name, mixed $value) : void
Parameters
$name : string
$value : mixed
Tags
throws
MemberAccessException

if the property is not defined or is read-only

__sleep()

Prevents serialization.

public __sleep() : array<string|int, mixed>
Return values
array<string|int, mixed>

__toString()

Outputs image to string.

public __toString() : string
Return values
string

affine()

public affine(array<string|int, mixed> $affine[, array<string|int, mixed>|null $clip = = 'null' ]) : Image
Parameters
$affine : array<string|int, mixed>
$clip : array<string|int, mixed>|null = = 'null'
Return values
Image

alphaBlending()

public alphaBlending(bool $enable) : void
Parameters
$enable : bool

antialias()

public antialias(bool $enable) : void
Parameters
$enable : bool

arc()

public arc(int $centerX, int $centerY, int $width, int $height, int $startAngle, int $endAngle, ImageColor $color) : void
Parameters
$centerX : int
$centerY : int
$width : int
$height : int
$startAngle : int
$endAngle : int
$color : ImageColor

calculateCutout()

Calculates dimensions of cutout in image. Arguments accepts pixels or percent.

public static calculateCutout(int $srcWidth, int $srcHeight, int|string $left, int|string $top, int|string $newWidth, int|string $newHeight) : array<string|int, mixed>
Parameters
$srcWidth : int
$srcHeight : int
$left : int|string
$top : int|string
$newWidth : int|string
$newHeight : int|string
Return values
array<string|int, mixed>

calculateSize()

Calculates dimensions of resized image. Width and height accept pixels or percent.

public static calculateSize(int $srcWidth, int $srcHeight, mixed $newWidth, mixed $newHeight[, int-mask-of $mode = self::OrSmaller ]) : array<string|int, mixed>
Parameters
$srcWidth : int
$srcHeight : int
$newWidth : mixed
$newHeight : mixed
$mode : int-mask-of = self::OrSmaller
Return values
array<string|int, mixed>

calculateTextBox()

Calculates the bounding box for a TrueType text. Returns keys left, top, width and height.

public static calculateTextBox(string $text, string $fontFile, float $size[, float $angle = 0 ][, array<string|int, mixed> $options = [] ]) : array<string|int, mixed>
Parameters
$text : string
$fontFile : string
$size : float
$angle : float = 0
$options : array<string|int, mixed> = []
Return values
array<string|int, mixed>

colorAllocate()

public colorAllocate(int $red, int $green, int $blue) : int
Parameters
$red : int
$green : int
$blue : int
Return values
int

colorAllocateAlpha()

public colorAllocateAlpha(int $red, int $green, int $blue, int $alpha) : int
Parameters
$red : int
$green : int
$blue : int
$alpha : int
Return values
int

colorAt()

public colorAt(int $x, int $y) : int
Parameters
$x : int
$y : int
Return values
int

colorClosest()

public colorClosest(int $red, int $green, int $blue) : int
Parameters
$red : int
$green : int
$blue : int
Return values
int

colorClosestAlpha()

public colorClosestAlpha(int $red, int $green, int $blue, int $alpha) : int
Parameters
$red : int
$green : int
$blue : int
$alpha : int
Return values
int

colorClosestHWB()

public colorClosestHWB(int $red, int $green, int $blue) : int
Parameters
$red : int
$green : int
$blue : int
Return values
int

colorDeallocate()

public colorDeallocate(int $color) : void
Parameters
$color : int

colorExact()

public colorExact(int $red, int $green, int $blue) : int
Parameters
$red : int
$green : int
$blue : int
Return values
int

colorExactAlpha()

public colorExactAlpha(int $red, int $green, int $blue, int $alpha) : int
Parameters
$red : int
$green : int
$blue : int
$alpha : int
Return values
int

colorMatch()

public colorMatch(Image $image2) : void
Parameters
$image2 : Image

colorResolve()

public colorResolve(int $red, int $green, int $blue) : int
Parameters
$red : int
$green : int
$blue : int
Return values
int

colorResolveAlpha()

public colorResolveAlpha(int $red, int $green, int $blue, int $alpha) : int
Parameters
$red : int
$green : int
$blue : int
$alpha : int
Return values
int

colorSet()

public colorSet(int $index, int $red, int $green, int $blue[, int $alpha = = '0' ]) : void
Parameters
$index : int
$red : int
$green : int
$blue : int
$alpha : int = = '0'

colorsForIndex()

public colorsForIndex(int $color) : array<string|int, mixed>
Parameters
$color : int
Return values
array<string|int, mixed>

colorsTotal()

public colorsTotal() : int
Return values
int

colorTransparent()

public colorTransparent([int|null $color = = 'null' ]) : int
Parameters
$color : int|null = = 'null'
Return values
int

convolution()

public convolution(array<string|int, mixed> $matrix, float $div, float $offset) : void
Parameters
$matrix : array<string|int, mixed>
$div : float
$offset : float

copy()

public copy(Image $src, int $dstX, int $dstY, int $srcX, int $srcY, int $srcW, int $srcH) : void
Parameters
$src : Image
$dstX : int
$dstY : int
$srcX : int
$srcY : int
$srcW : int
$srcH : int

copyMerge()

public copyMerge(Image $src, int $dstX, int $dstY, int $srcX, int $srcY, int $srcW, int $srcH, int $pct) : void
Parameters
$src : Image
$dstX : int
$dstY : int
$srcX : int
$srcY : int
$srcW : int
$srcH : int
$pct : int

copyMergeGray()

public copyMergeGray(Image $src, int $dstX, int $dstY, int $srcX, int $srcY, int $srcW, int $srcH, int $pct) : void
Parameters
$src : Image
$dstX : int
$dstY : int
$srcX : int
$srcY : int
$srcW : int
$srcH : int
$pct : int

copyResampled()

public copyResampled(Image $src, int $dstX, int $dstY, int $srcX, int $srcY, int $dstW, int $dstH, int $srcW, int $srcH) : void
Parameters
$src : Image
$dstX : int
$dstY : int
$srcX : int
$srcY : int
$dstW : int
$dstH : int
$srcW : int
$srcH : int

copyResized()

public copyResized(Image $src, int $dstX, int $dstY, int $srcX, int $srcY, int $dstW, int $dstH, int $srcW, int $srcH) : void
Parameters
$src : Image
$dstX : int
$dstY : int
$srcX : int
$srcY : int
$dstW : int
$dstH : int
$srcW : int
$srcH : int

crop()

Crops image. Arguments accepts pixels or percent.

public crop(int|string $left, int|string $top, int|string $width, int|string $height) : static
Parameters
$left : int|string
$top : int|string
$width : int|string
$height : int|string
Return values
static

cropAuto()

public cropAuto([int $mode = = 'IMG_CROP_DEFAULT' ][, float $threshold = = '.5' ][, ImageColor|null $color = = 'null' ]) : Image
Parameters
$mode : int = = 'IMG_CROP_DEFAULT'
$threshold : float = = '.5'
$color : ImageColor|null = = 'null'
Return values
Image

detectTypeFromFile()

Returns the type of image from file.

public static detectTypeFromFile(string $file[, mixed &$width = null ][, mixed &$height = null ]) : ImageType::*|null
Parameters
$file : string
$width : mixed = null
$height : mixed = null
Return values
ImageType::*|null

detectTypeFromString()

Returns the type of image from string.

public static detectTypeFromString(string $s[, mixed &$width = null ][, mixed &$height = null ]) : ImageType::*|null
Parameters
$s : string
$width : mixed = null
$height : mixed = null
Return values
ImageType::*|null

ellipse()

public ellipse(int $centerX, int $centerY, int $width, int $height, ImageColor $color) : void
Parameters
$centerX : int
$centerY : int
$width : int
$height : int
$color : ImageColor

extensionToType()

Returns the image type for given file extension.

public static extensionToType(string $extension) : ImageType::*
Parameters
$extension : string
Return values
ImageType::*

filledArc()

public filledArc(int $centerX, int $centerY, int $width, int $height, int $startAngle, int $endAngle, ImageColor $color, int $style) : void
Parameters
$centerX : int
$centerY : int
$width : int
$height : int
$startAngle : int
$endAngle : int
$color : ImageColor
$style : int

filledEllipse()

public filledEllipse(int $centerX, int $centerY, int $width, int $height, ImageColor $color) : void
Parameters
$centerX : int
$centerY : int
$width : int
$height : int
$color : ImageColor

filledPolygon()

public filledPolygon(array<string|int, mixed> $points, ImageColor $color) : void
Parameters
$points : array<string|int, mixed>
$color : ImageColor

filledRectangle()

public filledRectangle(int $x1, int $y1, int $x2, int $y2, ImageColor $color) : void
Parameters
$x1 : int
$y1 : int
$x2 : int
$y2 : int
$color : ImageColor

filledRectangleWH()

Draw a filled rectangle.

public filledRectangleWH(int $x, int $y, int $width, int $height, ImageColor $color) : void
Parameters
$x : int
$y : int
$width : int
$height : int
$color : ImageColor

filter()

public filter(int $filter, mixed ...$args) : void
Parameters
$filter : int
$args : mixed

flip()

public flip(int $mode) : void
Parameters
$mode : int

fromBlank()

Creates a new true color image of the given dimensions. The default color is black.

public static fromBlank(positive-int $width, positive-int $height[, ImageColor|array<string|int, mixed>|null $color = null ]) : static
Parameters
$width : positive-int
$height : positive-int
$color : ImageColor|array<string|int, mixed>|null = null
Tags
throws
NotSupportedException

if gd extension is not loaded

Return values
static

fromFile()

Reads an image from a file and returns its type in $type.

public static fromFile(string $file[, int|null &$type = null ]) : static
Parameters
$file : string
$type : int|null = null
Tags
throws
NotSupportedException

if gd extension is not loaded

throws
UnknownImageFileException

if file not found or file type is not known

Return values
static

fromString()

Reads an image from a string and returns its type in $type.

public static fromString(string $s[, int|null &$type = null ]) : static
Parameters
$s : string
$type : int|null = null
Tags
throws
NotSupportedException

if gd extension is not loaded

throws
ImageException
Return values
static

ftText()

public ftText(float $size, float $angle, int $x, int $y, ImageColor $color, string $fontFile, string $text[, array<string|int, mixed> $options = = '[]' ]) : array<string|int, mixed>
Parameters
$size : float
$angle : float
$x : int
$y : int
$color : ImageColor
$fontFile : string
$text : string
$options : array<string|int, mixed> = = '[]'
Return values
array<string|int, mixed>

gammaCorrect()

public gammaCorrect(float $inputgamma, float $outputgamma) : void
Parameters
$inputgamma : float
$outputgamma : float

getClip()

public getClip() : array<string|int, mixed>
Return values
array<string|int, mixed>

getHeight()

Returns image height.

public getHeight() : positive-int
Return values
positive-int

getImageResource()

Returns image GD resource.

public getImageResource() : GdImage
Return values
GdImage

getInterpolation()

public getInterpolation() : int
Return values
int

getSupportedTypes()

public static getSupportedTypes() : array<string|int, ImageType>
Return values
array<string|int, ImageType>

getWidth()

Returns image width.

public getWidth() : positive-int
Return values
positive-int

interlace()

public interlace([bool|null $enable = = 'null' ]) : int
Parameters
$enable : bool|null = = 'null'
Return values
int

isTrueColor()

public isTrueColor() : bool
Return values
bool

isTypeSupported()

public static isTypeSupported(ImageType::* $type) : bool
Parameters
$type : ImageType::*
Return values
bool

layerEffect()

public layerEffect(int $effect) : void
Parameters
$effect : int

line()

public line(int $x1, int $y1, int $x2, int $y2, ImageColor $color) : void
Parameters
$x1 : int
$y1 : int
$x2 : int
$y2 : int
$color : ImageColor

openPolygon()

public openPolygon(array<string|int, mixed> $points, ImageColor $color) : void
Parameters
$points : array<string|int, mixed>
$color : ImageColor

paletteCopy()

public paletteCopy(Image $source) : void
Parameters
$source : Image

paletteToTrueColor()

public paletteToTrueColor() : void

place()

Puts another image into this image. Left and top accepts pixels or percent.

public place(self $image[, int|string $left = 0 ][, int|string $top = 0 ][, int<0, 100> $opacity = 100 ]) : static
Parameters
$image : self
$left : int|string = 0
$top : int|string = 0
$opacity : int<0, 100> = 100

0..100

Return values
static

polygon()

public polygon(array<string|int, mixed> $points, ImageColor $color) : void
Parameters
$points : array<string|int, mixed>
$color : ImageColor

rectangle()

public rectangle(int $x1, int $y1, int $x2, int $y2, ImageColor $color) : void
Parameters
$x1 : int
$y1 : int
$x2 : int
$y2 : int
$color : ImageColor

rectangleWH()

Draw a rectangle.

public rectangleWH(int $x, int $y, int $width, int $height, ImageColor $color) : void
Parameters
$x : int
$y : int
$width : int
$height : int
$color : ImageColor

resize()

Scales an image. Width and height accept pixels or percent.

public resize(int|string|null $width, int|string|null $height[, int-mask-of $mode = self::OrSmaller ]) : static
Parameters
$width : int|string|null
$height : int|string|null
$mode : int-mask-of = self::OrSmaller
Return values
static

resolution()

public resolution([int|null $resolutionX = = 'null' ][, int|null $resolutionY = = 'null' ]) : mixed
Parameters
$resolutionX : int|null = = 'null'
$resolutionY : int|null = = 'null'

resolveColor()

public resolveColor(ImageColor|array<string|int, mixed> $color) : int
Parameters
$color : ImageColor|array<string|int, mixed>
Return values
int

rgb()

Returns RGB color (0..255) and transparency (0..127).

public static rgb(int $red, int $green, int $blue[, int $transparency = 0 ]) : array<string|int, mixed>

use ImageColor::rgb()

Parameters
$red : int
$green : int
$blue : int
$transparency : int = 0
Return values
array<string|int, mixed>

save()

Saves image to the file. Quality is in the range 0..100 for JPEG (default 85), WEBP (default 80) and AVIF (default 30) and 0..9 for PNG (default 9).

public save(string $file[, int|null $quality = null ][, ImageType::*|null $type = null ]) : void
Parameters
$file : string
$quality : int|null = null
$type : ImageType::*|null = null
Tags
throws
ImageException

saveAlpha()

public saveAlpha(bool $enable) : void
Parameters
$enable : bool

scale()

public scale(int $newWidth[, int $newHeight = = '-1' ][, int $mode = = 'IMG_BILINEAR_FIXED' ]) : Image
Parameters
$newWidth : int
$newHeight : int = = '-1'
$mode : int = = 'IMG_BILINEAR_FIXED'
Return values
Image

send()

Outputs image to browser. Quality is in the range 0..100 for JPEG (default 85), WEBP (default 80) and AVIF (default 30) and 0..9 for PNG (default 9).

public send([ImageType::* $type = ImageType::JPEG ][, int|null $quality = null ]) : void
Parameters
$type : ImageType::* = ImageType::JPEG
$quality : int|null = null
Tags
throws
ImageException

setClip()

public setClip(int $x1, int $y1, int $x2, int $y2) : void
Parameters
$x1 : int
$y1 : int
$x2 : int
$y2 : int

setInterpolation()

public setInterpolation([int $method = = 'IMG_BILINEAR_FIXED' ]) : void
Parameters
$method : int = = 'IMG_BILINEAR_FIXED'

setStyle()

public setStyle(array<string|int, mixed> $style) : void
Parameters
$style : array<string|int, mixed>

setThickness()

public setThickness(int $thickness) : void
Parameters
$thickness : int

sharpen()

Sharpens image a little bit.

public sharpen() : static
Return values
static

toString()

Outputs image to string. Quality is in the range 0..100 for JPEG (default 85), WEBP (default 80) and AVIF (default 30) and 0..9 for PNG (default 9).

public toString([ImageType::* $type = ImageType::JPEG ][, int|null $quality = null ]) : string
Parameters
$type : ImageType::* = ImageType::JPEG
$quality : int|null = null
Return values
string

trueColorToPalette()

public trueColorToPalette(bool $dither, int $ncolors) : void
Parameters
$dither : bool
$ncolors : int

ttfText()

public ttfText(float $size, float $angle, int $x, int $y, ImageColor $color, string $fontfile, string $text[, array<string|int, mixed> $options = = '[]' ]) : array<string|int, mixed>
Parameters
$size : float
$angle : float
$x : int
$y : int
$color : ImageColor
$fontfile : string
$text : string
$options : array<string|int, mixed> = = '[]'
Return values
array<string|int, mixed>

typeToExtension()

Returns the file extension for the given image type.

public static typeToExtension(ImageType::* $type) : value-of
Parameters
$type : ImageType::*
Return values
value-of

typeToMimeType()

Returns the mime type for the given image type.

public static typeToMimeType(ImageType::* $type) : string
Parameters
$type : ImageType::*
Return values
string

setImageResource()

Sets image resource.

protected setImageResource(GdImage $image) : static
Parameters
$image : GdImage
Return values
static

ensureExtension()

private static ensureExtension() : void

invokeSafe()

private static invokeSafe(string $func, string $arg, string $message, string $callee) : static
Parameters
$func : string
$arg : string
$message : string
$callee : string
Return values
static

isPercent()

private static isPercent(int|string &$num) : bool
Parameters
$num : int|string
Return values
bool

output()

Outputs image to browser or file.

private output(ImageType::* $type, int|null $quality[, string|null $file = null ]) : void
Parameters
$type : ImageType::*
$quality : int|null
$file : string|null = null
Tags
throws
ImageException

        
On this page

Search results