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

Class: Image_Transform_Driver_GD

Source Location: /Image_Transform-0.9.5/Image/Transform/Driver/GD.php

Class Overview

Image_Transform
   |
   --Image_Transform_Driver_GD

GD implementation for Image_Transform package


Author(s):

Version:

  • Release: @package_version@

Copyright:

  • 2002-2005 The PHP Group

Variables

Methods


Child classes:

Image_Transform_Driver_GD1
This driver is for GD1 or the non-bundled version of GD2

Inherited Variables

Inherited Methods

Class: Image_Transform

Image_Transform::addBorder()
Image_Transform::addDropShadow()
Image_Transform::addText()
Methods to add to the driver classes in the future
Image_Transform::canvasResize()
Image_Transform::colorarray2colorhex()
Converts an array of RGB value into a #FFFFFF format color.
Image_Transform::colorhex2colorarray()
Converts a color string into an array of RGB values
Image_Transform::crop()
Crops an image
Image_Transform::display()
Outputs the image to standard output
Image_Transform::factory()
Creates a new Image_Transform object
Image_Transform::fit()
Fits the image in the specified box size
Image_Transform::fitOnCanvas()
This works as per fit, but creates the canvas of size $width x $height and positions the resized image on it, by default in the centre.
Image_Transform::fitX()
Fits the image in the specified width
Image_Transform::fitY()
Fits the image in the specified height
Image_Transform::flip()
Vertical mirroring
Image_Transform::free()
Releases resource
Image_Transform::gamma()
Corrects the gamma of an image
Image_Transform::getHandle()
Returns the image handle so that one can further try to manipulate the image
Image_Transform::getImageHeight()
Returns the image height
Image_Transform::getImageSize()
Returns the image size and extra format information
Image_Transform::getImageType()
Returns the type of the image being manipulated
Image_Transform::getImageWidth()
Returns the image width
Image_Transform::getMimeType()
Returns the MIME type of the image being manipulated
Image_Transform::getNewImageHeight()
Return new image Y
Image_Transform::getNewImageWidth()
Returns the new image width
Image_Transform::getTempDir()
Returns the temp directory according to either the TMP, TMPDIR, or TEMP env variables. If these are not set it will also check for the existence of /tmp, %WINDIR%\temp
Image_Transform::getTempFile()
Returns a temporary filename using tempnam() and the above getTmpDir() function.
Image_Transform::getWebSafeFormat()
This looks at the current image type and attempts to determine which
Image_Transform::grayscale()
Converts an image into greyscale colors
Image_Transform::greyscale()
Converts an image into greyscale colors
Image_Transform::intersects()
Checks if the rectangle passed intersects with the current image
Image_Transform::isError()
Returns/sets an error when the instance couldn't initialize properly
Image_Transform::keepSettingsOnSave()
Image_Transform::load()
Loads an image file to work with
Image_Transform::mirror()
Horizontal mirroring
Image_Transform::normalize()
Normalizes the colors, gamma and other properties of an image (this should give a result equivalent to a Photoshop autolevels)
Image_Transform::resize()
Resizes the image in the X and/or Y direction(s)
Image_Transform::rotate()
Rotates the image clockwise
Image_Transform::save()
Saves image to file
Image_Transform::scale()
Scales an image by a percentage, factor or a given length
Image_Transform::scaleByFactor()
Scales an image to a factor of its original size. For example, if my image was 640x480 and I called scaleByFactor(0.5) then the image would be resized to 320x240.
Image_Transform::scaleByLength()
Alias for scaleMaxLength
Image_Transform::scaleByPercentage()
Scales an image to a percentage of its original size. For example, if my image was 640x480 and I called scaleByPercentage(10) then the image would be resized to 64x48
Image_Transform::scaleByX()
Scales the image to the specified width
Image_Transform::scaleByXY()
Alias for resize()
Image_Transform::scaleByY()
Scales the image to the specified height.
Image_Transform::scaleMaxLength()
Scales an image so that the longest side has the specified dimension.
Image_Transform::setOption()
Sets one options
Image_Transform::setOptions()
Sets multiple options at once
Image_Transform::supportsType()
Returns if the driver supports a given image type
Image_Transform::_convert_image_type()
Returns the matching IMAGETYPE_* constant for a given image type
Image_Transform::_getColor()
Returns a color option
Image_Transform::_getOption()
Returns an option
Image_Transform::_get_default_text_params()
Returns the current value of $this->default_text_params.
Image_Transform::_get_image_details()
Sets the image type (in lowercase letters), the image height and width.
Image_Transform::_parse_size()
Parses input for number format and convert
Image_Transform::_prepare_cmd()
Handles space in path and Windows/UNIX difference
Image_Transform::_resize()
Place holder for the real resize method used by extended methods to do the resizing
Image_Transform::_rotation_angle()
Returns an angle between 0 and 360 from any angle value
Image_Transform::_set_img_x()
Sets the image width
Image_Transform::_set_img_y()
Sets the image height
Image_Transform::_set_new_x()
Sets the new image width
Image_Transform::_set_new_y()
Sets the new image height

Class Details

[line 64]
GD implementation for Image_Transform package

Usage : $img =& Image_Transform::factory('GD'); $angle = -78; $img->load('magick.png');

if ($img->rotate($angle, array( 'autoresize' => true, 'color_mask' => array(255, 0, 0)))) { $img->addText(array( 'text' => 'Rotation ' . $angle, 'x' => 0, 'y' => 100, 'font' => '/usr/share/fonts/default/TrueType/cogb____.ttf')); $img->display(); } else { echo "Error"; } $img->free();



[ Top ]


Class Variables

$imageHandle =  null

[line 72]

Holds the image resource for manipulation
  • Access: protected

Type:   resource


[ Top ]

$oldImage =  null

[line 80]

Holds the original image file
  • Access: protected

Type:   resource


[ Top ]



Method Detail

__construct (Constructor)   [line 95]

Image_Transform_Driver_GD __construct( )

Check settings
  • Since: PHP 5

Overridden in child classes as:

Image_Transform_Driver_GD1::__construct()
Check settings

[ Top ]

Image_Transform_Driver_GD (Constructor)   [line 85]

Image_Transform_Driver_GD Image_Transform_Driver_GD( )

Check settings

[ Top ]

addBorder   [line 176]

bool addBorder( int $border_width, [ $color = ''])

Adds a border of constant width around an image
  • Return: TRUE
  • Author: Peter Bowyer
  • Access: public

Overrides Image_Transform::addBorder() (parent method not documented)

Parameters:

int   $border_width   —  Width of border to add
   $color   — 

[ Top ]

addText   [line 217]

bool|PEAR_Error addText( array $params)

addText
  • Return: TRUE or a PEAR_Error object on error

Overrides Image_Transform::addText() (Methods to add to the driver classes in the future)

Parameters:

array   $params   —  Array contains options array( 'text' The string to draw 'x' Horizontal position 'y' Vertical Position 'color' Font color 'font' Font to be used 'size' Size of the fonts in pixel 'resize_first' Tell if the image has to be resized before drawing the text )

[ Top ]

crop   [line 329]

bool|PEAR_Error crop( int $width, int $height, [int $x = 0], [int $y = 0])

Crops image by size and start coordinates
  • Return: TRUE or a PEAR_Error object on error
  • Access: public

Overrides Image_Transform::crop() (Crops an image)

Parameters:

int   $width   —  width Cropped image width
int   $height   —  height Cropped image height
int   $x   —  x X-coordinate to crop at
int   $y   —  y Y-coordinate to crop at

[ Top ]

display   [line 505]

bool|PEAR_Error display( [string $type = ''], [int $quality = null])

Displays image without saving and lose changes.

This method adds the Content-type HTTP header

  • Return: TRUE or PEAR_Error object on error
  • Access: public

Overrides Image_Transform::display() (Outputs the image to standard output)

Parameters:

string   $type   —  (JPEG, PNG...);
int   $quality   —  75

[ Top ]

flip   [line 295]

TRUE flip( )

Vertical mirroring

Overrides Image_Transform::flip() (Vertical mirroring)
[ Top ]

free   [line 535]

void free( )

Destroys image handle
  • Access: public

Overrides Image_Transform::free() (Releases resource)
[ Top ]

gamma   [line 425]

bool|PEAR_Error gamma( [float $outputgamma = 1.0])

Adjusts the image gamma
  • Return: TRUE or a PEAR_Error object on error
  • Access: public

Overrides Image_Transform::gamma() (Corrects the gamma of an image)

Parameters:

float   $outputgamma   — 

[ Top ]

getHandle   [line 163]

resource getHandle( )

Returns the GD image handle
  • Access: public

Overrides Image_Transform::getHandle() (Returns the image handle so that one can further try to manipulate the image)
[ Top ]

greyscale   [line 362]

bool|PEAR_Error greyscale( )

Converts the image to greyscale
  • Return: TRUE or a PEAR_Error object on error
  • Access: public

Overrides Image_Transform::greyscale() (Converts an image into greyscale colors)
[ Top ]

load   [line 131]

bool|PEAR_Error load( string $image)

Loads an image from file
  • Return: TRUE or a PEAR_Error object on error
  • Access: public

Overrides Image_Transform::load() (Loads an image file to work with)

Parameters:

string   $image   —  filename

[ Top ]

mirror   [line 276]

mixed mirror( )

Horizontal mirroring

Overrides Image_Transform::mirror() (Horizontal mirroring)
[ Top ]

rotate   [line 251]

bool|PEAR_Error rotate( int $angle, [array $options = null])

Rotates image by the given angle

Uses a fast rotation algorythm for custom angles or lines copy for multiple of 90 degrees

  • Return: TRUE or a PEAR_Error object on error
  • Author: Pierre-Alain Joye
  • Access: public

Overridden in child classes as:

Image_Transform_Driver_GD1::rotate()

Overrides Image_Transform::rotate() (Rotates the image clockwise)

Parameters:

int   $angle   —  Rotation angle
array   $options   —  array( 'canvasColor' => array(r ,g, b), named color or #rrggbb )

[ Top ]

save   [line 521]

bool|PEAR_Error save( string $filename, [string $type = ''], [int $quality = null])

Saves the image to a file
  • Return: TRUE on success or PEAR_Error object on error
  • Access: public

Overrides Image_Transform::save() (Saves image to file)

Parameters:

string   $filename   —  the name of the file to write to
string   $type   —  the output format, default is the current used format
int   $quality   —  default is 75

[ Top ]

_createImage   [line 557]

resource _createImage( [int $width = -1], [int $height = -1], [bool $trueColor = null])

Returns a new image for temporary processing
  • Return: a GD image resource
  • Access: protected

Parameters:

int   $width   —  width of the new image
int   $height   —  height of the new image
bool   $trueColor   —  force which type of image to create

[ Top ]

_generate   [line 444]

bool|PEAR_Error _generate( string $filename, [ $type = ''], [int $quality = null], string $types)

Helper method to save to a file or output the image
  • Return: TRUE on success or PEAR_Error object on error
  • Access: protected

Parameters:

string   $filename   —  the name of the file to write to (blank to output)
string   $types   —  define the output format, default is the current used format
int   $quality   —  output DPI, default is 75
   $type   — 

[ Top ]

_resize   [line 384]

bool|PEAR_Error _resize( int $new_x, int $new_y, [array $options = null])

Resize Action

For GD 2.01+ the new copyresampled function is used It uses a bicubic interpolation algorithm to get far better result.

  • Return: TRUE on success or PEAR_Error object on error
  • Access: protected

Overrides Image_Transform::_resize() (Place holder for the real resize method used by extended methods to do the resizing)

Parameters:

int   $new_x   —  New width
int   $new_y   —  New height
array   $options   —  Optional parameters
  • 'scaleMethod': "pixel" or "smooth"

[ Top ]


Documentation generated on Mon, 11 Mar 2019 15:48:00 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.