wCMF  3.6
 All Classes Namespaces Files Functions Variables Groups Pages
GraphicsUtil Class Reference

Public Member Functions

 getErrorMsg ()
 
 isImage ($imgname)
 
 isValidImageDimension ($imgname, $width, $height, $exact=true)
 
 isValidImageWidth ($imgname, $width, $exact=true)
 
 isValidImageHeight ($imgname, $height, $exact=true)
 
 fitIntoSquare ($srcName, $maxDimension)
 
 createThumbnail ($srcName, $destName, $width, $height)
 
 cropImage ($srcName, $destName, $width, $height, $x=null, $y=null)
 
 createBlackWhiteImage ($srcName, $destName)
 
 processImageFunction ($srcName, $destName, $function, $params)
 
 renderTextTTF ($text, $fontfile, $fontsize, $color, $bgcolor, $filename, $width=null, $height=null, $x=null, $y=null, $angle=0)
 
 getTextDimension ($fontsize, $angle, $fontfile, $text)
 
 calculateTextParams ($width, $height, $x, $y, $textwidth, $textheight)
 
 calculateSizeParams ($width, $height, $imageWidth, $imageHeight)
 

Public Attributes

 $_errorMsg = ''
 

Detailed Description

GraphicsUtil provides support for graphic manipulation.

wCMF - wemove Content Management Framework Copyright (C) 2005-2014 wemove digital solutions GmbH

Licensed under the terms of any of the following licenses at your choice:

See the license.txt file distributed with this work for additional information.

Id:
class.GraphicsUtil.php 1462 2014-02-04 23:52:27Z iherwig
Author
ingo herwig ingo@.nosp@m.wemo.nosp@m.ve.co.nosp@m.m

Definition at line 30 of file class.GraphicsUtil.php.

Member Function Documentation

GraphicsUtil::getErrorMsg ( )

Get last error message.

Returns
The error string

Definition at line 38 of file class.GraphicsUtil.php.

References $_errorMsg.

GraphicsUtil::isImage (   $imgname)

Check if a given file is an image.

Parameters
imgnameName of the imagefile to check
Returns
Boolean whether the file is an image

Definition at line 48 of file class.GraphicsUtil.php.

GraphicsUtil::isValidImageDimension (   $imgname,
  $width,
  $height,
  $exact = true 
)

Check image dimensions.

Parameters
imgnameName of the imagefile to check
widthWidth of the image, -1 means don't care
heightHeight of the image, -1 means don't care
exactBoolean whether the image should match the dimension exactly or might be smaller [default: true]
Returns
Boolean whether the image meets the dimensions, error string provided by getErrorMsg()

Definition at line 66 of file class.GraphicsUtil.php.

References isValidImageHeight(), and isValidImageWidth().

+ Here is the call graph for this function:

GraphicsUtil::isValidImageWidth (   $imgname,
  $width,
  $exact = true 
)

Check image width.

Parameters
imgnameName of the imagefile to check
widthWidth of the image
exactBoolean whether the image width should match exactly or might be smaller [default: true]
Returns
Boolean whether the image width meets the criteria, error string provided by getErrorMsg()
Note
This method returns true if the file does not exist.

Definition at line 81 of file class.GraphicsUtil.php.

References Message\get().

Referenced by isValidImageDimension().

+ Here is the call graph for this function:

GraphicsUtil::isValidImageHeight (   $imgname,
  $height,
  $exact = true 
)

Check image height.

Parameters
imgnameName of the imagefile to check
heightHeight of the image
exactBoolean whether the image height should match exactly or might be smaller [default: true]
Returns
Boolean whether the image width meets the criteria, error string provided by getErrorMsg()
Note
This method returns true if the file does not exist.

Definition at line 107 of file class.GraphicsUtil.php.

References Message\get().

Referenced by isValidImageDimension().

+ Here is the call graph for this function:

GraphicsUtil::fitIntoSquare (   $srcName,
  $maxDimension 
)

Calculate image dimension to fit into a square, preserving the aspect ratio

Parameters
srcNameThe source file name
maxDimensionThe maximum dimension the image should have (either width or height)
Returns
Array with width and height value or null, on error, error string provided by getErrorMsg()

Definition at line 131 of file class.GraphicsUtil.php.

GraphicsUtil::createThumbnail (   $srcName,
  $destName,
  $width,
  $height 
)

Create a thumbnail of an image file.

Parameters
srcNameThe source file name
destNameThe destination file name
widthThe width of the thumbnail (maybe null)
heightThe height of the thumbnail (maybe null)
Returns
Boolean whether the operation succeeded, error string provided by getErrorMsg()
Note
: supported image formats are GIF, JPG, PNG if only width or height are given the other dimension is calculated to preserve the aspect

Definition at line 167 of file class.GraphicsUtil.php.

GraphicsUtil::cropImage (   $srcName,
  $destName,
  $width,
  $height,
  $x = null,
  $y = null 
)

Crop an image to the given size starting from the middle of a given start point.

Parameters
srcNameThe source file name
destNameThe destination file name
widthThe width of the cropped image (maybe null)
heightThe height of the cropped image (maybe null)
xThe start point x coordinate (maybe null, default null)
yThe start point y coordinate (maybe null, default null)
Returns
Boolean whether the operation succeeded, error string provided by getErrorMsg()
Note
: supported image formats are GIF, JPG, PNG if only width or height are given the other dimension is taken from the original image

Definition at line 191 of file class.GraphicsUtil.php.

GraphicsUtil::createBlackWhiteImage (   $srcName,
  $destName 
)

Create a black and white copy of an image.

Parameters
srcNameThe source file name
destNameThe destination file name

Definition at line 213 of file class.GraphicsUtil.php.

GraphicsUtil::processImageFunction (   $srcName,
  $destName,
  $function,
  $params 
)

Process the given function on the given source image (supports animated gifs) and save the result in the given destination image.

Parameters
srcNameThe source file name
destNameThe destination file name
functionThe name of the function
paramsThe paremeters to be passed to the function

Definition at line 232 of file class.GraphicsUtil.php.

GraphicsUtil::renderTextTTF (   $text,
  $fontfile,
  $fontsize,
  $color,
  $bgcolor,
  $filename,
  $width = null,
  $height = null,
  $x = null,
  $y = null,
  $angle = 0 
)

Render a text to an image. Using the default parameters the text will be rendered into a box that fits the text. If the width parameter is not null and the text exceeds the width, the text will be wrapped and the height parameter will be used as lineheight. Wrapping code is from http://de.php.net/manual/de/function.imagettfbbox.php#60673

Parameters
textThe text to render
fontfileThe font file to use
fontsizeThe font size to use (in pixels)
colorThe color to use for the text (as HEX value)
bgcolorThe color to use for the background (as HEX value)
filenameThe name of the file to write to
widthThe width of the image (or null if it should fit the text) [default: null]
heightThe height of the image (or null if it should fit the text) [default: null]
xThe x offset of the text (or null if it should be centered) [default: null]
yThe y offset of the text (or null if the baseline should be the image border) [default: null]
angleThe angle of the text (optional) [default: 0]
Returns
Boolean whether the operation succeeded, error string provided by getErrorMsg()

Definition at line 275 of file class.GraphicsUtil.php.

GraphicsUtil::getTextDimension (   $fontsize,
  $angle,
  $fontfile,
  $text 
)

Calculate the dimension of the given text

Parameters
fontsizeThe font size (in pixels)
angleThe angle of the characters (optional) [default: 0]
fontfileThe font file
textThe text
Returns
An array with the width and height values

Definition at line 376 of file class.GraphicsUtil.php.

GraphicsUtil::calculateTextParams (   $width,
  $height,
  $x,
  $y,
  $textwidth,
  $textheight 
)

Calculate the offset of the text and the size of the image based on the given parameters

Parameters
widthThe width of the image (or null if it should be the textwidth)
heightThe height of the image (or null if it should be the textheight)
xThe x offset of the text (or null if it should be centered)
yThe y offset of the text (or null if the baseline should be the image border)
textwidthThe width of the text
textheightThe height of the text
Returns
An array with width, height, x, y values

Definition at line 392 of file class.GraphicsUtil.php.

GraphicsUtil::calculateSizeParams (   $width,
  $height,
  $imageWidth,
  $imageHeight 
)

Calculate the size based on the image aspect, if only width or height are given.

Parameters
widthThe requested width (maybe null)
heightThe requested height (maybe null)
imageWidthThe image's width
imageHeightThe image's height
Returns
Array with width, height

Definition at line 414 of file class.GraphicsUtil.php.

Member Data Documentation

GraphicsUtil::$_errorMsg = ''

Definition at line 32 of file class.GraphicsUtil.php.

Referenced by getErrorMsg().


The documentation for this class was generated from the following file: