Image_Toolbox
[ class tree: Image_Toolbox ] [ index: Image_Toolbox ] [ all elements ]

Class: Image_Toolbox

Source Location: /Image_Toolbox.class.php

Class Overview


PHP image manipulation class


Author(s):

Version:

  • 1.1.0

Copyright:

  • 2003, Martin Theimer

Methods


Inherited Variables

Inherited Methods


Class Details

[line 75]
PHP image manipulation class

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




Tags:

version:  1.1.0
link:  http://sourceforge.net/projects/image-toolbox
copyright:  2003, Martin Theimer
author:  Martin Theimer <mailto:pappkamerad@decoded.net>


[ Top ]


Class Methods


constructor Image_Toolbox [line 161]

Image_Toolbox Image_Toolbox( )

The class constructor.

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')




[ Top ]

method addImage [line 927]

void addImage( )

Adds a new image resource based on the given parameters.

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')




[ Top ]

method addText [line 1283]

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

Writes text over the image

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:

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

[ Top ]

method blend [line 979]

void blend( [string|integer $x = 0], [integer $y = 0], [integer $mode = IMAGE_TOOLBOX_BLEND_COPY], [integer $percent = 100])

Blend two images.

Original image and the image loaded with addImage
NOTE: This operation can take very long and is not intended for realtime use. (but of course depends on the power of your server :) )

IMPORTANT: http://www.php.net/imagecopymerge 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:

  • IMAGE_TOOLBOX_BLEND_COPY
  • IMAGE_TOOLBOX_BLEND_MULTIPLY
  • IMAGE_TOOLBOX_BLEND_SCREEN
  • IMAGE_TOOLBOX_BLEND_DIFFERENCE
  • IMAGE_TOOLBOX_BLEND_EXCLUSION
  • IMAGE_TOOLBOX_BLEND_OVERLAY

$percent:
alpha value in percent of blend effect (0 - 100)
(default = 100)




Parameters:

string|integer   $x   Horizontal position of second image.
integer   $y   Vertical position of second image. negative values are possible.
integer   $mode   blend mode.
integer   $percent   alpha value

[ Top ]

method getServerFeatures [line 225]

array getServerFeatures( )

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

Array values:

  • 'gd_version' -> what GD version is installed on this server (e.g. 2.0)
  • 'gif' -> 0 = not supported, 1 = reading is supported, 2 = creating is supported
  • 'jpg' -> 0 = not supported, 1 = reading is supported, 2 = creating is supported
  • 'png' -> 0 = not supported, 1 = reading is supported, 2 = creating is supported
  • 'ttf' -> TTF text creation. true = supported, false = not supported




[ Top ]

method newImage [line 245]

void newImage( )

Flush all image resources and init a new one

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')




[ Top ]

method newOutputSize [line 791]

bool newOutputSize( integer $width, integer $height, [integer $mode = 0], [bool $autorotate = false], [string $bgcolor = '#000000'])

Resize the current image

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.

$mode can be one of the following:

  • 0 -> image will be resized to the new output size, regardless of the original aspectratio. (default)
  • 1 -> image will be cropped if necessary to preserve the aspectratio and avoid image distortions.
  • 2 -> image will be resized preserving its original aspectratio. differences to the new outputsize will be filled with $bgcolor

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)




Tags:

return:  true on success, otherwise false


Parameters:

integer   $width   new width of image
integer   $height   new height of image
integer   $mode   resize mode
bool   $autorotate   use autorotating
string   $bgcolor   background fillcolor (hexformat, e.g. '#FF0000')

[ Top ]

method output [line 504]

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

Output a image to the browser

$output_type can be one of the following:

  • 'gif' -> gif image (if supported) (8-bit indexed colors)
  • 'png' -> png image (if supported) (truecolor)
  • 'png8' -> png image (if supported) (8-bit indexed colors)
  • 'jpg' -> jpeg image (if supported) (truecolor)
(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)




Tags:

return:  true on success, otherwise false


Parameters:

string|integer   $output_type   type of outputted image
integer   $output_quality   jpeg quality of outputted image (default: IMAGE_TOOLBOX_DEFAULT_JPEG_QUALITY)
bool   $dither   use dither

[ Top ]

method save [line 620]

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

Save a image to disk

$output_type can be one of the following:

  • 'gif' -> gif image (if supported) (8-bit indexed colors)
  • 'png' -> png image (if supported) (truecolor)
  • 'png8' -> png image (if supported) (8-bit indexed colors)
  • 'jpg' -> jpeg image (if supported) (truecolor)
(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)




Tags:

return:  true on success, otherwise false


Parameters:

string   $filename   filename of saved image
string|integer   $output_type   type of saved image
integer   $output_quality   jpeg quality of saved image (default: IMAGE_TOOLBOX_DEFAULT_JPEG_QUALITY)
bool   $dither   use dither

[ Top ]

method setResizeMethod [line 725]

bool setResizeMethod( string|integer $method)

Sets the resize method of choice

$method can be one of the following:

  • 'resize' -> supported by every version of GD (fast but ugly resize of image)
  • 'resample' -> only supported by GD version >= 2.0 (slower but antialiased resize of image)
  • 'workaround' -> supported by every version of GD (workaround function for bicubic resizing, downsizing, VERY slow!, taken from php.net comments)
  • 'workaround2' -> supported by every version of GD (alternative workaround function for bicubic resizing, down- and upsizing, VERY VERY slow!, taken from php.net comments)




Tags:

return:  true on success, otherwise false


Parameters:

string|integer   $method   resize method

[ Top ]


Documentation generated on Fri, 5 Dec 2003 22:09:41 +0100 by phpDocumentor 1.2.3