Class Image_Toolbox by Martin Theimer
Version 1.6 2003/11/04 19:49:16

PHP image manipulation class

This class provides an easy to use library to the PHP GD-based imagefunctions

Constructor Summary
Image_Toolbox -- The class constructor.

Method Summary
addImage -- Adds a new image resource based on the given parameters.
addText -- Writes text over the image
blend -- Blend two images.
getServerFeatures -- Returns an assocative array with information about the image features of this server
newImage -- Flush all image resources and init a new one
newOutputSize -- Resize the current image
output -- Output a image to the browser
save -- Save a image to disk
setResizeMethod -- Sets the resize method of choice

Constructor Detail

Image_Toolbox

The class constructor.

Image_Toolbox ( void)

Determines the image features of the server and sets the according values.
Additionally you can specify a image to be created/loaded. like addImage.

If no parameter is given, no image resource will be generated
Or:
string $file imagefile to load
Or:
integer $width imagewidth of new image to be created
integer $height imageheight of new image to be created
string $fillcolor optional fill the new image with this color (hexformat, e.g. '#FF0000')

Method Detail

addImage

Adds a new image resource based on the given parameters.

addImage ( void)

It does not overwrite the existing image resource.
Instead it is used to load a second image to merge with the existing image.

Parameter:
string $file imagefile to load
Or:
integer $width imagewidth of new image to be created
integer $height imageheight of new image to be created
string $fillcolor optional fill the new image with this color (hexformat, e.g. '#FF0000')

addText

Writes text over the image

addText ( string text, string font, integer size, string color, string|integer x, string|integer y [, integer angle])

only TTF fonts are supported at the moment

$x:
You can also use the following keywords ('left', 'center' or 'middle', 'right').
Additionally you can specify an offset in pixel with the keywords like this 'left +10'.
(default = 0)

$y:
You can also use the following keywords ('top', 'center' or 'middle', 'bottom').
Additionally you can specify an offset in pixel with the keywords like this 'bottom -10'.
(default = 0)

Parameters:
text - text to be generated.
font - TTF fontfile to be used. (relative paths are ok).
size - textsize.
color - textcolor in hexformat (e.g. '#FF0000').
x - horizontal postion in pixel.
y - vertical postion in pixel.
angle - rotation of the text.

blend

Blend two images.

blend ( [ string|integer x [, integer y [, integer mode [, integer percent]]]])

Original image and the image loaded with addImage
IMPORTANT: imagecopymerged doesn't work with PHP 4.3.2. Bug ID: 24816

$x:
negative values are possible.
You can also use the following keywords ('left', 'center' or 'middle', 'right').
Additionally you can specify an offset in pixel with the keywords like this 'left +10'.
(default = 0)

$y:
negative values are possible.
You can also use the following keywords ('top', 'center' or 'middle', 'bottom').
Additionally you can specify an offset in pixel with the keywords like this 'bottom -10'.
(default = 0)

Possible values for $mode:

$percent:
alpha value in percent of blend effect (0 - 100)
(default = 100)
Parameters:
x - Horizontal position of second image.
y - Vertical position of second image. negative values are possible.
mode - blend mode.
percent - alpha value

getServerFeatures

Returns an assocative array with information about the image features of this server

array getServerFeatures ( void)

Array values:

newImage

Flush all image resources and init a new one

newImage ( void)

Parameter:
string $file imagefile to load
Or:
integer $width imagewidth of new image to be created
integer $height imageheight of new image to be created
string $fillcolor optional fill the new image with this color (hexformat, e.g. '#FF0000')

newOutputSize

Resize the current image

bool newOutputSize ( integer width, integer height [, bool crop [, bool autorotate]])

if $width = 0 the new width will be calculated from the $height value preserving the correct aspectratio.

if $height = 0 the new height will be calculated from the $width value preserving the correct aspectratio.

if $crop is set to true the image will be cropped if necessary to preserve the aspectratio and avoid image distortions.
(default = false)

if $autorotate is set to true the given $width and $height values may "change place" if the given image bias is different from the original one.
if either $width or $height is 0, the new size will be applied to either the new width or the new height based on the bias value of the original image.
(default = false)

Parameters:
width - new width of image
height - new height of image
crop - use image cropping
autorotate - use autorotating
Returns:
true on success, otherwise false

output

Output a image to the browser

bool output ( [ string|integer output_type [, integer output_quality [, bool dither]]])

$output_type can be one of the following:

(default: same as original)

$dither:
If this is true than dither is used on the conversion from truecolor to 8-bit indexed imageformats (png8, gif)
(default = false)
Parameters:
output_type - type of outputted image
output_quality - jpeg quality of outputted image (default: IMAGE_TOOLBOX_DEFAULT_JPEG_QUALITY)
dither - use dither
Returns:
true on success, otherwise false

save

Save a image to disk

bool save ( string filename [, string|integer output_type [, integer output_quality [, bool dither]]])

$output_type can be one of the following:

(default: same as original)

$dither:
If this is true than dither is used on the conversion from truecolor to 8-bit indexed imageformats (png8, gif)
(default = false)
Parameters:
filename - filename of saved image
output_type - type of saved image
output_quality - jpeg quality of saved image (default: IMAGE_TOOLBOX_DEFAULT_JPEG_QUALITY)
dither - use dither
Returns:
true on success, otherwise false

setResizeMethod

Sets the resize method of choice

bool setResizeMethod ( string|integer method)

$method can be one of the following:

Parameters:
method - resize method
Returns:
true on success, otherwise false

Documentation generated by TM::PHPDoc