Overview

Namespaces

  • Budovy
  • Kdyby
    • BootstrapFormRenderer
      • DI
      • Latte
  • Nette
    • Application
      • Diagnostics
      • Responses
      • Routers
      • UI
    • Caching
      • Storages
    • ComponentModel
    • Database
      • Diagnostics
      • Drivers
      • Reflection
      • Table
    • DI
      • Config
        • Adapters
      • Diagnostics
      • Extensions
    • Diagnostics
    • Forms
      • Controls
      • Rendering
    • Http
      • Diagnostics
    • Iterators
    • Latte
      • Macros
    • Loaders
    • Localization
    • Mail
    • PhpGenerator
    • Reflection
    • Security
      • Diagnostics
    • Templating
    • Utils
  • NetteModule
  • Nextras
    • Datagrid
  • None
  • PHP
  • Tester
    • CodeCoverage
    • Runner
      • Output
  • Vodacek
    • Forms
      • Controls
  • WebLoader
    • Filter
    • Nette

Classes

  • ArrayHash
  • ArrayList
  • Configurator
  • DateTime
  • Framework
  • Image
  • Object
  • ObjectMixin

Exceptions

  • ArgumentOutOfRangeException
  • DeprecatedException
  • DirectoryNotFoundException
  • FatalErrorException
  • FileNotFoundException
  • InvalidArgumentException
  • InvalidStateException
  • IOException
  • MemberAccessException
  • NotImplementedException
  • NotSupportedException
  • OutOfRangeException
  • StaticClassException
  • UnexpectedValueException
  • UnknownImageFileException
  • Overview
  • Namespace
  • Class
  • Tree

Class Image

Basic manipulation with images.

$image = Image::fromFile('nette.jpg');
$image->resize(150, 100);
$image->sharpen();
$image->send();
Nette\Object
Extended by Nette\Image
Namespace: Nette
Author: David Grudl
Located at vendor/nette/nette/Nette/common/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
integer
red 0..255
$green
integer
green 0..255
$blue
integer
blue 0..255
$transparency
integer
transparency 0..127

Returns

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

Opens image from file.

Opens image from file.

Parameters

$file
string
$format
mixed
detected image format

Returns

Nette\Image
public static mixed
# getFormatFromString( string $s )

Get format from the image stream in the string.

Get format from the image stream in the string.

Parameters

$s
string

Returns

mixed
detected image format
public static Nette\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
string
$format
mixed
detected image format

Returns

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

Creates blank image.

Creates blank image.

Parameters

$width
integer
$height
integer
$color
array

Returns

Nette\Image
public
# __construct( resource $image )

Wraps GD image.

Wraps GD image.

Parameters

$image
resource
public integer
# getWidth( )

Returns image width.

Returns image width.

Returns

integer
public integer
# getHeight( )

Returns image height.

Returns image height.

Returns

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

Sets image resource.

Sets image resource.

Parameters

$image
resource

Returns

Nette\Image
public resource
# getImageResource( )

Returns image GD resource.

Returns image GD resource.

Returns

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

Resizes image.

Resizes image.

Parameters

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

Returns

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

Calculates dimensions of resized image.

Calculates dimensions of resized image.

Parameters

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

Returns

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

Crops image.

Crops image.

Parameters

$left
mixed
x-offset in pixels or percent
$top
mixed
y-offset in pixels or percent
$width
mixed
width in pixels or percent
$height
mixed
height in pixels or percent

Returns

Nette\Image
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
mixed
source width
$srcHeight
mixed
source height
$left
mixed
x-offset in pixels or percent
$top
mixed
y-offset in pixels or percent
$newWidth
mixed
width in pixels or percent
$newHeight
mixed
height in pixels or percent

Returns

array
public Nette\Image
# sharpen( )

Sharpen image.

Sharpen image.

Returns

Nette\Image
public Nette\Image
# place( Nette\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
Nette\Image
$left
mixed
x-coordinate in pixels or percent
$top
mixed
y-coordinate in pixels or percent
$opacity
integer
opacity 0..100

Returns

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

Saves image to the file.

Saves image to the file.

Parameters

$file
string
filename
$quality
integer
quality 0..100 (for JPEG and PNG)
$type
integer
optional image type

Returns

boolean
TRUE on success or FALSE on failure.
public string
# toString( integer $type = Nette\Image::JPEG, integer $quality = NULL )

Outputs image to string.

Outputs image to string.

Parameters

$type
integer
image type
$quality
integer
quality 0..100 (for JPEG and PNG)

Returns

string
public string
# __toString( )

Outputs image to string.

Outputs image to string.

Returns

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

Outputs image to browser.

Outputs image to browser.

Parameters

$type
integer
image type
$quality
integer
quality 0..100 (for JPEG and 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
string
method name
$args
array
arguments

Returns

mixed

Throws

Nette\MemberAccessException

Overrides

Nette\Object::__call()
Methods inherited from Nette\Object
__callStatic(), __get(), __isset(), __set(), __unset(), extensionMethod(), getReflection()
Magic methods summary
public
# alphaBlending( boolean $on = )

Parameters

$on
boolean
$on
public
# antialias( boolean $on = )

Parameters

$on
boolean
$on
public
# arc( mixed $x = , mixed $y = , mixed $w = , mixed $h = , mixed $s = , mixed $e = , mixed $color = )

Parameters

$x
mixed
$x
$y
mixed
$y
$w
mixed
$w
$h
mixed
$h
$s
mixed
$s
$e
mixed
$e
$color
mixed
$color
public
# char( mixed $font = , mixed $x = , mixed $y = , mixed $char = , mixed $color = )

Parameters

$font
mixed
$font
$x
mixed
$x
$y
mixed
$y
$char
mixed
$char
$color
mixed
$color
public
# charUp( mixed $font = , mixed $x = , mixed $y = , mixed $char = , mixed $color = )

Parameters

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

Parameters

$red
mixed
$red
$green
mixed
$green
$blue
mixed
$blue

Returns

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

Parameters

$red
mixed
$red
$green
mixed
$green
$blue
mixed
$blue
$alpha
mixed
$alpha

Returns

integer
public integer
# colorAt( mixed $x = , mixed $y = )

Parameters

$x
mixed
$x
$y
mixed
$y

Returns

integer
public integer
# colorClosest( mixed $red = , mixed $green = , mixed $blue = )

Parameters

$red
mixed
$red
$green
mixed
$green
$blue
mixed
$blue

Returns

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

Parameters

$red
mixed
$red
$green
mixed
$green
$blue
mixed
$blue
$alpha
mixed
$alpha

Returns

integer
public integer
# colorClosestHWB( mixed $red = , mixed $green = , mixed $blue = )

Parameters

$red
mixed
$red
$green
mixed
$green
$blue
mixed
$blue

Returns

integer
public
# colorDeallocate( mixed $color = )

Parameters

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

Parameters

$red
mixed
$red
$green
mixed
$green
$blue
mixed
$blue

Returns

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

Parameters

$red
mixed
$red
$green
mixed
$green
$blue
mixed
$blue
$alpha
mixed
$alpha

Returns

integer
public
# colorMatch( Nette\Image $image2 = )

Parameters

$image2
Nette\Image
$image2
public integer
# colorResolve( mixed $red = , mixed $green = , mixed $blue = )

Parameters

$red
mixed
$red
$green
mixed
$green
$blue
mixed
$blue

Returns

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

Parameters

$red
mixed
$red
$green
mixed
$green
$blue
mixed
$blue
$alpha
mixed
$alpha

Returns

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

Parameters

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

Parameters

$index
mixed
$index

Returns

array
public integer
# colorsTotal( )

Returns

integer
public integer
# colorTransparent( )

Returns

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

Parameters

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

Parameters

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

Parameters

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

Parameters

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

Parameters

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

Parameters

$src
Nette\Image
$src
$dstX
mixed
$dstX
$dstY
mixed
$dstY
$srcX
mixed
$srcX
$srcY
mixed
$srcY
$dstW
mixed
$dstW
$dstH
mixed
$dstH
$srcW
mixed
$srcW
$srcH
mixed
$srcH
public
# dashedLine( mixed $x1 = , mixed $y1 = , mixed $x2 = , mixed $y2 = , mixed $color = )

Parameters

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

Parameters

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

Parameters

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

Parameters

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

Parameters

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

Parameters

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

Parameters

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

Parameters

$x
mixed
$x
$y
mixed
$y
$border
mixed
$border
$color
mixed
$color
public
# filter( )
public integer
# fontHeight( mixed $font = )

Parameters

$font
mixed
$font

Returns

integer
public integer
# fontWidth( mixed $font = )

Parameters

$font
mixed
$font

Returns

integer
public array
# ftBBox( mixed $size = , mixed $angle = , string $fontFile = )

Parameters

$size
mixed
$size
$angle
mixed
$angle
$fontFile
string
$fontFile

Returns

array
public array
# ftText( mixed $size = , mixed $angle = , mixed $x = , mixed $y = , mixed $col = , string $fontFile = )

Parameters

$size
mixed
$size
$angle
mixed
$angle
$x
mixed
$x
$y
mixed
$y
$col
mixed
$col
$fontFile
string
$fontFile

Returns

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

Parameters

$inputgamma
float
$inputgamma
$outputgamma
float
$outputgamma
public integer
# interlace( )

Returns

integer
public boolean
# isTrueColor( )

Returns

boolean
public
# layerEffect( mixed $effect = )

Parameters

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

Parameters

$x1
mixed
$x1
$y1
mixed
$y1
$x2
mixed
$x2
$y2
mixed
$y2
$color
mixed
$color
public integer
# loadFont( string $file = )

Parameters

$file
string
$file

Returns

integer
public
# paletteCopy( Nette\Image $source = )

Parameters

$source
Nette\Image
$source
public
# polygon( array $points = , mixed $numPoints = , mixed $color = )

Parameters

$points
array
$points
$numPoints
mixed
$numPoints
$color
mixed
$color
public array
# psBBox( string $text = , mixed $font = )

Parameters

$text
string
$text
$font
mixed
$font

Returns

array
public
# psEncodeFont( mixed $fontIndex = , string $encodingfile = )

Parameters

$fontIndex
mixed
$fontIndex
$encodingfile
string
$encodingfile
public
# psExtendFont( mixed $fontIndex = , float $extend = )

Parameters

$fontIndex
mixed
$fontIndex
$extend
float
$extend
public
# psFreeFont( mixed $fontindex = )

Parameters

$fontindex
mixed
$fontindex
public resource
# psLoadFont( string $filename = )

Parameters

$filename
string
$filename

Returns

resource
public
# psSlantFont( mixed $fontIndex = , float $slant = )

Parameters

$fontIndex
mixed
$fontIndex
$slant
float
$slant
public array
# psText( string $text = , mixed $font = , mixed $size = , mixed $color = , mixed $backgroundColor = , mixed $x = )

Parameters

$text
string
$text
$font
mixed
$font
$size
mixed
$size
$color
mixed
$color
$backgroundColor
mixed
$backgroundColor
$x
mixed
$x

Returns

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

Parameters

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

Parameters

$angle
float
$angle
$backgroundColor
mixed
$backgroundColor

Returns

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

Parameters

$saveflag
boolean
$saveflag
public
# setBrush( Nette\Image $brush = )

Parameters

$brush
Nette\Image
$brush
public
# setPixel( mixed $x = , mixed $y = , mixed $color = )

Parameters

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

Parameters

$style
array
$style
public
# setThickness( mixed $thickness = )

Parameters

$thickness
mixed
$thickness
public
# setTile( Nette\Image $tile = )

Parameters

$tile
Nette\Image
$tile
public
# string( mixed $font = , mixed $x = , mixed $y = , string $s = , mixed $col = )

Parameters

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

Parameters

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

Parameters

$dither
boolean
$dither
$ncolors
mixed
$ncolors
public array
# ttfBBox( mixed $size = , mixed $angle = , string $fontfile = , string $text = )

Parameters

$size
mixed
$size
$angle
mixed
$angle
$fontfile
string
$fontfile
$text
string
$text

Returns

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

Parameters

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

Returns

array
public integer
# types( )

Returns

integer
Constants summary
integer SHRINK_ONLY 1
#

Nette\Image::resize() only shrinks images

Nette\Image::resize() only shrinks images

integer STRETCH 2
#

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

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

integer FIT 0
#

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

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

integer FILL 4
#

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

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

integer EXACT 8
#

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

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

integer JPEG IMAGETYPE_JPEG
#

Int

image types Nette\Image::send()
integer PNG IMAGETYPE_PNG
#

Int

image types Nette\Image::send()
integer GIF IMAGETYPE_GIF
#

Int

image types Nette\Image::send()
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
#
Magic properties inherited from Nette\Object
$reflection
API documentation generated by ApiGen 2.8.0