[drupal-devel] [task] Core image handling
drupal-devel at drupal.org
Fri Jan 28 20:50:37 UTC 2005
Component: base system
Assigned to: walkah
Reported by: walkah
Updated by: walkah
Attachment: http://drupal.org/files/issues/image-core.patch (7.22 KB)
and the patch (as mentioned above).
January 28, 2005 - 15:31 : walkah
Attachment: http://drupal.org/files/issues/image_0.inc (7.44 KB)
Due to popular demand - attached here is an image.inc for inclusion (in
includes/), that will offer some basic image detection and manipulation
functionality to drupal's core.
currently image.inc is responsible for managing image 'toolkits' -
these are either PHP modules (e.g. GD) or external programs (e.g.
imagemagick) that handle the actual manipulation of images. also
included is the default "GD" toolkit (that supports both GD1 or GD2,
depending on which is installed). PHP comes bundled with gd as of
version 4.3 - therefore this is a reasonable default. However, other
toolkits will follow (I presume) - they can be installed in includes/
There are 5 main functions that modules may now utilize to handle
* image_get_info() - this function checks a file - if it exists and is
a valid image file , it will return an array containing things like the
pixel dimensions of the image, plus the 'type' and common extension.
* image_scale - resizes a given image to fit within a given width /
height dimensions, while maintaining aspect ratio (not distorting the
image). - this function can be used to generate thumbnails, or ensure a
maximum resolution, etc.
* image_resize - similar to image_scale (but will not respect aspect
ratio - may well distort the image).
* image_rotate - rotate an image by X degrees
* image_crop - crops an image to a given rectangle (defined as top-left
x/y coordinates plus a width & height of the rectangle).
In a follow up I will post a patch that does the following:
* adds some default settings to admin/settings :
* toolkit selection (and possibly configuration)
* default thumbnail dimensions (WxH) - to be used as a system-wide
* maximum dimensions (WxH ) - to be used as a system-wide default
* changes the user picture handling to silently resize uploaded
pictures to fit within the specified dimensions (rather than throwing
* uses image_get_info() to verify logo uploads in admin/theme
* patches upload.module to respect maximum dimensions for uploaded
Contribution modules will now be able to rely on these base
manipulation functions to offer additional functionality (such as image
nodes, photo galleries, advanced image manipulation, etc)
More information about the drupal-devel