Packages

  • Nette
    • Application
      • Diagnostics
      • Responses
      • Routers
      • UI
    • Caching
      • Storages
    • ComponentModel
    • Config
      • Adapters
      • Extensions
    • Database
      • Diagnostics
      • Drivers
      • Reflection
      • Table
    • DI
      • Diagnostics
    • Diagnostics
    • Forms
      • Controls
      • Rendering
    • Http
    • Iterators
    • Latte
      • Macros
    • Loaders
    • Localization
    • Mail
    • Reflection
    • Security
      • Diagnostics
    • Templating
    • Utils
      • PhpGenerator
  • NetteModule
  • None
  • PHP

Classes

  • NArrayHash
  • NArrayList
  • NCallback
  • NDateTime53
  • NFramework
  • NFreezableObject
  • NImage
  • NObject
  • NObjectMixin

Interfaces

  • IFreezable

Exceptions

  • ArgumentOutOfRangeException
  • DeprecatedException
  • DirectoryNotFoundException
  • FatalErrorException
  • FileNotFoundException
  • InvalidStateException
  • IOException
  • MemberAccessException
  • NotImplementedException
  • NotSupportedException
  • NStaticClassException
  • NUnknownImageFileException
  • Overview
  • Package
  • Class
  • Tree

Class NImage

Basic manipulation with images.

$image = NImage::fromFile('nette.jpg');
$image->resize(150, 100);
$image->sharpen();
$image->send();
NObject
Extended by NImage
Package: Nette
Author: David Grudl
Located at 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 NImage
# fromFile( string $file, mixed & $format = NULL )

Opens image from file.

Opens image from file.

Parameters

$file
string
$format
mixed
detected image format

Returns

NImage
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 NImage
# 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

NImage
public static NImage
# fromBlank( integer $width, integer $height, array $color = NULL )

Creates blank image.

Creates blank image.

Parameters

$width
integer
$height
integer
$color
array

Returns

NImage
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 NImage
# setImageResource( resource $image )

Sets image resource.

Sets image resource.

Parameters

$image
resource

Returns

NImage
provides a fluent interface
public resource
# getImageResource( )

Returns image GD resource.

Returns image GD resource.

Returns

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

Resizes image.

Resizes image.

Parameters

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

Returns

NImage
provides a fluent interface
public static array
# calculateSize( mixed $srcWidth, mixed $srcHeight, mixed $newWidth, mixed $newHeight, integer $flags = NImage::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 NImage
# 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

NImage
provides a fluent interface
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 NImage
# sharpen( )

Sharpen image.

Sharpen image.

Returns

NImage
provides a fluent interface
public NImage
# place( NImage $image, mixed $left = 0, mixed $top = 0, integer $opacity = 100 )

Puts another image into this image.

Puts another image into this image.

Parameters

$image
NImage
$left
mixed
x-coordinate in pixels or percent
$top
mixed
y-coordinate in pixels or percent
$opacity
integer
opacity 0..100

Returns

NImage
provides a fluent interface
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 = NImage::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 = NImage::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

MemberAccessException

Overrides

NObject::__call
Methods inherited from NObject
__callStatic(), __get(), __isset(), __set(), __unset(), extensionMethod(), getReflection()
Constants summary
integer SHRINK_ONLY 1
#

NImage::resize() only shrinks images

NImage::resize() only shrinks images

integer STRETCH 2
#

NImage::resize() will ignore aspect ratio

NImage::resize() will ignore aspect ratio

integer FIT 0
#

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

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

integer FILL 4
#

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

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

integer EXACT 8
#

NImage::resize() fills given area exactly

NImage::resize() fills given area exactly

integer JPEG IMAGETYPE_JPEG
#

Int

image types NImage::send()
integer PNG IMAGETYPE_PNG
#

Int

image types NImage::send()
integer GIF IMAGETYPE_GIF
#

Int

image types NImage::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;"
#
Nette Framework 2.0.4 (for PHP 5.2, prefixed) API API documentation generated by ApiGen 2.7.0