Image toolkits

Functions for image file manipulations.

Drupal'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 Drupal. 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 using the Plugin system using \Drupal\system\Plugin\ImageToolkitManager. 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 \Drupal\system\Plugin\ImageToolkitManager::getAvailableToolkits(), and then calling its functions directly.

File

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

Functions

Namesort descending Location Description
image_crop drupal/core/includes/image.inc Crops an image to a rectangle specified by the given dimensions.
image_desaturate drupal/core/includes/image.inc Converts an image to grayscale.
image_dimensions_scale drupal/core/includes/image.inc Scales image dimensions while maintaining aspect ratio.
image_get_info drupal/core/includes/image.inc Gets details about an image.
image_load drupal/core/includes/image.inc Loads an image file and returns an image object.
image_resize drupal/core/includes/image.inc Resizes an image to the given dimensions (ignoring aspect ratio).
image_rotate drupal/core/includes/image.inc Rotates an image by the given number of degrees.
image_save drupal/core/includes/image.inc Closes the image and saves the changes to a file.
image_scale drupal/core/includes/image.inc Scales an image while maintaining aspect ratio.
image_scale_and_crop drupal/core/includes/image.inc Scales an image to the exact width and height given.