| [ Index ] |
|
Code source de Typo3 4.1.3 |
[Code source] [Imprimer] [Statistiques]
Standard graphical functions $Id: class.t3lib_stdgraphic.php 2572 2007-10-16 16:07:41Z mundaun $ Revised for TYPO3 3.6 July/2003 by Kasper Skaarhoj
| Author: | Kasper Skaarhoj <kasperYYYY@typo3.com> |
| Poids: | 2951 lignes (102 kb) |
| Inclus ou requis: | 0 fois |
| Référencé: | 0 fois |
| Nécessite: | 0 fichiers |
t3lib_stdGraphic:: (66 méthodes):
init()
maskImageOntoImage()
copyImageOntoImage()
copyGifOntoGif()
imagecopyresized()
makeText()
txtPosition()
calcBBox()
addToMap()
calcTextCordsForMap()
SpacedImageTTFText()
fontResize()
ImageTTFBBoxWrapper()
ImageTTFTextWrapper()
splitString()
calcWordSpacing()
getTextScalFactor()
makeOutline()
circleOffset()
makeEmboss()
makeShadow()
makeBox()
makeEffect()
IMparams()
adjust()
crop()
scale()
setWorkArea()
autolevels()
outputLevels()
inputLevels()
reduceColors()
IMreduceColors()
prependAbsolutePath()
v5_sharpen()
v5_blur()
randomName()
applyOffset()
convertColor()
recodeString()
singleChars()
objPosition()
imageMagickConvert()
getImageDimensions()
cacheImageDimensions()
getCachedImageDimensions()
getImageScale()
file_exists_typo3temp_file()
imageMagickIdentify()
imageMagickExec()
combineExec()
wrapFileName()
checkFile()
createTempSubDir()
applyImageMagickToPHPGif()
gif_or_jpg()
output()
destroy()
imgTag()
ImageWrite()
imageGif()
imageCreateFromGif()
imageCreateFromFile()
imagecreate()
hexColor()
unifyColors()
Classe: t3lib_stdGraphic - X-Ref
Class contains a bunch of cool functions for manipulating graphics with GDlib/Freetype and ImageMagick| init() X-Ref |
| Init function. Must always call this when using the class. This function will read the configuration information from $GLOBALS['TYPO3_CONF_VARS']['GFX'] can set some values in internal variables. return: void |
| maskImageOntoImage(&$im,$conf,$workArea) X-Ref |
| Implements the "IMAGE" GIFBUILDER object, when the "mask" property is true. It reads the two images defined by $conf['file'] and $conf['mask'] and copies the $conf['file'] onto the input image pointer image using the $conf['mask'] as a grayscale mask The operation involves ImageMagick for combining. param: pointer GDlib image pointer param: array TypoScript array with configuration for the GIFBUILDER object. param: array The current working area coordinates. return: void |
| copyImageOntoImage(&$im,$conf,$workArea) X-Ref |
| Implements the "IMAGE" GIFBUILDER object, when the "mask" property is false (using only $conf['file']) param: pointer GDlib image pointer param: array TypoScript array with configuration for the GIFBUILDER object. param: array The current working area coordinates. return: void |
| copyGifOntoGif(&$im,$cpImg,$conf,$workArea) X-Ref |
| Copies two GDlib image pointers onto each other, using TypoScript configuration from $conf and the input $workArea definition. param: pointer GDlib image pointer, destination (bottom image) param: pointer GDlib image pointer, source (top image) param: array TypoScript array with the properties for the IMAGE GIFBUILDER object. Only used for the "tile" property value. param: array Work area return: void Works on the $im image pointer |
| imagecopyresized(&$im, $cpImg, $Xstart, $Ystart, $cpImgCutX, $cpImgCutY, $w, $h, $w, $h) X-Ref |
| Alternative function for using the similar PHP function imagecopyresized(). Used for GD2 only. OK, the reason for this stupid fix is the following story: GD1.x was capable of copying two images together and combining their palettes! GD2 is apparently not. With GD2 only the palette of the dest-image is used which mostly results in totally black images when trying to copy a color-ful image onto the destination. The GD2-fix is to 1) Create a blank TRUE-COLOR image 2) Copy the destination image onto that one 3) Then do the actual operation; Copying the source (top image) onto that 4) ... and return the result pointer. 5) Reduce colors (if we do not, the result may become strange!) It works, but the resulting images is now a true-color PNG which may be very large. So, why not use 'imagetruecolortopalette ($im, TRUE, 256)' - well because it does NOT WORK! So simple is that. For parameters, see PHP function "imagecopyresized()" param: pointer see PHP function "imagecopyresized()" param: pointer see PHP function "imagecopyresized()" param: integer see PHP function "imagecopyresized()" param: integer see PHP function "imagecopyresized()" param: integer see PHP function "imagecopyresized()" param: integer see PHP function "imagecopyresized()" param: integer see PHP function "imagecopyresized()" param: integer see PHP function "imagecopyresized()" param: integer see PHP function "imagecopyresized()" param: integer see PHP function "imagecopyresized()" return: void |
| makeText(&$im,$conf,$workArea) X-Ref |
| Implements the "TEXT" GIFBUILDER object param: pointer GDlib image pointer param: array TypoScript array with configuration for the GIFBUILDER object. param: array The current working area coordinates. return: void |
| txtPosition($conf,$workArea,$BB) X-Ref |
| Calculates text position for printing the text onto the image based on configuration like alignment and workarea. param: array TypoScript array for the TEXT GIFBUILDER object param: array Workarea definition param: array Bounding box information, was set in tslib_gifBuilder::start() return: array [0]=x, [1]=y, [2]=w, [3]=h |
| calcBBox($conf) X-Ref |
| Calculates bounding box information for the TEXT GIFBUILDER object. param: array TypoScript array for the TEXT GIFBUILDER object return: array Array with three keys [0]/[1] being x/y and [2] being the bounding box array |
| addToMap($cords,$conf) X-Ref |
| Adds an <area> tag to the internal variable $this->map which is used to accumulate the content for an ImageMap param: array Coordinates for a polygon image map as created by ->calcTextCordsForMap() param: array Configuration for "imgMap." property of a TEXT GIFBUILDER object. return: void |
| calcTextCordsForMap($cords,$offset, $conf) X-Ref |
| Calculating the coordinates for a TEXT string on an image map. Used in an <area> tag param: array Coordinates (from BBOX array) param: array Offset array param: array Configuration for "imgMap." property of a TEXT GIFBUILDER object. return: array |
| SpacedImageTTFText(&$im, $fontSize, $angle, $x, $y, $Fcolor, $fontFile, $text, $spacing, $wordSpacing, $splitRenderingConf, $sF=1) X-Ref |
| Printing text onto an image like the PHP function imageTTFText does but in addition it offers options for spacing of letters and words. Spacing is done by printing one char at a time and this means that the spacing is rather uneven and probably not very nice. See param: pointer (See argument for PHP function imageTTFtext()) param: integer (See argument for PHP function imageTTFtext()) param: integer (See argument for PHP function imageTTFtext()) param: integer (See argument for PHP function imageTTFtext()) param: integer (See argument for PHP function imageTTFtext()) param: integer (See argument for PHP function imageTTFtext()) param: string (See argument for PHP function imageTTFtext()) param: string (See argument for PHP function imageTTFtext()). UTF-8 string, possibly with entities in. param: integer The spacing of letters in pixels param: integer The spacing of words in pixels param: array $splitRenderingConf array param: integer Scale factor return: void |
| fontResize($conf) X-Ref |
| Function that finds the right fontsize that will render the textstring within a certain width author: Rene Fritz <r.fritz@colorcube.de> param: array The TypoScript properties of the TEXT GIFBUILDER object return: integer The new fontSize |
| ImageTTFBBoxWrapper($fontSize, $angle, $fontFile, $string, $splitRendering, $sF=1) X-Ref |
| Wrapper for ImageTTFBBox param: integer (See argument for PHP function ImageTTFBBox()) param: integer (See argument for PHP function ImageTTFBBox()) param: string (See argument for PHP function ImageTTFBBox()) param: string (See argument for PHP function ImageTTFBBox()) param: array Split-rendering configuration param: integer Scale factor return: array Information array. |
| ImageTTFTextWrapper($im, $fontSize, $angle, $x, $y, $color, $fontFile, $string, $splitRendering,$sF=1) X-Ref |
| Wrapper for ImageTTFText param: pointer (See argument for PHP function imageTTFtext()) param: integer (See argument for PHP function imageTTFtext()) param: integer (See argument for PHP function imageTTFtext()) param: integer (See argument for PHP function imageTTFtext()) param: integer (See argument for PHP function imageTTFtext()) param: integer (See argument for PHP function imageTTFtext()) param: string (See argument for PHP function imageTTFtext()) param: string (See argument for PHP function imageTTFtext()). UTF-8 string, possibly with entities in. param: array Split-rendering configuration param: integer Scale factor return: void |
| splitString($string,$splitRendering,$fontSize,$fontFile) X-Ref |
| Splitting a string for ImageTTFBBox up into an array where each part has its own configuration options. param: string UTF-8 string param: array Split-rendering configuration from GIFBUILDER TEXT object. param: integer Current fontsize param: string Current font file return: array Array with input string splitted according to configuration |
| calcWordSpacing($conf, $scaleFactor=1) X-Ref |
| Calculates the spacing and wordSpacing values param: array TypoScript array for the TEXT GIFBUILDER object param: integer TypoScript value from eg $conf['niceText.']['scaleFactor'] return: array Array with two keys [0]/[1] being array($spacing,$wordSpacing) |
| getTextScalFactor($conf) X-Ref |
| Calculates and returns the niceText.scaleFactor param: array TypoScript array for the TEXT GIFBUILDER object return: integer TypoScript value from eg $conf['niceText.']['scaleFactor'] |
| makeOutline(&$im,$conf,$workArea,$txtConf) X-Ref |
| Implements the "OUTLINE" GIFBUILDER object / property for the TEXT object param: pointer GDlib image pointer param: array TypoScript array with configuration for the GIFBUILDER object. param: array The current working area coordinates. param: array TypoScript array with configuration for the associated TEXT GIFBUILDER object. return: void |
| circleOffset($distance, $iterations) X-Ref |
| Creates some offset values in an array used to simulate a circularly applied outline around TEXT access private param: integer Distance param: integer Iterations. return: array |
| makeEmboss(&$im,$conf,$workArea,$txtConf) X-Ref |
| Implements the "EMBOSS" GIFBUILDER object / property for the TEXT object param: pointer GDlib image pointer param: array TypoScript array with configuration for the GIFBUILDER object. param: array The current working area coordinates. param: array TypoScript array with configuration for the associated TEXT GIFBUILDER object. return: void |
| makeShadow(&$im,$conf,$workArea,$txtConf) X-Ref |
| Implements the "SHADOW" GIFBUILDER object / property for the TEXT object The operation involves ImageMagick for combining. param: pointer GDlib image pointer param: array TypoScript array with configuration for the GIFBUILDER object. param: array The current working area coordinates. param: array TypoScript array with configuration for the associated TEXT GIFBUILDER object. return: void |
| makeBox(&$im,$conf,$workArea) X-Ref |
| Implements the "BOX" GIFBUILDER object param: pointer GDlib image pointer param: array TypoScript array with configuration for the GIFBUILDER object. param: array The current working area coordinates. return: void |
| makeEffect(&$im, $conf) X-Ref |
| Implements the "EFFECT" GIFBUILDER object The operation involves ImageMagick for applying effects param: pointer GDlib image pointer param: array TypoScript array with configuration for the GIFBUILDER object. return: void |
| IMparams($setup) X-Ref |
| Creating ImageMagick paramters from TypoScript property param: string A string with effect keywords=value pairs separated by "|" return: string ImageMagick prepared parameters. |
| adjust(&$im, $conf) X-Ref |
| Implements the "ADJUST" GIFBUILDER object param: pointer GDlib image pointer param: array TypoScript array with configuration for the GIFBUILDER object. return: void |
| crop(&$im,$conf) X-Ref |
| Implements the "CROP" GIFBUILDER object param: pointer GDlib image pointer param: array TypoScript array with configuration for the GIFBUILDER object. return: void |
| scale(&$im,$conf) X-Ref |
| Implements the "SCALE" GIFBUILDER object param: pointer GDlib image pointer param: array TypoScript array with configuration for the GIFBUILDER object. return: void |
| setWorkArea($workArea) X-Ref |
| Implements the "WORKAREA" GIFBUILDER object when setting it Setting internal working area boundaries (->workArea) param: string Working area dimensions, comma separated return: void |
| autolevels(&$im) X-Ref |
| Apply auto-levels to input image pointer param: integer GDlib Image Pointer return: void |
| outputLevels(&$im,$low,$high,$swap='') X-Ref |
| Apply output levels to input image pointer (decreasing contrast) param: integer GDlib Image Pointer param: integer The "low" value (close to 0) param: integer The "high" value (close to 255) param: boolean If swap, then low and high are swapped. (Useful for negated masks...) return: void |
| inputLevels(&$im,$low,$high,$swap='') X-Ref |
| Apply input levels to input image pointer (increasing contrast) param: integer GDlib Image Pointer param: integer The "low" value (close to 0) param: integer The "high" value (close to 255) param: boolean If swap, then low and high are swapped. (Useful for negated masks...) return: void |
| reduceColors(&$im,$limit, $cols) X-Ref |
| Reduce colors in image dependend on the actual amount of colors (Only works if we are not in truecolor mode) param: integer GDlib Image Pointer param: integer The max number of colors in the image before a reduction will happen; basically this means that IF the GD image current has the same amount or more colors than $limit define, THEN a reduction is performed. param: integer Number of colors to reduce the image to. return: void |
| IMreduceColors($file, $cols) X-Ref |
| Reduce colors in image using IM and create a palette based image if possible (<=256 colors) param: string Image file to reduce param: integer Number of colors to reduce the image to. return: string Reduced file |
| prependAbsolutePath($fontFile) X-Ref |
| Checks if the $fontFile is already at an absolute path and if not, prepends the correct path. Use PATH_site unless we are in the backend. Call it by t3lib_stdGraphic::prependAbsolutePath() param: string The font file return: string The font file with absolute path. |
| v5_sharpen($factor) X-Ref |
| Returns the IM command for sharpening with ImageMagick 5 (when $this->V5_EFFECTS is set). Uses $this->im5fx_sharpenSteps for translation of the factor to an actual command. param: integer The sharpening factor, 0-100 (effectively in 10 steps) return: string The sharpening command, eg. " -sharpen 3x4" |
| v5_blur($factor) X-Ref |
| Returns the IM command for blurring with ImageMagick 5 (when $this->V5_EFFECTS is set). Uses $this->im5fx_blurSteps for translation of the factor to an actual command. param: integer The blurring factor, 0-100 (effectively in 10 steps) return: string The blurring command, eg. " -blur 3x4" |
| randomName() X-Ref |
| Returns a random filename prefixed with "temp_" and then 32 char md5 hash (without extension) from $this->tempPath. Used by functions in this class to create truely temporary files for the on-the-fly processing. These files will most likely be deleted right away. return: string |
| applyOffset($cords,$OFFSET) X-Ref |
| Applies offset value to coordinated in $cords. Basically the value of key 0/1 of $OFFSET is added to keys 0/1 of $cords param: array Integer coordinates in key 0/1 param: array Offset values in key 0/1 return: array Modified $cords array |
| convertColor($string) X-Ref |
| Converts a "HTML-color" TypoScript datatype to RGB-values. Default is 0,0,0 param: string "HTML-color" data type string, eg. 'red', '#ffeedd' or '255,0,255'. You can also add a modifying operator afterwards. There are two options: "255,0,255 : 20" - will add 20 to values, result is "255,20,255". Or "255,0,255 : *1.23" which will multiply all RGB values with 1.23 return: array RGB values in key 0/1/2 of the array |
| recodeString($string) X-Ref |
| Recode string Used with text strings for fonts when languages has other character sets. param: string The text to recode return: string The recoded string. Should be UTF-8 output. MAY contain entities (eg. { or &#quot; which should render as real chars). |
| singleChars($theText,$returnUnicodeNumber=FALSE) X-Ref |
| Split a string into an array of individual characters The function will look at $this->nativeCharset and if that is set, the input string is expected to be UTF-8 encoded, possibly with entities in it. Otherwise the string is supposed to be a single-byte charset which is just splitted by a for-loop. param: string The text string to split param: boolean Return Unicode numbers instead of chars. return: array Numerical array with a char as each value. |
| objPosition($conf,$workArea,$BB) X-Ref |
| Create an array with object position/boundaries based on input TypoScript configuration (such as the "align" property is used), the work area definition and $BB array param: array TypoScript configuration for a GIFBUILDER object param: array Workarea definition param: array BB (Bounding box) array. Not just used for TEXT objects but also for others return: array [0]=x, [1]=y, [2]=w, [3]=h |
| imageMagickConvert($imagefile,$newExt='',$w='',$h='',$params='',$frame='',$options='',$mustCreate=0) X-Ref |
| Converts $imagefile to another file in temp-dir of type $newExt (extension). param: string The image filepath param: string New extension, eg. "gif", "png", "jpg", "tif". If $newExt is NOT set, the new imagefile will be of the original format. If newExt = 'WEB' then one of the web-formats is applied. param: string Width. $w / $h is optional. If only one is given the image is scaled proportionally. If an 'm' exists in the $w or $h and if both are present the $w and $h is regarded as the Maximum w/h and the proportions will be kept param: string Height. See $w param: string Additional ImageMagick parameters. param: string Refers to which frame-number to select in the image. '' or 0 will select the first frame, 1 will select the next and so on... param: array An array with options passed to getImageScale (see this function). param: boolean If set, then another image than the input imagefile MUST be returned. Otherwise you can risk that the input image is good enough regarding messures etc and is of course not rendered to a new, temporary file in typo3temp/. But this option will force it to. return: array [0]/[1] is w/h, [2] is file extension and [3] is the filename. |
| getImageDimensions($imageFile) X-Ref |
| Gets the input image dimensions. param: string The image filepath return: array Returns an array where [0]/[1] is w/h, [2] is extension and [3] is the filename. |
| cacheImageDimensions($identifyResult) X-Ref |
| Cache the result of the getImageDimensions function into the database. Does not check if the file exists! author: Michael Stucki <michael@typo3.org> / Robert Lemke <rl@robertlemke.de> param: array $identifyResult: Result of the getImageDimensions function return: boolean True if operation was successful |
| getCachedImageDimensions($imageFile) X-Ref |
| Fetch the cached imageDimensions from the MySQL database. Does not check if the image file exists! author: Michael Stucki <michael@typo3.org> / Robert Lemke <rl@robertlemke.de> param: string The image filepath return: array Returns an array where [0]/[1] is w/h, [2] is extension and [3] is the filename. |
| getImageScale($info,$w,$h,$options) X-Ref |
| Get numbers for scaling the image based on input param: array Current image information: Width, Height etc. param: integer "required" width param: integer "required" height param: array Options: Keys are like "maxW", "maxH", "minW", "minH" return: array |
| file_exists_typo3temp_file($output,$orig='') X-Ref |
| Used to check if a certain process of scaling an image is already being carried out (can be logged in the SQL database) param: string Output imagefile param: string Original basis file return: boolean Returns true if the file is already being made; thus "true" means "Don't render the image again" |
| imageMagickIdentify($imagefile) X-Ref |
| Returns an array where [0]/[1] is w/h, [2] is extension and [3] is the filename. Using ImageMagick param: string The relative (to PATH_site) image filepath return: array |
| imageMagickExec($input,$output,$params) X-Ref |
| Executes a ImageMagick "convert" on two filenames, $input and $output using $params before them. Can be used for many things, mostly scaling and effects. param: string The relative (to PATH_site) image filepath, input file (read from) param: string The relative (to PATH_site) image filepath, output filename (written to) param: string ImageMagick parameters return: string The result of a call to PHP function "exec()" |
| combineExec($input,$overlay,$mask,$output, $handleNegation = false) X-Ref |
| Executes a ImageMagick "combine" (or composite in newer times) on four filenames - $input, $overlay and $mask as input files and $output as the output filename (written to) Can be used for many things, mostly scaling and effects. param: string The relative (to PATH_site) image filepath, bottom file param: string The relative (to PATH_site) image filepath, overlay file (top) param: string The relative (to PATH_site) image filepath, the mask file (grayscale) param: string The relative (to PATH_site) image filepath, output filename (written to) param: [type] $handleNegation: ... return: void |
| wrapFileName($inputName) X-Ref |
| Wrapping the input filename in double-quotes param: string Input filename return: string The output wrapped in "" (if there are spaces in the filepath) |
| checkFile($file) X-Ref |
| Returns true if the input file existed param: string Input file to check return: string Returns the filename if the file existed, otherwise empty. |
| createTempSubDir($dirName) X-Ref |
| Creates subdirectory in typo3temp/ if not already found. param: string Name of sub directory return: boolean Result of t3lib_div::mkdir(), true if it went well. |
| applyImageMagickToPHPGif(&$im, $command) X-Ref |
| Applies an ImageMagick parameter to a GDlib image pointer resource by writing the resource to file, performing an IM operation upon it and reading back the result into the ImagePointer. param: pointer The image pointer (reference) param: string The ImageMagick parameters. Like effects, scaling etc. return: void |
| gif_or_jpg($type,$w,$h) X-Ref |
| Returns an image extension for an output image based on the number of pixels of the output and the file extension of the original file. For example: If the number of pixels exceeds $this->pixelLimitGif (normally 10000) then it will be a "jpg" string in return. param: string The file extension, lowercase. param: integer The width of the output image. param: integer The height of the output image. return: string The filename, either "jpg" or "gif"/"png" (whatever $this->gifExtension is set to.) |
| output($file) X-Ref |
| Writing the internal image pointer, $this->im, to file based on the extension of the input filename Used in GIFBUILDER Uses $this->setup['reduceColors'] for gif/png images and $this->setup['quality'] for jpg images to reduce size/quality if needed. param: string The filename to write to. return: string Returns input filename |
| destroy() X-Ref |
| Destroy internal image pointer, $this->im return: void |
| imgTag($imgInfo) X-Ref |
| Returns Image Tag for input image information array. param: array Image information array, key 0/1 is width/height and key 3 is the src value return: string Image tag for the input image information array. |
| ImageWrite($destImg, $theImage, $quality=0) X-Ref |
| Writes the input GDlib image pointer to file param: pointer The GDlib image resource pointer param: string The filename to write to param: integer The image quality (for JPEGs) return: mixed The output of either imageGif, imagePng or imageJpeg based on the filename to write |
| imageGif($destImg, $theImage) X-Ref |
| Writes the input GDlib image pointer to file. Now just a wrapper to ImageWrite. param: pointer The GDlib image resource pointer param: string The filename to write to return: mixed The output of either imageGif, imagePng or imageJpeg based on the filename to write |
| imageCreateFromGif($sourceImg) X-Ref |
| This function has been renamed and only exists for providing backwards compatibility. Please use $this->imageCreateFromFile() instead. param: string Image filename return: pointer Image Resource pointer |
| imageCreateFromFile($sourceImg) X-Ref |
| Creates a new GDlib image resource based on the input image filename. If it fails creating a image from the input file a blank gray image with the dimensions of the input image will be created instead. param: string Image filename return: pointer Image Resource pointer |
| imagecreate($w, $h) X-Ref |
| Creates a new GD image resource. Wrapper for imagecreate(truecolor) depended if GD2 is used. param: integer Width of image param: integer Height of image return: pointer Image Resource pointer |
| hexColor($col) X-Ref |
| Returns the HEX color value for an RGB color array param: array RGB color array return: string HEX color value |
| unifyColors(&$img, $colArr, $closest = false) X-Ref |
| Unifies all colors given in the colArr color array to the first color in the array. param: pointer Image resource param: array Array containing RGB color arrays param: [type] $closest: ... return: integer The index of the unified color |
| Généré le : Sun Nov 25 17:13:16 2007 | par Balluche grâce à PHPXref 0.7 |
|