Image toolkits
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 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.НазваниеИнструментария.inc в раздел includes Drupal'а. Инструментарий должен быть разрешён с использованием формы admin/settings/image-toolkit.
Только один набор инструментов может быть выбран единовременно. Если авторы модулей хотят обратиться к определённому инструментарию, они могут проверить, установлен ли он, вызовом image_get_available_toolkits()
, и последующими запросами к его функциям напрямую.
Функции
Имя | Описание |
---|---|
image_crop includes/image.inc | Crop an image to the rectangle specified by the given rectangle. |
image_gd_check_settings includes/image.gd.inc | Verify GD2 settings (that the right version is actually installed). |
image_gd_close includes/image.gd.inc | GD helper to write an image resource to a destination file. |
image_gd_crop includes/image.gd.inc | Обрезает изображение используя набор инструментов GD. |
image_gd_info includes/image.gd.inc | Retrieve information about the toolkit. |
image_gd_open includes/image.gd.inc | GD helper function to create an image resource from a file. |
image_gd_resize includes/image.gd.inc | Scale an image to the specified size using GD. |
image_gd_rotate includes/image.gd.inc | Поворачивает изображение на заданное число градусов. |
image_gd_settings includes/image.gd.inc | Retrieve settings for the GD2 toolkit. |
image_gd_settings_validate includes/image.gd.inc | Validate the submitted GD settings. |
image_get_available_toolkits includes/image.inc | Возвращает список доступных наборов инструментов. |
image_get_info includes/image.inc | Возвращает информацию о формате изображения. |
image_get_toolkit includes/image.inc | Retrieve the name of the currently used toolkit. |
image_resize includes/image.inc | Resize an image to the given dimensions (ignoring aspect ratio). |
image_rotate includes/image.inc | Rotate an image by the given number of degrees. |
image_scale includes/image.inc | Scales an image to the given width and height while maintaining aspect ratio. |
image_scale_and_crop includes/image.inc | 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... |
image_toolkit_invoke includes/image.inc | Invokes the given method using the currently selected toolkit. |