Namespaces

  • Latte
    • Loaders
    • Macros
    • Runtime
  • Nette
    • Application
      • Responses
      • Routers
      • UI
    • Bridges
      • ApplicationDI
      • ApplicationLatte
      • ApplicationTracy
      • CacheDI
      • CacheLatte
      • DatabaseDI
      • DatabaseTracy
      • DITracy
      • FormsDI
      • FormsLatte
      • Framework
      • HttpDI
      • HttpTracy
      • MailDI
      • ReflectionDI
      • SecurityDI
      • SecurityTracy
    • Caching
      • Storages
    • ComponentModel
    • Database
      • Conventions
      • Drivers
      • Table
    • DI
      • Config
        • Adapters
      • Extensions
    • Forms
      • Controls
      • Rendering
    • Http
    • Iterators
    • Loaders
    • Localization
    • Mail
    • Neon
    • PhpGenerator
      • Traits
    • Reflection
    • Security
    • Tokenizer
    • Utils
  • Tracy
    • Bridges
      • Nette
  • none

Classes

  • ArrayHash
  • ArrayList
  • Arrays
  • Callback
  • DateTime
  • FileSystem
  • Finder
  • Html
  • Image
  • Json
  • ObjectHelpers
  • ObjectMixin
  • Paginator
  • Random
  • Reflection
  • SafeStream
  • Strings
  • TokenIterator
  • Tokenizer
  • Validators

Interfaces

  • IHtmlString

Exceptions

  • AssertionException
  • ImageException
  • JsonException
  • RegexpException
  • TokenizerException
  • UnknownImageFileException
  • Overview
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Other releases

Class Image

Basic manipulation with images.

$image = Image::fromFile('nette.jpg');
$image->resize(150, 100);
$image->sharpen();
$image->send();
Nette\Utils\Image uses Nette\SmartObject
Namespace: Nette\Utils
Located at Utils/Image.php
Methods summary
public static array
# rgb( integer $red, integer $green, integer $blue, integer $transparency = 0 )

Returns RGB color.

Returns RGB color.

Parameters

$red
0..255
$green
0..255
$blue
0..255
$transparency
0..127

Returns

array
array
public static Nette\Utils\Image
# fromFile( string $file, mixed & $format = null )

Opens image from file.

Opens image from file.

Parameters

$file
$format
image format

Returns

Nette\Utils\Image
static

Throws

Nette\NotSupportedException
if gd extension is not loaded
Nette\Utils\UnknownImageFileException
if file not found or file type is not known
public static Nette\Utils\Image
# fromString( string $s, mixed & $format = null )

Create a new image from the image stream in the string.

Create a new image from the image stream in the string.

Parameters

$s
$format
image format

Returns

Nette\Utils\Image
static

Throws

Nette\Utils\ImageException
ImageException
public static Nette\Utils\Image
# fromBlank( integer $width, integer $height, array $color = null )

Creates blank image.

Creates blank image.

Parameters

$width
$height
$color

Returns

Nette\Utils\Image
static
public
# __construct( resource $image )

Wraps GD image.

Wraps GD image.

Parameters

$image
public integer
# getWidth( )

Returns image width.

Returns image width.

Returns

integer
int
public integer
# getHeight( )

Returns image height.

Returns image height.

Returns

integer
int
protected Nette\Utils\Image
# setImageResource( resource $image )

Sets image resource.

Sets image resource.

Parameters

$image

Returns

Nette\Utils\Image
static
public resource
# getImageResource( )

Returns image GD resource.

Returns image GD resource.

Returns

resource
resource
public Nette\Utils\Image
# resize( mixed $width, mixed $height, integer $flags = Nette\Utils\Image::FIT )

Resizes image.

Resizes image.

Parameters

$width
in pixels or percent
$height
in pixels or percent
$flags
flags

Returns

Nette\Utils\Image
static
public static array
# calculateSize( mixed $srcWidth, mixed $srcHeight, mixed $newWidth, mixed $newHeight, integer $flags = Nette\Utils\Image::FIT )

Calculates dimensions of resized image.

Calculates dimensions of resized image.

Parameters

$srcWidth
width
$srcHeight
height
$newWidth
in pixels or percent
$newHeight
in pixels or percent
$flags
flags

Returns

array
array
public Nette\Utils\Image
# crop( mixed $left, mixed $top, mixed $width, mixed $height )

Crops image.

Crops image.

Parameters

$left
in pixels or percent
$top
in pixels or percent
$width
in pixels or percent
$height
in pixels or percent

Returns

Nette\Utils\Image
static
public static array
# calculateCutout( mixed $srcWidth, mixed $srcHeight, mixed $left, mixed $top, mixed $newWidth, mixed $newHeight )

Calculates dimensions of cutout in image.

Calculates dimensions of cutout in image.

Parameters

$srcWidth
width
$srcHeight
height
$left
in pixels or percent
$top
in pixels or percent
$newWidth
in pixels or percent
$newHeight
in pixels or percent

Returns

array
array
public Nette\Utils\Image
# sharpen( )

Sharpen image.

Sharpen image.

Returns

Nette\Utils\Image
static
public Nette\Utils\Image
# place( Nette\Utils\Image $image, mixed $left = 0, mixed $top = 0, integer $opacity = 100 )

Puts another image into this image.

Puts another image into this image.

Parameters

$image
$left
in pixels or percent
$top
in pixels or percent
$opacity
0..100

Returns

Nette\Utils\Image
static
public boolean
# save( string $file = null, integer $quality = null, integer $type = null )

Saves image to the file.

Saves image to the file.

Parameters

$file
filename
$quality
(0..100 for JPEG and WEBP, 0..9 for PNG)
$type
image type

Returns

boolean
true on success or false on failure.
public string
# toString( integer $type = Nette\Utils\Image::JPEG, integer $quality = null )

Outputs image to string.

Outputs image to string.

Parameters

$type
type
$quality
(0..100 for JPEG and WEBP, 0..9 for PNG)

Returns

string
string
public string
# __toString( )

Outputs image to string.

Outputs image to string.

Returns

string
string
public boolean
# send( integer $type = Nette\Utils\Image::JPEG, integer $quality = null )

Outputs image to browser.

Outputs image to browser.

Parameters

$type
type
$quality
(0..100 for JPEG and WEBP, 0..9 for PNG)

Returns

boolean
true on success or false on failure.
public mixed
# __call( string $name, array $args )

Call to undefined method.

Call to undefined method.

Parameters

$name
name
$args
arguments

Returns

mixed
mixed

Throws

Nette\MemberAccessException
Nette\MemberAccessException
public
# __clone( )
public
# __sleep( )

Prevents serialization.

Prevents serialization.

Methods used from Nette\SmartObject
__callStatic(), __get(), __isset(), __set(), __unset(), extensionMethod(), getReflection()
Magic methods summary
public
# alphaBlending( boolean $on )

Parameters

$on
public
# antialias( boolean $on )

Parameters

$on
public
# arc( $x, $y, $w, $h, $start, $end, $color )

Parameters

$x
$y
$w
$h
$start
$end
$color
public
# char( integer $font, $x, $y, string $char, $color )

Parameters

$font
$x
$y
$char
$color
public
# charUp( integer $font, $x, $y, string $char, $color )

Parameters

$font
$x
$y
$char
$color
public integer
# colorAllocate( $red, $green, $blue )

Parameters

$red
$green
$blue

Returns

integer
int
public integer
# colorAllocateAlpha( $red, $green, $blue, $alpha )

Parameters

$red
$green
$blue
$alpha

Returns

integer
int
public integer
# colorAt( $x, $y )

Parameters

$x
$y

Returns

integer
int
public integer
# colorClosest( $red, $green, $blue )

Parameters

$red
$green
$blue

Returns

integer
int
public integer
# colorClosestAlpha( $red, $green, $blue, $alpha )

Parameters

$red
$green
$blue
$alpha

Returns

integer
int
public integer
# colorClosestHWB( $red, $green, $blue )

Parameters

$red
$green
$blue

Returns

integer
int
public
# colorDeallocate( $color )

Parameters

$color
public integer
# colorExact( $red, $green, $blue )

Parameters

$red
$green
$blue

Returns

integer
int
public integer
# colorExactAlpha( $red, $green, $blue, $alpha )

Parameters

$red
$green
$blue
$alpha

Returns

integer
int
public
# colorMatch( Nette\Utils\Image $image2 )

Parameters

$image2
public integer
# colorResolve( $red, $green, $blue )

Parameters

$red
$green
$blue

Returns

integer
int
public integer
# colorResolveAlpha( $red, $green, $blue, $alpha )

Parameters

$red
$green
$blue
$alpha

Returns

integer
int
public
# colorSet( $index, $red, $green, $blue )

Parameters

$index
$red
$green
$blue
public array
# colorsForIndex( $index )

Parameters

$index

Returns

array
array
public integer
# colorsTotal( )

Returns

integer
int
public integer
# colorTransparent( $color = null )

Parameters

$color

Returns

integer
int
public
# convolution( array $matrix, float $div, float $offset )

Parameters

$matrix
$div
$offset
public
# copy( Nette\Utils\Image $src, $dstX, $dstY, $srcX, $srcY, $srcW, $srcH )

Parameters

$src
$dstX
$dstY
$srcX
$srcY
$srcW
$srcH
public
# copyMerge( Nette\Utils\Image $src, $dstX, $dstY, $srcX, $srcY, $srcW, $srcH, $opacity )

Parameters

$src
$dstX
$dstY
$srcX
$srcY
$srcW
$srcH
$opacity
public
# copyMergeGray( Nette\Utils\Image $src, $dstX, $dstY, $srcX, $srcY, $srcW, $srcH, $opacity )

Parameters

$src
$dstX
$dstY
$srcX
$srcY
$srcW
$srcH
$opacity
public
# copyResampled( Nette\Utils\Image $src, $dstX, $dstY, $srcX, $srcY, $dstW, $dstH, $srcW, $srcH )

Parameters

$src
$dstX
$dstY
$srcX
$srcY
$dstW
$dstH
$srcW
$srcH
public
# copyResized( Nette\Utils\Image $src, $dstX, $dstY, $srcX, $srcY, $dstW, $dstH, $srcW, $srcH )

Parameters

$src
$dstX
$dstY
$srcX
$srcY
$dstW
$dstH
$srcW
$srcH
public Nette\Utils\Image
# cropAuto( integer $mode = -1, float $threshold = .5, integer $color = -1 )

Parameters

$mode
$threshold
$color

Returns

Nette\Utils\Image
Image
public
# dashedLine( $x1, $y1, $x2, $y2, $color )

Parameters

$x1
$y1
$x2
$y2
$color
public
# ellipse( $cx, $cy, $w, $h, $color )

Parameters

$cx
$cy
$w
$h
$color
public
# fill( $x, $y, $color )

Parameters

$x
$y
$color
public
# filledArc( $cx, $cy, $w, $h, $s, $e, $color, $style )

Parameters

$cx
$cy
$w
$h
$s
$e
$color
$style
public
# filledEllipse( $cx, $cy, $w, $h, $color )

Parameters

$cx
$cy
$w
$h
$color
public
# filledPolygon( array $points, $numPoints, $color )

Parameters

$points
$numPoints
$color
public
# filledRectangle( $x1, $y1, $x2, $y2, $color )

Parameters

$x1
$y1
$x2
$y2
$color
public
# fillToBorder( $x, $y, $border, $color )

Parameters

$x
$y
$border
$color
public
# filter( $filtertype )

Parameters

$filtertype
public
# flip( integer $mode )

Parameters

$mode
public array
# ftText( $size, $angle, $x, $y, $col, string $fontFile, string $text, array $extrainfo = null )

Parameters

$size
$angle
$x
$y
$col
$fontFile
$text
$extrainfo

Returns

array
array
public
# gammaCorrect( float $inputgamma, float $outputgamma )

Parameters

$inputgamma
$outputgamma
public integer
# interlace( $interlace = null )

Parameters

$interlace

Returns

integer
int
public boolean
# isTrueColor( )

Returns

boolean
bool
public
# layerEffect( $effect )

Parameters

$effect
public
# line( $x1, $y1, $x2, $y2, $color )

Parameters

$x1
$y1
$x2
$y2
$color
public
# paletteCopy( Nette\Utils\Image $source )

Parameters

$source
public
# paletteToTrueColor( )
public
# polygon( array $points, $numPoints, $color )

Parameters

$points
$numPoints
$color
public array
# psText( string $text, $font, $size, $color, $backgroundColor, $x, $y, $space = null, $tightness = null, float $angle = null, $antialiasSteps = null )

Parameters

$text
$font
$size
$color
$backgroundColor
$x
$y
$space
$tightness
$angle
$antialiasSteps

Returns

array
array
public
# rectangle( $x1, $y1, $x2, $y2, $col )

Parameters

$x1
$y1
$x2
$y2
$col
public Nette\Utils\Image
# rotate( float $angle, $backgroundColor )

Parameters

$angle
$backgroundColor

Returns

Nette\Utils\Image
Image
public
# saveAlpha( boolean $saveflag )

Parameters

$saveflag
public Nette\Utils\Image
# scale( integer $newWidth, integer $newHeight = -1, integer $mode = IMG_BILINEAR_FIXED )

Parameters

$newWidth
$newHeight
$mode

Returns

Nette\Utils\Image
Image
public
# setBrush( Nette\Utils\Image $brush )

Parameters

$brush
public
# setPixel( $x, $y, $color )

Parameters

$x
$y
$color
public
# setStyle( array $style )

Parameters

$style
public
# setThickness( $thickness )

Parameters

$thickness
public
# setTile( Nette\Utils\Image $tile )

Parameters

$tile
public
# string( $font, $x, $y, string $s, $col )

Parameters

$font
$x
$y
$s
$col
public
# stringUp( $font, $x, $y, string $s, $col )

Parameters

$font
$x
$y
$s
$col
public
# trueColorToPalette( boolean $dither, $ncolors )

Parameters

$dither
$ncolors
public array
# ttfText( $size, $angle, $x, $y, $color, string $fontfile, string $text )

Parameters

$size
$angle
$x
$y
$color
$fontfile
$text

Returns

array
array
Constants summary
integer SHRINK_ONLY

Nette\Utils\Image::resize() only shrinks images

Nette\Utils\Image::resize() only shrinks images

#0b0001
integer STRETCH

Nette\Utils\Image::resize() will ignore aspect ratio

Nette\Utils\Image::resize() will ignore aspect ratio

#0b0010
integer FIT

Nette\Utils\Image::resize() fits in given area so its dimensions are less than or equal to the required dimensions

Nette\Utils\Image::resize() fits in given area so its dimensions are less than or equal to the required dimensions

#0b0000
integer FILL

Nette\Utils\Image::resize() fills given area so its dimensions are greater than or equal to the required dimensions

Nette\Utils\Image::resize() fills given area so its dimensions are greater than or equal to the required dimensions

#0b0100
integer EXACT

Nette\Utils\Image::resize() fills given area exactly

Nette\Utils\Image::resize() fills given area exactly

#0b1000
integer JPEG

image types

image types

#IMAGETYPE_JPEG
integer PNG

image types

image types

#IMAGETYPE_PNG
integer GIF

image types

image types

#IMAGETYPE_GIF
integer WEBP

image types

image types

#18
string EMPTY_GIF
#"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;"
Magic properties summary
public read-only integer $width
public read-only integer $height
public read-only resource $imageResource
Nette 2.4-20180918 API API documentation generated by ApiGen 2.8.0