Class: GdFunctionality
Source Location: /modules/gd/classes/GdFunctionality.class
Class GdFunctionality
Class Overview
|
All image functions from the GD library are implemented here.
Every call to these functions should go through this class. Errors are handled the Gallery-way (GalleryStatus) and it provides an easy way to test the Toolkit (by using an implementation with pseudo-functionality instead of this class).
Located in /modules/gd/classes/GdFunctionality.class [line 43]
|
Methods
|
Method Summary
| array |
checkResource() |
Check if a resource that is based on $filename is valid |
| boolean |
chmod() |
Set file permissions according to preferences |
| string |
copy() |
The copy method from GalleryPlatform, which we need to be able to overwrite in tests |
| int |
filesize() |
The filesize method from GalleryPlatform, which we need to be able to overwrite in tests |
| array |
gd_info() |
Return an array of information about the currently installed GD version |
| array |
getImageSize() |
Return the size (width, height) of an image file. |
| array |
imageCreate() |
Create a new palette based image with specified width and height |
| array |
imagesavealpha() |
Set the flag to save full alpha channel information (as opposed to single-color transparency) when saving PNG images |
| int |
imageTypes() |
Return an integer representing the known imageTypes |
| boolean |
isValidFile() |
Helper functionality to see if a filename is readable |
| string |
tempnam() |
The tempnam method from the GalleryPlatform we will need to overwrite in our testcases |
| string |
unlink() |
The unlink method from GalleryPlatform, which we need to be able to overwrite in tests |
Methods
array checkResource(
$res,
$filename
)
|
|
Check if a resource that is based on $filename is valid
Parameters:
API Tags:
| Return: | GalleryStatus resource GD resource |
boolean chmod(
string
$file
)
|
|
Set file permissions according to preferences
Parameters:
API Tags:
string copy(
$src,
$dest
)
|
|
The copy method from GalleryPlatform, which we need to be able to overwrite in tests
Parameters:
The filesize method from GalleryPlatform, which we need to be able to overwrite in tests
Parameters:
boolean functionExists(
$fct
)
|
|
Just check if a function exists or not.
This is here so we can substitute the function-checker routine in our phpunit testcases.
Parameters:
API Tags:
Return an array of information about the currently installed GD version
Requires:
API Tags:
| Return: | GalleryStatus array the output of gd_info |
array getImageSize(
$filename
)
|
|
Return the size (width, height) of an image file.
Parameters:
API Tags:
bool imagealphablending(
resource
$res, bool
$blendmode
)
|
|
Set the blending mode for an image
Parameters:
|
resource |
$res: |
|
|
bool |
$blendmode: |
|
API Tags:
| Return: | true on success, false on failure |
int imagecolorallocate(
resource
$res, int
$red, int
$green, int
$blue
)
|
|
Allocate a color for an image.
Parameters:
|
resource |
$res: |
|
|
int |
$red: |
|
|
int |
$green: |
|
|
int |
$blue: |
|
API Tags:
| Return: | a color identifier, false on failure |
array imagecolorallocatealpha(
resource
$res, int
$red, int
$green, int
$blue, int
$alpha
)
|
|
Allocate a color for an image.
Requires:
Parameters:
|
resource |
$res: |
|
|
int |
$red: |
|
|
int |
$green: |
|
|
int |
$blue: |
|
|
int |
$alpha: |
|
API Tags:
| Return: | GalleryStatus int a color identifier, false on failure |
int imagecolorat(
resource
$res, int
$x, int
$y
)
|
|
Get the index of the color of a pixel.
Parameters:
|
resource |
$res: |
|
|
int |
$x: |
|
|
int |
$y: |
|
API Tags:
| Return: | The index of the color |
array('red' imagecolorsforindex(
resource
$res, int
$index
)
|
|
Get the colors for an index.
Parameters:
|
resource |
$res: |
|
|
int |
$index: |
|
API Tags:
| Return: | => int, 'green' => int, 'blue' => int, 'alpha' => int) |
The imagecolortransparent(
resource
$res, [int
$color = null]
)
|
|
Get / set the transparent color.
Parameters:
|
resource |
$res: |
|
|
int |
$color: |
(optional) A color identifier |
API Tags:
| Return: | identifier of the new (or current, if none is specified) transparent color. |
GalleryStatus imageCopy(
$dstRes,
$srcRes,
$dstX,
$dstY,
$srcX,
$srcY,
$srcW,
$srcH
)
|
|
Copy part of an image
Requires:
Parameters:
|
|
$dstRes: |
|
|
|
$srcRes: |
|
|
|
$dstX: |
|
|
|
$dstY: |
|
|
|
$srcX: |
|
|
|
$srcY: |
|
|
|
$srcW: |
|
|
|
$srcH: |
|
GalleryStatus imageCopyMerge(
$dstRes,
$srcRes,
$dstX,
$dstY,
$srcX,
$srcY,
$srcW,
$srcH,
$pct
)
|
|
Copy and merge part of an image
Requires:
Parameters:
|
|
$dstRes: |
|
|
|
$srcRes: |
|
|
|
$dstX: |
|
|
|
$dstY: |
|
|
|
$srcX: |
|
|
|
$srcY: |
|
|
|
$srcW: |
|
|
|
$srcH: |
|
|
|
$pct: |
|
GalleryStatus imageCopyResampled(
$dstRes,
$srcRes,
$dstX,
$dstY,
$srcX,
$srcY,
$dstW,
$dstH,
$srcW,
$srcH
)
|
|
Copy and resize part of an image with resampling
Requires: - PHP 4 >= 4.0.6 or PHP 5
- GD >= 2.0.1
Parameters:
|
|
$dstRes: |
|
|
|
$srcRes: |
|
|
|
$dstX: |
|
|
|
$dstY: |
|
|
|
$srcX: |
|
|
|
$srcY: |
|
|
|
$dstW: |
|
|
|
$dstH: |
|
|
|
$srcW: |
|
|
|
$srcH: |
|
GalleryStatus imageCopyResized(
$dstRes,
$srcRes,
$dstX,
$dstY,
$srcX,
$srcY,
$dstW,
$dstH,
$srcW,
$srcH
)
|
|
Copy and resize part of an image
Requires:
Parameters:
|
|
$dstRes: |
|
|
|
$srcRes: |
|
|
|
$dstX: |
|
|
|
$dstY: |
|
|
|
$srcX: |
|
|
|
$srcY: |
|
|
|
$dstW: |
|
|
|
$dstH: |
|
|
|
$srcW: |
|
|
|
$srcH: |
|
array imageCreate(
$width,
$height
)
|
|
Create a new palette based image with specified width and height
Requires:
Parameters:
API Tags:
| Return: | GalleryStatus res GD-resource |
array imageCreateFromGif(
$filename
)
|
|
Create a new image from GIF file or URL.
Requires - any PHP version
- GD with GIF support
Parameters:
API Tags:
| Return: | GalleryStatus res GD-resource |
array imageCreateFromJpeg(
$filename
)
|
|
Create a new image from JPEG file or URL.
Requires: - any PHP >= 3.0.16
- GD >= 1.8 (for JPEG support)
Parameters:
API Tags:
| Return: | GalleryStatus res GD-resource |
array imageCreateFromPng(
$filename
)
|
|
Create a new image from PNG file or URL.
Requires: - any PHP >= 3.0.13
- GD (with PNG support)
Parameters:
API Tags:
| Return: | GalleryStatus res GD-resource |
array imageCreateFromWbmp(
$filename
)
|
|
Create a new image from WBMP (wap-bmp) file or URL.
Requires: - PHP 4 >= 4.0.1 or PHP 5
- GD >= 1.8 (for WBMP support)
Parameters:
API Tags:
| Return: | GalleryStatus res GD-resource |
array imageCreateFromXbm(
$filename
)
|
|
Create a new image from XBM file or URL.
Requires: - PHP 4 >= 4.0.1 or PHP 5
- GD
Parameters:
API Tags:
| Return: | GalleryStatus res GD-resource |
array imageCreateFromXpm(
$filename
)
|
|
Create a new image from XPM file or URL.
Requires: - PHP 4 >= 4.0.1 or PHP 5
- GD
Parameters:
API Tags:
| Return: | GalleryStatus res GD-resource |
array imageCreateTruecolor(
$width,
$height
)
|
|
Create a new true color image with specified width and height
Requires: - PHP 4 >= 4.0.6 or PHP 5
- GD >= 2.0.1
Danger: The imageCreateTruecolor() function is defined even if the GD library does not support it! If called in this situation, the call will generate a "Fatal error", which cannot be catched. So we have to make sure to call this method ONLY if we are sure to have GD >= 2.0.1 (which at the current stage of this module will always be the case, since this is the minimal required version).
Parameters:
API Tags:
| Return: | GalleryStatus res GD-resource |
void imagedestroy(
object
$res
)
|
|
Destroy an image
Parameters:
|
object |
$res: |
image resource |
bool imagefilledrectangle(
resource
$res, int
$x1, int
$y1, int
$x2, int
$y2,
$color
)
|
|
Draw a filled rectangle spanned by 2 points.
Parameters:
|
resource |
$res: |
|
|
int |
$x1: |
x coordinate of point 1 |
|
int |
$y1: |
y coordinate of point 1 |
|
int |
$x2: |
x coordinate of point 2 |
|
int |
$y2: |
y coordinate of point 2 |
|
|
$color: |
|
API Tags:
| Return: | true on success, false on failure |
Output GIF image to file.
Requires: - any PHP
- GD with GIF support
Parameters:
Output JPEG image to file.
Requires: - any PHP >= 3.0.16
- GD >= 1.8
Parameters:
|
|
$res: |
|
|
|
$filename: |
|
|
|
$quality: |
|
Output PNG image to file.
Requires:
Parameters:
array imageRotate(
$srcRes,
$angle,
$bgdColor
)
|
|
Copy and merge part of an image
Requires:
Parameters:
|
|
$srcRes: |
|
|
|
$angle: |
|
|
|
$bgdColor: |
|
API Tags:
| Return: | GalleryStatus resource new gd resource |
array imagesavealpha(
resource
$res,
$saveflag, bool
$saveFlag
)
|
|
Set the flag to save full alpha channel information (as opposed to single-color transparency) when saving PNG images
Requires:
Parameters:
|
resource |
$res: |
|
|
bool |
$saveFlag: |
|
|
|
$saveflag: |
|
API Tags:
| Return: | GalleryStatus bool true on success, false on failure |
bool imagesetpixel(
resource
$res, int
$x, int
$y, int
$color
)
|
|
set the color of a pixel.
Parameters:
|
resource |
$res: |
|
|
int |
$x: |
|
|
int |
$y: |
|
|
int |
$color: |
A color identifier |
API Tags:
| Return: | true on success, false on failure |
Get image width
Parameters:
API Tags:
| Return: | the width of the image |
Get image height
Parameters:
API Tags:
| Return: | the height of the image |
true imagetruecolortopalette(
resource
$res, bool
$dither, int
$ncolors
)
|
|
Convert a true color image to a palette image.
Parameters:
|
resource |
$res: |
|
|
bool |
$dither: |
|
|
int |
$ncolors: |
|
API Tags:
| Return: | on success, false on failure |
Return an integer representing the known imageTypes
Output WBMP image to file.
Requires: - PHP 3>= 3.0.15 or PHP 4 >= 4.0.1 or PHP 5
- GD >= 1.8 (for WBMP support)
Parameters:
Output XBM image to file.
Requires:
Parameters:
boolean isValidFile(
$filename
)
|
|
Helper functionality to see if a filename is readable
Parameters:
array phpinfo(
[
$section = null]
)
|
|
Parameters:
API Tags:
| Return: | GalleryStatus string phpinfo output |
string tempnam(
$tmpDir,
$prefix
)
|
|
The tempnam method from the GalleryPlatform we will need to overwrite in our testcases
Parameters:
The unlink method from GalleryPlatform, which we need to be able to overwrite in tests
Parameters:
|
|