Class Image (namespace Nette)


Basic manipulation with images.

  1. 1:  $image Image::fromFile('nette.jpg');
  2. 2:  $image->resize(150100);
  3. 3:  $image->sharpen();
  4. 4:  $image->send();

Object
   |
   --Image

Direct Known Sub-classes:

Author: David Grudl
Copyright: Copyright (c) 2004, 2009 David Grudl
Located: in /Image.php (line 41)
Public Method Summary
Image
__construct (resource $image)
Wraps GD image.
array
calculateSize (mixed $newWidth, mixed $newHeight, [int $flags = 0])
Calculates dimensions of resized image.
Image
crop (int $left, int $top, int $width, int $height)
Crops image.
static Image
fromBlank (int $width, int $height, [array $color = NULL])
Creates blank image.
static Image
fromFile (string $file, [mixed &$format = NULL])
Opens image from file.
static Image
fromString (string $s)
Create a new image from the image stream in the string.
int
Returns image height.
resource
Returns image GD resource.
int
Returns image width.
Image
place (Image $image, [mixed $left = 0], [mixed $top = 0], [int $opacity = 100])
Puts another image into this image.
Image
resize (mixed $newWidth, mixed $newHeight, [int $flags = 0])
Resizes image.
static array
rgb (int $red, int $green, int $blue, [int $transparency = 0])
Returns RGB color.
bool
save ([string $file = NULL], [int $quality = NULL], [int $type = NULL])
Saves image to the file.
bool
send ([int $type = self::JPEG], [int $quality = NULL])
Outputs image to browser.
Image
sharpen ()
Sharpen image.
string
toString ([int $type = self::JPEG], [int $quality = NULL])
Outputs image to string.
mixed
__call (string $name, array $args)
Call to undefined method.
string
Outputs image to string.
Protected Method Summary
protected void
setImageResource (resource $image)
Sets image resource.
Methods Inherited From Object
extensionMethod(), getClass(), getReflection(), __call(), __callStatic(), __get(), __isset(), __set(), __unset()
Constant Summary
string EMPTY_GIF ...

line 54

int ENLARGE 1

line 44

resizing flags resize()
string GIF IMAGETYPE_GIF

line 51

string JPEG IMAGETYPE_JPEG

line 49

string PNG IMAGETYPE_PNG

line 50

int STRETCH 2

line 45

resizing flags resize()
Variable Summary
static bool $useImageMagick FALSE

line 57


Method Details

line 166

__construct

public Image __construct (resource $image)

Wraps GD image.

Overridden in child classes as:

Input
resource $image
Output
Image  

line 246

calculateSize

public array calculateSize (mixed $newWidth, mixed $newHeight, [int $flags = 0])

Calculates dimensions of resized image.

Input
mixed $newWidth width in pixels or percent
mixed $newHeight height in pixels or percent
int $flags flags
Output
array  

line 312

crop

public Image crop (int $left, int $top, int $width, int $height)

Crops image.

Overridden in child classes as:

Input
int $left x-coordinate
int $top y-coordinate
int $width width
int $height height
Output
Image provides a fluent interface

line 140

fromBlank

public static Image fromBlank (int $width, int $height, [array $color = NULL])

Creates blank image.

Input
int $width
int $height
array $color
Output
Image  

line 90

fromFile

public static Image fromFile (string $file, [mixed &$format = NULL])

Opens image from file.

Input
string $file
mixed &$format detected image format
Output
Image  

line 126

fromString

public static Image fromString (string $s)

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

Input
string $s
Output
Image  

line 188

getHeight

public int getHeight ()

Returns image height.

Overridden in child classes as:

Output
int  

line 214

getImageResource

public resource getImageResource ()

Returns image GD resource.

Overridden in child classes as:

Output
resource  

line 177

getWidth

public int getWidth ()

Returns image width.

Overridden in child classes as:

Output
int  

line 351

place

public Image place (Image $image, [mixed $left = 0], [mixed $top = 0], [int $opacity = 100])

Puts another image into this image.

Input
Image $image
mixed $left x-coordinate in pixels or percent
mixed $top y-coordinate in pixels or percent
int $opacity opacity 0..100
Output
Image provides a fluent interface

line 228

resize

public Image resize (mixed $newWidth, mixed $newHeight, [int $flags = 0])

Resizes image.

Overridden in child classes as:

Input
mixed $newWidth width in pixels or percent
mixed $newHeight height in pixels or percent
int $flags flags
Output
Image provides a fluent interface

line 72

rgb

public static array rgb (int $red, int $green, int $blue, [int $transparency = 0])

Returns RGB color.

Input
int $red red 0..255
int $green green 0..255
int $blue blue 0..255
int $transparency transparency 0..127
Output
array  

line 381

save

public bool save ([string $file = NULL], [int $quality = NULL], [int $type = NULL])

Saves image to the file.

Overridden in child classes as:

Input
string $file filename
int $quality quality 0..100 (for JPEG and PNG)
int $type optional image type
Output
bool TRUE on success or FALSE on failure.

line 454

send

public bool send ([int $type = self::JPEG], [int $quality = NULL])

Outputs image to browser.

Input
int $type image type
int $quality quality 0..100 (for JPEG and PNG)
Output
bool TRUE on success or FALSE on failure.

line 200

setImageResource

protected void setImageResource (resource $image)

Sets image resource.

Input
resource $image
Output
void  

line 331

sharpen

public Image sharpen ()

Sharpen image.

Output
Image provides a fluent interface

line 422

toString

public string toString ([int $type = self::JPEG], [int $quality = NULL])

Outputs image to string.

Input
int $type image type
int $quality quality 0..100 (for JPEG and PNG)
Output
string  

line 473

__call

public mixed __call (string $name, array $args)

Call to undefined method.

Input
string $name method name
array $args arguments
Output
mixed  
Throws
throws MemberAccessException

line 435

__toString

public string __toString ()

Outputs image to string.

Output
string