Module: gd
Module for image processing, compatible with PHP GD based on LibGD The module must be loaded with dl('gd');
See also example Graphics functions.
The following functions are almost compatible with PHP. For further information read documentation of PHP GD.
- gd_info
- imagetypes
Open / Output
- imagecreate
- imagecreatetruecolor
- imagedestroy
- imagejpeg
- imagegif
- imagepng
- imagewbmp
- imagewebp
- imagebmp
Special helper functions, not part of PHP GD.
Function/Arguments | Return | Description |
---|---|---|
imagecreatefromfile (string filename) | handle | Create image from filename. On success a image handle is returned. |
imagecreatefromstring (string buffer, string type) | handle | Create image from string buffer. type can be the following images types: jpg, png, gif, wbmp, webp, tif, bmp. On success a image handle is returned. |
imagefile (handle image, string filename) | bool | Save image to filename. Note: This function does not use quality parameter. To specify a quality you have to use the default functions such as imagejpeg() or imagetostring(). On success true is returned. |
imagetostring (handle image, string type, [number quality=-1]) | string | Get image data as string. type can be the following images types: jpg, png, gif, wbmp, webp, tif, bmp. Optional parameter quality can be the quality in percent of the JPEG image or compression flag for BMP images. On success a string with image data is returned. |
imagetruecolorattachbuffer (number address, number width, number height, number stride) | handle | Create image from a RGB32 image buffer. Memory address is usually a string buffer. memref() function return the memory address of a string. width and height give the resolution in pixels. If stride is the negative width then address starts at the top/left position of the image. If stride is the positive width then address starts at the bottom/left position of the image. On success a new image handle is returned. |
Drawing
- imagesetpixel
- imagefill
- imagefilltoborder
- imageline
- imagedashedline
- imagerectangle
- imagefilledrectangle
- imagearc
- imagefilledarc
- imageellipse
- imagefilledellipse
- imagepolygon
- imageopenpolygon
- imagefilledpolygon
Text/Font
- imagestring
- imagestringup
- imagettftext
- imagefontheight
- imagefontwidth
Properties
- imageistruecolor
- imagegettruecolorpixel
- imagesetthickness
- imagesetbrush
- imagesettile
- imagesetstyle
- imagesetantialiased
- imagesetantialiaseddontblend
- imageinterlace
- imageresolution
- imagealphablending
- imagesavealpha
- imagesetinterpolation
Special helper functions, not part of PHP GD.
Function/Arguments | Return | Description |
---|---|---|
imagesx (handle image) | number | Return image width in pixel. |
imagesy (handle image) | number | Return image height in pixel. |
imagegetpixel (handle image, number x, number y) | number | Get color of pixel x/y. Same as colorat function. |
Colors, Palettes
- imagecolorstotal
- imagecolorat
- imagecolorsforindex
- imagecolortransparent
- imagecolorallocate
- imagecolorallocatealpha
- imagecolordeallocate
- imagecolorclosest
- imagecolorclosestalpha
- imagecolorclosesthwb
- imagecolorexact
- imagecolorexactalpha
- imagecolorresolve
- imagecolorresolvealpha
- imagecolormatch
- imagecolorset
- imagepalettetotruecolor
- imagetruecolortopalette
- imagepalettecopy
Copy, Size
- imagecopy
- imagecopymerge
- imagecopymergegray
- imagecopyresized
- imagecopyrotated
- imagecopyresampled
- imagecrop
- imagecropauto
- imagescale
Operations, Filters
- imageflip
- imagerotate
- imagefilter
- imagecompare
Special functions only available on Windows, not part of PHP GD.
Function/Arguments | Return | Description |
---|---|---|
makescreenshot (number hWnd=null, bool clientRect=false) | handle | Capture image from screen or specific window handle given by hWnd. If hWnd is null then the entire screen is captured. If clientRect is true, only the inner rectangle of a window is captured. On success the captured image handle is returned. |
videogetalldrivers () | array | Get a list with all video drivers available. Driver index is beginning from 0. |
videocreate (number index) | handle | Create and connect to video driver index. On success a video handle is returned. On error false is returned. |
videosetdriverindex (handle video, number index) | bool | Connect to a individual video driver index on an existing video handle. On success true is returned. See videogetalldrivers() to get a list of all available drivers. |
videosetformat (handle video, number width, number height [,number bits=-1]) | bool | Set a video format. video is the video handle created by videocreate(). width and height give the resolution in screen pixels. Optional parameter bits give the color depth (8, 16, 24, 32). If bits is not given the default color depth is used. On success true is returned. See also videogetprops() to get the properties of default resolution after videocreate(). |
videogetprops (handle video) | array | Return an array with properties of current video resolution. video is the video handle created by videocreate(). On success an array with the following array keys is returned: device_index, device_name, device_version, width, height, bits, compression, size_image, planes, has_overlay, capture_initialized. On error false is returned. |
videosetcapturebuffer (number address, [bool autoConvertRGB32=true, number notifyId=0 ]) | bool | Set a capture buffer to hold a camera image. Memory address is usually a string buffer. memref() function return the memory address of a string. Optional parameter autoConvertRGB32 marks if the camera raw image should be converted automatically to RGB32, otherwise the raw data will be captured. Take care to allocate enough RGB32 buffer with resize() which is calculated by width x height x 4 bytes. Note: Not all image data formats will be converted automatically to RGB32. In time only RGB24, YUY2, MJPEG will be convered. All other formats are transferred as raw data. See also compression flag returned by videogetprops(). For more details of the available compression flags read the Microsoft FOURCC Codes. If the optional parameter notifyId is not 0 than it holds a WM_COMMAND identifier to notify the preview window that a new frame was received, see also videoenablepreviewwindow(). On success true is returned. |
videoenablepreviewwindow (handle video, number hWndParent, number x, number y, number width, number height, [number scale=1, number refreshRate=30]) | bool | Set a video preview window. video is the video handle created by videocreate(). hWndParent is the parent window handle where the preview is shown. x, y, width and height are the position and resolution of the preview in parent window. Parameters scale and refreshRate are optional. On success true is returned. Note: After enabling a preview window the frame grabbing begins to start and new frames are transferred constantly to capture buffer set with videosetcapturebuffer(). If you only want to grab the frames you should set the width and height of the preview window to 1 pixel (0 does not work). In the example application win-video the frames are transferred to a memory DC, the preview window itself is has only the dimension of 1x1 pixels. |
videodisablepreviewwindow (handle video) | bool | Disable the video preview window. video is the video handle created by videocreate(). Note: After disabling a preview window the frame grabbing stops and no new frames are transferred to capture buffer set with videosetcapturebuffer(). On success true is returned. |
videograbframe (handle video) | bool | Grab a new frame manually from video handle created by videocreate() to a capture buffer set with videosetcapturebuffer(). Note: In contrast to videoenablepreviewwindow() this function will not grab frames constantly into the capture buffer. On success true is returned. |
videocapturebmp (handle video, string filename) | bool | Save the current frame as BMP image filename. video is the handle created by videocreate(). Note: This function does not need to set own capture buffer with videosetcapturebuffer() and does not need to enable a preview window with videoenablepreviewwindow(). On success true is returned. |
videogetwindow (handle video) | number | Get window handle of video handle created by videocreate(). Note: This window is invisible until you make it visible with videoenablepreviewwindow(). |
videogeterror (handle video) | array | Return an array with last error information for video handle created with videocreate(). On success an array ("error_id"=><id>, "error_text"=>"<text>") is returned. |
videodestroy (handle video) | bool | Disconnect and destroy a video handle created with videocreate(). On success true is returned. |