Image

Class Methods

The following methods can be invoked on instances of this class.

__construct()

Constructor

__destruct()

Destructor
Destroys the internal image

setImageHandle(mixed pImageHandle)

Sets the internal GD image pointer

getImageHandle()

Returns the internal GD image pointer

create(mixed iWidth, mixed iHeight, bool bTrueColor)

Creates a new true colour image handle

createFromString(mixed strImage)

Creates the image obtained from the given string

createFromFile(mixed strFile)

Creates the image obtained from the given file name

__clone()

Clones the image

destroy()

Destroys the internal image

createCanvas(mixed iWidth, int iHeight)

Sets up a new image canvas from the properties of the existing canvas

mergeWith(mixed pImage, mixed iX, mixed iY, mixed iWidth, mixed iHeight)

setBackgroundColorHex(mixed strHex)

setBackgroundColorRGB(mixed r, mixed g, mixed b)

loadBackground(string strFile)

Loads an image onto the canvas - call this before any other methods

getWidth()

Returns the width of the image in pixels

getHeight()

Returns the height of the image in pixels

getMainColors(mixed iNumColours)

Returns the main colours used in an image, sorted by the number of times used
NB: modifies the current image -- reduces palette

rotate(mixed angle, mixed iCanvasR, mixed iCanvasG, mixed iCanvasB)

Rotates image by the given angle

paletteToTrueColor()

Convert the palette image to true colour

trueColorToPallete(mixed bDither, int iColors)

Convert the true color image to a palette image

trueColorToPaletteAccurate(bool bDither, mixed iColors)

A slightly slower version of trueColorToPallete which produces a better quality result

allocateColor(mixed iR, mixed iG, mixed iB, int fA)

Allocates a colour and returns its pallet index

colorAtAccurate(mixed iXPos, mixed iYPos)

Returns the colour of a particular pixel in the image (slow)

crop(mixed iX, mixed iY, mixed iWidth, int iHeight)

Crops the image

resizeCanvas(mixed iWidth, int iHeight)

Resizes the canvas for an image

resize(mixed iWidth, mixed iHeight, mixed bResizeIfSmaller, bool bMaintainAspect)

Resizes an image
Cases: 1) When neither width or height are specified, the original image is returned 2) If only a width or a height is specified, the image will be resized maintaining aspect ratio 3) If both width and height are specified, the image will be resized to these specified dimensions 4) If $bResizeIfSmaller, the image will be scaled up if it is smaller than the specified dimensions

skewY(mixed iLeftHeight, mixed iRightHeight, float fAntialias)

Skews an image on the Y axis

resizeMatrix(mixed arrMatrix, float fAntialias)

Resizes an image by a given matrix of offsets:
array( top_left: [x,y], top_right: [x,y], bottom_right: [x,y], bottom_left: [x,y] )

fill(mixed iX, mixed iY, mixed iColor)

sharpen()

brighten(mixed iAmount)

contrast(mixed iAmount)

drawLine(mixed iX1, mixed iY1, mixed iX2, mixed iY2, int iLineColour)

Draws a line

drawText(mixed fSize, mixed fAngle, mixed iX, mixed iY, mixed iColour, mixed strFont, string strText)

Draws text on the image

write(string strFile)

Writes an image to the file system
Output format is dependant on $strFile's extension

writeJPG(mixed strFile, int iQuality)

Writes the image out as a JPG

writeGIF(string strFile)

Writes the image out as a GIF

writePNG(string strFile)

Writes the image out as a PNG

render(mixed strType)

Renders the image to the browser

resizeFile(mixed strFile, mixed iWidth, mixed iHeight, mixed bMaintainAspect, mixed bReplaceIfExists)

Resizes a file on the filesystem

writeFromFileUpload(mixed arrFileUpload, mixed strMediaFolder, mixed iWidth, int iHeight, mixed bMaintainAspect)

Generates and writes a thumbnail to the filesystem and returns its name
File name format: [filename]_[width]x[height].[extension] Eg. hlr2_1024x768.jpg

getExtensionsSupported()

Returns an array of all image extensions

getExtensionsWebSafe()

Returns an array of all image extensions

rgba(mixed r, mixed g, mixed b, mixed a)

RGBA Constructor

hsl(mixed h, mixed s, mixed l)

HSL Constructor

cmyk(mixed c, mixed m, mixed y, mixed k)

CMYK Constructor

convertIntToRGBA(mixed iColour)

Converts an integer to RGBA

convertIntToHex(mixed iColour)

Converts an integer to hex

convertHexToRGB(string strHex)

Converts hex to RGB

convertHexToHSL(string strHex)

Converts from hex to HSL

convertRGBToHex(mixed r, mixed g, mixed b)

Converts RGB to hex

convertRGBToHSL(mixed r, mixed g, int b)

Converts from RGB to HSL

convertRGBToCMYK(mixed r, mixed g, mixed b)

Converts RGB to CMYK

hueToRGB(mixed v1, mixed v2, mixed vH)

convertHSLToRGB(mixed H, mixed S, int L)

Converts Hue Saturation Lightness to RGB

colourIsDark(mixed strHex)

Determines whether a hex colour value is light or dark.

colourGetComplement(string strHex)

Uses the RGB colour model to find the complementary colour of a
given hex colour value.

colourGetLighter(mixed strHex, int intLight)

Generates a lighter tint of a given colour. The percentage increase can be specified.

colourGetDarker(mixed strHex, int intDark)

Generates a darker shade of a given colour. The percentage increase can be specified.

__call(mixed strName, array arrArguments)

Magic function to trap calls to undefined functions and throw an exception rather than
a fatal error.

__callStatic(mixed strName, array arrArguments)

Magic function to trap static calls to undefined functions and throw an exception rather
than a fatal error.

classGetFolder()

Returns the folder where the class exists

__set_state(mixed arrValues)

classGetFolderResources()

Returns the folder where the class's resources exist

classGetSrcFile()

Returns the folder where the class exists

classGetSrcHash()

Returns the folder where the class exists

classGetReflection()

Returns the reflection data for the current class

classGetReflectionAnnotation(string strField)

Returns a specific class annotation for the current class