graphicsGD
extends graphicsBase
in package
class for image handling using the GD library
Tags
Table of Contents
Properties
- $fontlist : mixed
- $gd_freetype_fonts : mixed
- $gd_loaded : mixed
- $gd_present : mixed
- $generalinfo : mixed
- $imagemagick_version : mixed
- $imagemagick_version_pass : mixed
- $imagick_present : mixed
- $imagick_version : mixed
- $imagick_version_pass : mixed
- $info : mixed
Methods
- __construct() : mixed
- checkGraphicSupport() : mixed
- Check if a required graphics libary is available on the system Mzst be called by every graphics class related constructor to ensure that general properties are set properly
- colorAllocate() : int
- Returns an RGB color identifier
- copyCanvas() : mixed
- copies an image canvas
- createImage() : image
- Creates a true color image
- drawRectangle() : bool
- Creates a rectangle
- flipImage() : object
- Flips (mirrors) an image
- flipRotateImage() : object|false
- Rotates and/or flips an image based on by using rotateImage() and flipImage() methods
- getCounterClockwiseRotation() : int
- Returns the counter clockwise rotation degree the GD library requires
- getFonts() : array<string|int, mixed>
- Returns a list of available fonts
- graphicsLibInfo() : mixed
- imageBlurGD() : mixed
- provides image blur support for lib-GD:zp_imageUnsharpMask
- imageCanRotate() : bool
- Returns true if GD library is configued with image rotation suppord
- imageColorTransparent() : bool
- Sets the transparency color
- imageDims() : mixed
- imageFill() : bool
- Fills an image area
- imageFontHeight() : int
- Returns the font height in pixels
- imageFontWidth() : int
- Returns the font width in pixels
- imageFromString() : mixed
- creates an image from an image stream
- imageGet() : image
- Takes an image filename and returns a GD Image using the correct function for the image's format (imagecreatefrom*). Supports JPEG, GIF, and PNG.
- imageGray() : resource
- Creates a grayscale image
- imageHeight() : int
- Returns the height of an image resource
- imageIPTC() : mixed
- imageKill() : bool
- destroys an image resource
- imageLoadFont() : int
- Loads a font and returns its font id
- imageMerge() : bool
- Does a copy merge of two image resources
- imageOutput() : mixed
- outputs an image resource as a given type
- imageResizeAlpha() : image
- Resize a PNG file with transparency to given dimensions and still retain the alpha channel information
- imageResizeTransparent() : image
- Resize a GIF file with transparency to given dimensions and still retain the transparency information
- imageUnsharpMask() : image
- Sharpens an image using an Unsharp Mask filter.
- imageWidth() : int
- Returns the width of an image resource
- resampleImage() : bool
- resamples an image to a new copy
- rotateImage() : resource
- Rotates an image resource according to its Orientation NB: requires the imagarotate function to be configured
- writeString() : bool
- Rencers a string into the image
Properties
$fontlist
public
mixed
$fontlist
= array()
$gd_freetype_fonts
public
mixed
$gd_freetype_fonts
= array()
$gd_loaded
public
mixed
$gd_loaded
= \false
$gd_present
public
mixed
$gd_present
= \false
$generalinfo
public
mixed
$generalinfo
= array()
$imagemagick_version
public
mixed
$imagemagick_version
= ''
$imagemagick_version_pass
public
mixed
$imagemagick_version_pass
= \false
$imagick_present
public
mixed
$imagick_present
= \false
$imagick_version
public
mixed
$imagick_version
= ''
$imagick_version_pass
public
mixed
$imagick_version_pass
= \false
$info
public
mixed
$info
= array()
Methods
__construct()
public
__construct() : mixed
checkGraphicSupport()
Check if a required graphics libary is available on the system Mzst be called by every graphics class related constructor to ensure that general properties are set properly
public
checkGraphicSupport() : mixed
Tags
colorAllocate()
Returns an RGB color identifier
public
colorAllocate(resource $image, int $red, int $green, int $blue) : int
Parameters
- $image : resource
- $red : int
- $green : int
- $blue : int
Return values
intcopyCanvas()
copies an image canvas
public
copyCanvas(image $imgCanvas, image $img, int $dest_x, int $dest_y, int $src_x, int $src_y, int $w, int $h) : mixed
Parameters
- $imgCanvas : image
-
source canvas
- $img : image
-
destination canvas
- $dest_x : int
-
destination x
- $dest_y : int
-
destination y
- $src_x : int
-
source x
- $src_y : int
-
source y
- $w : int
-
width
- $h : int
-
height
createImage()
Creates a true color image
public
createImage(int $w, int $h[, bool $truecolor = true ]) : image
Parameters
- $w : int
-
the width of the image
- $h : int
-
the height of the image
- $truecolor : bool = true
-
True to create a true color image, false for usage with palette images like gifs
Return values
imagedrawRectangle()
Creates a rectangle
public
drawRectangle(resource $image, int $x1, int $y1, int $x2, int $y2, int $color) : bool
Parameters
- $image : resource
- $x1 : int
- $y1 : int
- $x2 : int
- $y2 : int
- $color : int
Return values
boolflipImage()
Flips (mirrors) an image
public
flipImage(image $im[, string $mode = 'horizontal' ]) : object
Parameters
- $im : image
- $mode : string = 'horizontal'
-
"horizontal" (default) or "vertical"
Tags
Return values
objectflipRotateImage()
Rotates and/or flips an image based on by using rotateImage() and flipImage() methods
public
flipRotateImage(object $im, array<string|int, mixed> $rotate) : object|false
Parameters
- $im : object
-
GDImage or imagick image object
- $rotate : array<string|int, mixed>
-
Two dimensional array with rotate and flip indexes as returned be getImageRotation()
Tags
Return values
object|falsegetCounterClockwiseRotation()
Returns the counter clockwise rotation degree the GD library requires
public
static getCounterClockwiseRotation(int $degree) : int
Parameters
- $degree : int
-
Rotation degree clockwise
Tags
Return values
intgetFonts()
Returns a list of available fonts
public
getFonts() : array<string|int, mixed>
Return values
array<string|int, mixed>graphicsLibInfo()
public
graphicsLibInfo() : mixed
imageBlurGD()
provides image blur support for lib-GD:zp_imageUnsharpMask
public
imageBlurGD(image $imgCanvas, mixed $imgCanvas2, int $radius, int $w, int $h) : mixed
Parameters
- $imgCanvas : image
- $imgCanvas2 : mixed
- $radius : int
- $w : int
- $h : int
imageCanRotate()
Returns true if GD library is configued with image rotation suppord
public
imageCanRotate() : bool
Return values
boolimageColorTransparent()
Sets the transparency color
public
imageColorTransparent(image $image, color $color) : bool
Parameters
- $image : image
- $color : color
Return values
boolimageDims()
public
imageDims(mixed $filename) : mixed
Parameters
- $filename : mixed
imageFill()
Fills an image area
public
imageFill(image $image, int $x, int $y, color $color) : bool
Parameters
- $image : image
- $x : int
- $y : int
- $color : color
Return values
boolimageFontHeight()
Returns the font height in pixels
public
imageFontHeight(int $font) : int
Parameters
- $font : int
Return values
intimageFontWidth()
Returns the font width in pixels
public
imageFontWidth(int $font) : int
Parameters
- $font : int
Return values
intimageFromString()
creates an image from an image stream
public
imageFromString(mixed $string) : mixed
Parameters
- $string : mixed
imageGet()
Takes an image filename and returns a GD Image using the correct function for the image's format (imagecreatefrom*). Supports JPEG, GIF, and PNG.
public
imageGet(mixed $imgfile) : image
Parameters
- $imgfile : mixed
Return values
image —the loaded GD image object.
imageGray()
Creates a grayscale image
public
imageGray(resource $image) : resource
Parameters
- $image : resource
Return values
resourceimageHeight()
Returns the height of an image resource
public
imageHeight(resource $im) : int
Parameters
- $im : resource
Return values
intimageIPTC()
public
imageIPTC(mixed $filename) : mixed
Parameters
- $filename : mixed
imageKill()
destroys an image resource
public
imageKill(resource $im) : bool
Parameters
- $im : resource
Return values
boolimageLoadFont()
Loads a font and returns its font id
public
imageLoadFont([string $font = NULL ][, mixed $size = 18 ]) : int
Parameters
- $font : string = NULL
- $size : mixed = 18
Return values
intimageMerge()
Does a copy merge of two image resources
public
imageMerge(resource $dst_im, resource $src_im, int $dst_x, int $dst_y, int $src_x, int $src_y, int $src_w, int $src_h, int $pct) : bool
Parameters
- $dst_im : resource
- $src_im : resource
- $dst_x : int
- $dst_y : int
- $src_x : int
- $src_y : int
- $src_w : int
- $src_h : int
- $pct : int
Return values
boolimageOutput()
outputs an image resource as a given type
public
imageOutput(resource $im, string $type[, string $filename = NULL ][, int $qual = 75 ]) : mixed
Parameters
- $im : resource
- $type : string
- $filename : string = NULL
- $qual : int = 75
imageResizeAlpha()
Resize a PNG file with transparency to given dimensions and still retain the alpha channel information
public
imageResizeAlpha(image $src, int $w, int $h) : image
Note: You have to apply the resampleImage() method afterwards as the function does not handle this internally
Parameters
- $src : image
- $w : int
- $h : int
Return values
imageimageResizeTransparent()
Resize a GIF file with transparency to given dimensions and still retain the transparency information
public
imageResizeTransparent(image $src, int $w, int $h) : image
Note: You have to apply zp_resampleImage() afterwards as the function does not handle this internally
Parameters
- $src : image
- $w : int
- $h : int
Tags
Return values
imageimageUnsharpMask()
Sharpens an image using an Unsharp Mask filter.
public
imageUnsharpMask(image $img, int $amount, int $radius, int $threshold) : image
Original description from the author:
WARNING ! Due to a known bug in PHP 4.3.2 this script is not working well in this version. The sharpened images get too dark. The bug is fixed in version 4.3.3.
From version 2 (July 17 2006) the script uses the imageconvolution function in PHP version >= 5.1, which improves the performance considerably.
Unsharp masking is a traditional darkroom technique that has proven very suitable for digital imaging. The principle of unsharp masking is to create a blurred copy of the image and compare it to the underlying original. The difference in colour values between the two images is greatest for the pixels near sharp edges. When this difference is subtracted from the original image, the edges will be accentuated.
The Amount parameter simply says how much of the effect you want. 100 is 'normal'. Radius is the radius of the blurring circle of the mask. 'Threshold' is the least difference in colour values that is allowed between the original and the mask. In practice this means that low-contrast areas of the picture are left unrendered whereas edges are treated normally. This is good for pictures of e.g. skin or blue skies.
Any suggenstions for improvement of the algorithm, expecially regarding the speed and the roundoff errors in the Gaussian blur process, are welcome.
Permission to license this code under the GPL was granted by the author on 2/12/2007.
Parameters
- $img : image
-
the GD format image to sharpen. This is not a URL string, but should be the result of a GD image function.
- $amount : int
-
the strength of the sharpening effect. Nominal values are between 0 and 100.
- $radius : int
-
the pixel radius of the sharpening mask. A smaller radius sharpens smaller details, and a larger radius sharpens larger details.
- $threshold : int
-
the color difference threshold required for sharpening. A low threshold sharpens all edges including faint ones, while a higher threshold only sharpens more distinct edges.
Return values
image —the input image with the specified sharpening applied.
imageWidth()
Returns the width of an image resource
public
imageWidth(resource $im) : int
Parameters
- $im : resource
Return values
intresampleImage()
resamples an image to a new copy
public
resampleImage(resource $dst_image, resource $src_image, int $dst_x, int $dst_y, int $src_x, int $src_y, int $dst_w, int $dst_h, int $src_w, int $src_h) : bool
Parameters
- $dst_image : resource
- $src_image : resource
- $dst_x : int
- $dst_y : int
- $src_x : int
- $src_y : int
- $dst_w : int
- $dst_h : int
- $src_w : int
- $src_h : int
Return values
boolrotateImage()
Rotates an image resource according to its Orientation NB: requires the imagarotate function to be configured
public
rotateImage(object $im, int $rotate) : resource
Parameters
- $im : object
-
GD image object
- $rotate : int
-
Rotation degree clock wise! GD required counter clockwise calcuation is done internally
Return values
resourcewriteString()
Rencers a string into the image
public
writeString(resource $image, int $font, int $x, int $y, string $string, int $color) : bool
Parameters
- $image : resource
- $font : int
- $x : int
- $y : int
- $string : string
- $color : int