Functions for image file manipulations.

Backdrop's image toolkits provide an abstraction layer for common image file manipulations like scaling, cropping, and rotating. The abstraction frees module authors from the need to support multiple image libraries, and it allows site administrators to choose the library that's best for them.

PHP includes the GD library by default so a GD toolkit is installed with Backdrop. Other toolkits like ImageMagick 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 discovered based on the associated module's hook_image_toolkits. The toolkit must then be enabled using the admin/config/media/image-toolkit form.

Only one toolkit may be 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.

File

core/includes/image.inc, line 7
API for manipulating images.

Functions

Namesort descending Location Description
image_add_svg_attributes core/includes/image.inc Add attributes to an SVG string.
image_crop core/includes/image.inc Crops an image to a rectangle specified by the given dimensions.
image_desaturate core/includes/image.inc Converts an image to grayscale.
image_dimensions_scale core/includes/image.inc Scales image dimensions while maintaining aspect ratio.
image_gd_check_settings core/modules/system/image.gd.inc Verify GD2 settings (that the right version is actually installed).
image_gd_create_tmp core/modules/system/image.gd.inc Create a truecolor image preserving transparency from a provided image.
image_gd_crop core/modules/system/image.gd.inc Crop an image using the GD toolkit.
image_gd_desaturate core/modules/system/image.gd.inc Convert an image resource to grayscale.
image_gd_get_info core/modules/system/image.gd.inc Get details about an image.
image_gd_load core/modules/system/image.gd.inc GD helper function to create an image resource from a file.
image_gd_resize core/modules/system/image.gd.inc Scale an image to the specified size using GD.
image_gd_rotate core/modules/system/image.gd.inc Rotate an image the given number of degrees.
image_gd_save core/modules/system/image.gd.inc GD helper to write an image resource to a destination file.
image_gd_settings core/modules/system/image.gd.inc Retrieve settings for the GD2 toolkit.
image_gd_supported_extensions core/modules/system/image.gd.inc Retrieve supported extensions for the GD2 toolkit.
image_get_available_toolkits core/includes/image.inc Gets a list of available toolkits.
image_get_info core/includes/image.inc Gets details about an image.
image_get_supported_extensions core/includes/image.inc Gets supported image extensions.
image_get_svg_dimensions core/includes/image.inc Get an SVG image's defined dimensions.
image_get_toolkit core/includes/image.inc Gets the name of the currently used toolkit.
image_hex2rgba core/includes/image.inc Converts a hex string to RGBA (red, green, blue, alpha) integer values and tidies up the input hex color string.
image_is_svg core/includes/image.inc Determine if a file URI is an SVG image based on its file extension.
image_load core/includes/image.inc Loads an image file and returns an image object.
image_resize core/includes/image.inc Resizes an image to the given dimensions (ignoring aspect ratio).
image_rotate core/includes/image.inc Rotates an image by the given number of degrees.
image_save core/includes/image.inc Closes the image and saves the changes to a file.
image_scale core/includes/image.inc Scales an image while maintaining aspect ratio.
image_scale_and_crop core/includes/image.inc Scales an image to the exact width and height given.
image_toolkit_invoke core/includes/image.inc Invokes the given method using the currently selected toolkit.

Constants

Namesort descending Location Description
IMAGE_SVG_DEFAULT_HEIGHT core/includes/image.inc Default height for SVG images.
IMAGE_SVG_DEFAULT_WIDTH core/includes/image.inc Default width for SVG images.