Class ImageEditor

Description

Handles the basic image editing capbabilities.

  • version: $Id: ImageEditor.php 27 2004-04-01 08:31:57Z Wei Zhuo $
  • author: $Author: Wei Zhuo $

Located in /plugins/ImageManager/Classes/ImageEditor.php (line 18)


	
			
Variable Summary
 mixed $filesaved
 mixed $lapse_time
 mixed $manager
 mixed $_uid
Method Summary
 ImageEditor ImageEditor (ImageManager $manager)
 void cleanUp (string $path, mixed $file)
 string createUnique (string $file)
 string getAction ()
 string getDefaultSaveFile ()
 string getImageType (string $file)
 string getSaveFileName (string $type)
 string getUniqueFilename (string $relative)
 int isFileSaved ()
 int isGDEditable ()
 int isGDGIFAble ()
 string makeRelative (string $pathA, string $file)
 array processAction (mixed $action, string $relative, string $fullpath, string $action,)
 array processImage ()
 string uniqueStr ()
Variables
mixed $filesaved = 0 (line 35)
mixed $lapse_time = 900 (line 33)

tmp file storage time.

mixed $manager (line 23)

ImageManager instance.

mixed $_uid (line 28)

user based on IP address

Methods
Constructor ImageEditor (line 47)

Create a new ImageEditor instance. Editing requires a

tmp file, which is saved in the current directory where the image is edited. The tmp file is assigned by md5 hash of the user IP address. This hashed is used as an ID for cleaning up the tmp files. In addition, any tmp files older than the the specified period will be deleted.

ImageEditor ImageEditor (ImageManager $manager)
  • ImageManager $manager: the image manager, we need this for some file and path handling functions.
cleanUp (line 342)

Delete any tmp image files.

void cleanUp (string $path, mixed $file)
  • string $path: the full path where the clean should take place.
createUnique (line 318)

Create unique tmp image file name.

The filename is based on the tmp file prefix specified in config.inc.php plus the UID (basically a md5 of the remote IP) and some random 6 character string. This function also calls to clean up the tmp files.

  • return: a unique filename for that path NOTE: it only returns the filename, path no included.
string createUnique (string $file)
  • string $file: the fullpath to a file
getAction (line 289)

Get the action GET parameter

  • return: action parameter
string getAction ()
getDefaultSaveFile (line 220)

Get the default save file name, used by editor.php.

  • return: a suggestive filename, this should be unique
string getDefaultSaveFile ()
getImageType (line 380)

Get the image type base on an image file.

  • return: of either 'gif', 'jpeg', 'png' or 'bmp' otherwise it will return null.
string getImageType (string $file)
  • string $file: the full path to the image file.
getSaveFileName (line 194)

Get the file name base on the save name and the save type.

  • return: the filename according to save type
string getSaveFileName (string $type)
  • string $type: image type, 'jpeg', 'png', or 'gif'
getUniqueFilename (line 236)

Get a unique filename. If the file exists, the filename base is appended with an increasing integer.

  • return: a unique filename in the current path
string getUniqueFilename (string $relative)
  • string $relative: the relative filename to the base_dir
isFileSaved (line 58)

Did we save a file?

  • return: 1 if the file was saved sucessfully,
    1. no save operation, -1 file save error.
int isFileSaved ()
isGDEditable (line 407)

Check if the specified image can be edit by GD

mainly to check that GD can read and save GIFs

  • return: 0 if it is not a GIF file, 1 is GIF is editable, -1 if not editable.
int isGDEditable ()
isGDGIFAble (line 433)

Check if GIF can be edit by GD.

  • return: 0 if it is not using the GD library, 1 is GIF is editable, -1 if not editable.
int isGDGIFAble ()
makeRelative (line 275)

Specifiy the original relative path, a new filename and return the new filename with relative path.

i.e. $pathA (-filename) + $file

  • return: relative path with the new filename
string makeRelative (string $pathA, string $file)
  • string $pathA: the relative file
  • string $file: the new filename
processAction (line 114)

Process the actions, crop, scale(resize), rotate, flip, and save.

When ever an action is performed, the result is save into a temporary image file, see createUnique on the filename specs. It does not return the saved file, alway returning the tmp file.

  • return: with image information
    1. array('src'=>'url of the image', 'dimensions'=>'width="xx" height="yy"',
    2. 'file'=>'image file, relative', 'fullpath'=>'full path to the image');
array processAction (mixed $action, string $relative, string $fullpath, string $action,)
  • string $action,: should be 'crop', 'scale', 'rotate','flip', or 'save'
  • string $relative: the relative image filename
  • string $fullpath: the fullpath to the image file
processImage (line 69)

Process the image, if not action, just display the image.

  • return: with image information, empty array if not an image.
    1. array('src'=>'url of the image', 'dimensions'=>'width="xx" height="yy"',
    2. 'file'=>'image file, relative', 'fullpath'=>'full path to the image');
array processImage ()
uniqueStr (line 302)

Generate a unique string based on md5(microtime()).

Well not so uniqe, as it is limited to 6 characters

  • return: unique string.
string uniqueStr ()

Documentation generated on Sat, 31 Dec 2005 14:56:53 -0500 by phpDocumentor 1.3.0RC3