wiImage methods
Base class for an image. Extended by
wiTrueColorImage and
wiPaletteImage.
Loading and saving
static load($source, $format = null)
Load an image. For details, see
LoadingImages.
static loadFromFile($uri, $format = null)
Loads an image specifically from a file.
static function loadFromString($string)
Loads an image specifically from a string.
static function loadFromHandle($handle)
Loads an image specifically from an image resource. Takes ownership of the resource (see
HandleOwnership).
saveToFile($uri, $format = null)
Saves an image to a file. See
SavingImages for details.
asString($format)
Returns the image data in a string. See
SavingImages for details.
Handle control
releaseHandle()
Tells the object to release the image resource handle. In most cases, you won't need this. See
HandleOwnership and
ResourceHandling for details.
destroy()
Destroys the image resource handle. In most cases, you won't need this. See
ResourceHandling and
HandleOwnership for details
static isValidImageHandle($handle)
Returns true if the passed handle is a valid
gd resource.
Basic information
getHandle()
Returns the image resource handle (gd resource).
isValid()
Returns true if object holds a valid image resource.
getWidth()
Returns the image's width, in pixels.
getHeight()
Returns the image's height, in pixels.
isTransparent()
Returns true if the image is transparent, false otherwise.
isTrueColor()
Returns true if the image is true-color, false otherwise.
Color handling
allocateColor($R, $G = null, $B = null)
Allocate a color by RGB values. $R can be red component value or an RGB array (with red, green, blue keys), in which case you don't have to pass $G and $B.
getRGBAt($x, $y)
Returns a RGBA array of the color at $x and $y.
setRGBAt($x, $y, $color)
Writes a pixel at the designated coordinates. Takes an associative array of colors and uses getExactColor() retrieve the exact index color to write to the image with.
getColorRGB($colorIndex)
Returns RGBA colors for color $colorIndex.
getColorAt($x, $y)
Returns the index of the color at ($x, $y).
setColorAt($x, $y, $color)
Sets the pixel at ($x, $y) to color index $color.
getClosestColor($R, $G = null, $B = null)
Returns the closest color index that matches the given RGB values. $R can be a RGBA array, in which case you don't have to pass $G and $B.
getExactColor($R, $G = null, $B = null)
Returns the exact color index that matches the given RGB values. $R can be a RGBA array, in which case you don't have to pass $G and $B. If no color is found, -1 is returned.
Transparency
copyTransparencyFrom($sourceImage, $fill = true)
Copies transparency information from $sourceImage. Optionally fills the image with the transparent color at (0, 0).
getTransparentColor()
Returns the transparent color index. Returns -1 if the image is not transparent.
setTransparentColor($color)
Sets the transparent color index.
getTransparentColorRGB()
Returns a RGBA associative array (keys red, green, blue, alpha) of the transparent color.
fill($x, $y, $color)
Fills the image with $color at ($x, $y).
Copying
copy()
Returns a copy of itself.
copyTo($dest, $left = 0, $top = 0)
Copies itself to $dest at ($left, $top). $dest must be a valid wiImage object.
CategoryDocApi
There are no comments on this page. [Add comment]