Class NImage
Basic manipulation with images.
$image = NImage::fromFile('nette.jpg'); $image->resize(150, 100); $image->sharpen(); $image->send();
- NObject
-
NImage
public static
array
|
#
rgb(
int
$red,
int
$green,
int
$blue,
int
$transparency = 0
)
Returns RGB color. Returns RGB color. Parameters$red int red 0..255$green int green 0..255$blue int blue 0..255$transparency int transparency 0..127 |
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 |
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 stringReturnsmixed 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 |
public static
NImage
|
#
fromBlank(
int
$width,
int
$height,
array
$color = NULL
)
Creates blank image. Creates blank image. Parameters$width int$height int$color array |
public
|
#
__construct(
resource
$image
)
Wraps GD image. Wraps GD image. Parameters$image resource |
public
int
|
#
getWidth(
)
Returns image width. Returns image width. |
public
int
|
#
getHeight(
)
Returns image height. Returns image height. |
protected
NImage
|
#
setImageResource(
resource
$image
)
Sets image resource. Sets image resource. Parameters$image resourceReturnsNImage provides a fluent interface
|
public
resource
|
#
getImageResource(
)
Returns image GD resource. Returns image GD resource. |
public
NImage
|
#
resize(
mixed
$width,
mixed
$height,
int
$flags = 0
)
Resizes image. Resizes image. Parameters$width mixed width in pixels or percent$height mixed height in pixels or percent$flags int flagsReturnsNImage provides a fluent interface
|
public static
array
|
#
calculateSize(
mixed
$srcWidth,
mixed
$srcHeight,
mixed
$newWidth,
mixed
$newHeight,
int
$flags = 0
)
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 int flags |
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 percentReturnsNImage 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 |
public
NImage
|
#
sharpen(
)
Sharpen image. Sharpen image. ReturnsNImage provides a fluent interface
|
public
NImage
|
#
place(
NImage
$image,
mixed
$left = 0,
mixed
$top = 0,
int
$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 int opacity 0..100ReturnsNImage provides a fluent interface
|
public
bool
|
#
save(
string
$file = NULL,
int
$quality = NULL,
int
$type = NULL
)
Saves image to the file. Saves image to the file. Parameters$file string filename$quality int quality 0..100 (for JPEG and PNG)$type int optional image typeReturnsbool TRUE on success or FALSE on failure.
|
public
string
|
#
toString(
int
$type = 2,
int
$quality = NULL
)
Outputs image to string. Outputs image to string. Parameters$type int image type$quality int quality 0..100 (for JPEG and PNG) |
public
string
|
#
__toString(
)
Outputs image to string. Outputs image to string. |
public
bool
|
#
send(
int
$type = 2,
int
$quality = NULL
)
Outputs image to browser. Outputs image to browser. Parameters$type int image type$quality int quality 0..100 (for JPEG and PNG)Returnsbool 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 argumentsThrows |
Methods Inherited From NObject
getReflection(), __call(), __callStatic(), extensionMethod(), __get(), __set(), __isset(), __unset()
ENLARGE |
1 # |
STRETCH |
2 # |
FIT |
0 # |
FILL |
4 # |
JPEG |
2 # |
PNG |
3 # |
GIF |
1 # |
EMPTY_GIF |
'GIF89a' . "\0" . '' . "\0" . '€' . "\0" . '' . "\0" . '' . "\0" . '' . "\0" . '' . "\0" . '' . "\0" . '' . "\0" . '' . "\0" . '!ù' . "\0" . '' . "\0" . '' . "\0" . '' . "\0" . ',' . "\0" . '' . "\0" . '' . "\0" . '' . "\0" . '' . "\0" . '' . "\0" . '' . "\0" . 'D' . "\0" . ';' # |