image_gd_info () | |
image_gd_settings () | |
image_gd_settings_validate ($form, &$form_state) | |
image_gd_check_settings () | |
image_gd_resize ($source, $destination, $width, $height) | |
image_gd_rotate ($source, $destination, $degrees, $background=0x000000) | |
image_gd_crop ($source, $destination, $x, $y, $width, $height) | |
image_gd_open ($file, $extension) | |
image_gd_close ($res, $destination, $extension) | |
Functions | |
image_get_available_toolkits () | |
image_get_toolkit () | |
image_toolkit_invoke ($method, $params=array()) | |
image_get_info ($file) | |
image_scale_and_crop ($source, $destination, $width, $height) | |
image_scale ($source, $destination, $width, $height) | |
image_resize ($source, $destination, $width, $height) | |
image_rotate ($source, $destination, $degrees, $background=0x000000) | |
image_crop ($source, $destination, $x, $y, $width, $height) |
PHP includes the GD library by default so a GD toolkit is installed with Drupal. Other toolkits like ImageMagic are available from contrib modules. GD works well for small images, but using it with larger files may cause PHP to run out of memory. In contrast the ImageMagick library does not suffer from this problem, but it requires the ISP to have installed additional software.
Image toolkits are installed by copying the image.ToolkitName.inc file into Drupal's includes directory. The toolkit must then be enabled using the admin/settings/image-toolkit form.
Only one toolkit maybe selected at a time. If a module author wishes to call a specific toolkit they can check that it is installed by calling image_get_available_toolkits(), and then calling its functions directly.
image_crop | ( | $ | source, | |
$ | destination, | |||
$ | x, | |||
$ | y, | |||
$ | width, | |||
$ | height | |||
) |
Crop an image to the rectangle specified by the given rectangle.
$source | The file path of the source image. | |
$destination | The file path of the destination image. | |
$x | The top left co-ordinate, in pixels, of the crop area (x axis value). | |
$y | The top left co-ordinate, in pixels, of the crop area (y axis value). | |
$width | The target width, in pixels. | |
$height | The target height, in pixels. |
Definition at line 264 of file image.inc.
References image_toolkit_invoke().
image_gd_check_settings | ( | ) |
Verify GD2 settings (that the right version is actually installed).
Definition at line 67 of file image.gd.inc.
Referenced by image_gd_settings(), and image_get_toolkit().
image_gd_close | ( | $ | res, | |
$ | destination, | |||
$ | extension | |||
) |
GD helper to write an image resource to a destination file.
$res | An image resource created with image_gd_open(). | |
$destination | A string file path where the iamge should be saved. | |
$extension | A string containing one of the following extensions: gif, jpg, jpeg, png. |
Definition at line 205 of file image.gd.inc.
References variable_get().
Referenced by image_gd_crop(), image_gd_resize(), and image_gd_rotate().
image_gd_crop | ( | $ | source, | |
$ | destination, | |||
$ | x, | |||
$ | y, | |||
$ | width, | |||
$ | height | |||
) |
Crop an image using the GD toolkit.
Definition at line 157 of file image.gd.inc.
References $result, image_gd_close(), image_gd_open(), and image_get_info().
image_gd_info | ( | ) |
Retrieve information about the toolkit.
Definition at line 17 of file image.gd.inc.
References t().
image_gd_open | ( | $ | file, | |
$ | extension | |||
) |
GD helper function to create an image resource from a file.
$file | A string file path where the iamge should be saved. | |
$extension | A string containing one of the following extensions: gif, jpg, jpeg, png. |
Definition at line 184 of file image.gd.inc.
Referenced by image_gd_crop(), image_gd_resize(), and image_gd_rotate().
image_gd_resize | ( | $ | source, | |
$ | destination, | |||
$ | width, | |||
$ | height | |||
) |
Scale an image to the specified size using GD.
Definition at line 80 of file image.gd.inc.
References $result, image_gd_close(), image_gd_open(), and image_get_info().
image_gd_rotate | ( | $ | source, | |
$ | destination, | |||
$ | degrees, | |||
$ | background = 0x000000 | |||
) |
Rotate an image the given number of degrees.
Definition at line 133 of file image.gd.inc.
References $result, image_gd_close(), image_gd_open(), and image_get_info().
image_gd_settings | ( | ) |
Retrieve settings for the GD2 toolkit.
Definition at line 24 of file image.gd.inc.
References form_set_error(), image_gd_check_settings(), t(), and variable_get().
image_gd_settings_validate | ( | $ | form, | |
&$ | form_state | |||
) |
Validate the submitted GD settings.
Definition at line 53 of file image.gd.inc.
References $value, form_set_error(), and t().
image_get_available_toolkits | ( | ) |
Return a list of available toolkits.
Definition at line 39 of file image.inc.
References $output, file_scan_directory(), and name.
Referenced by system_image_toolkit_settings().
image_get_info | ( | $ | file | ) |
Get details about an image.
Drupal only supports GIF, JPG and PNG file formats.
Definition at line 116 of file image.inc.
Referenced by file_validate_image_resolution(), file_validate_is_image(), image_gd_crop(), image_gd_resize(), image_gd_rotate(), image_scale(), and image_scale_and_crop().
image_get_toolkit | ( | ) |
Retrieve the name of the currently used toolkit.
Definition at line 61 of file image.inc.
References image_gd_check_settings(), and variable_get().
Referenced by file_validate_image_resolution(), image_toolkit_invoke(), and system_image_toolkit_settings().
image_resize | ( | $ | source, | |
$ | destination, | |||
$ | width, | |||
$ | height | |||
) |
Resize an image to the given dimensions (ignoring aspect ratio).
$source | The file path of the source image. | |
$destination | The file path of the destination image. | |
$width | The target width, in pixels. | |
$height | The target height, in pixels. |
Definition at line 222 of file image.inc.
References image_toolkit_invoke().
image_rotate | ( | $ | source, | |
$ | destination, | |||
$ | degrees, | |||
$ | background = 0x000000 | |||
) |
Rotate an image by the given number of degrees.
$source | The file path of the source image. | |
$destination | The file path of the destination image. | |
$degrees | The number of (clockwise) degrees to rotate the image. | |
$background | An hexidecimal integer specifying the background color to use for the uncovered area of the image after the rotation. E.g. 0x000000 for black, 0xff00ff for magenta, and 0xffffff for white. |
Definition at line 242 of file image.inc.
References image_toolkit_invoke().
image_scale | ( | $ | source, | |
$ | destination, | |||
$ | width, | |||
$ | height | |||
) |
Scales an image to the given width and height while maintaining aspect ratio.
The resulting image can be smaller for one or both target dimensions.
$source | The file path of the source image. | |
$destination | The file path of the destination image. | |
$width | The target width, in pixels. | |
$height | The target height, in pixels. |
Definition at line 187 of file image.inc.
References image_get_info(), and image_toolkit_invoke().
Referenced by file_validate_image_resolution().
image_scale_and_crop | ( | $ | source, | |
$ | destination, | |||
$ | width, | |||
$ | height | |||
) |
Scales an image to the exact width and height given. Achieves the target aspect ratio by cropping the original image equally on both sides, or equally on the top and bottom. This function is, for example, useful to create uniform sized avatars from larger images.
The resulting image always has the exact target dimensions.
$source | The file path of the source image. | |
$destination | The file path of the destination image. | |
$width | The target width, in pixels. | |
$height | The target height, in pixels. |
Definition at line 157 of file image.inc.
References image_get_info(), and image_toolkit_invoke().
image_toolkit_invoke | ( | $ | method, | |
$ | params = array() | |||
) |
Invokes the given method using the currently selected toolkit.
$method | A string containing the method to invoke. | |
$params | An optional array of parameters to pass to the toolkit method. |
Definition at line 88 of file image.inc.
References image_get_toolkit(), and watchdog().
Referenced by image_crop(), image_resize(), image_rotate(), image_scale(), image_scale_and_crop(), and system_image_toolkit_settings().