summaryrefslogtreecommitdiff
path: root/modules/system
diff options
context:
space:
mode:
authorAngie Byron <webchick@24967.no-reply.drupal.org>2009-09-01 17:49:11 +0000
committerAngie Byron <webchick@24967.no-reply.drupal.org>2009-09-01 17:49:11 +0000
commit18b7e4254bde471e4c2060a430b3f219f917c4b9 (patch)
tree893a4cdabfd4c3b5f43424a203ea4094797a6b7f /modules/system
parentc4a548f64d3c941a36edd03903ba388c6c32c1ae (diff)
downloadbrdo-18b7e4254bde471e4c2060a430b3f219f917c4b9.tar.gz
brdo-18b7e4254bde471e4c2060a430b3f219f917c4b9.tar.bz2
#269337 by egfrith and wrunt: Added support for more image types (PDF, TIFF, EPS, etc.).
Diffstat (limited to 'modules/system')
-rw-r--r--modules/system/image.gd.inc33
1 files changed, 33 insertions, 0 deletions
diff --git a/modules/system/image.gd.inc b/modules/system/image.gd.inc
index 23e34677b..e6c70e76b 100644
--- a/modules/system/image.gd.inc
+++ b/modules/system/image.gd.inc
@@ -321,5 +321,38 @@ function image_gd_create_tmp(stdClass $image, $width, $height) {
}
/**
+ * Get details about an image.
+ *
+ * @param $image
+ * An image object.
+ * @return
+ * FALSE, if the file could not be found or is not an image. Otherwise, a
+ * keyed array containing information about the image:
+ * - "width": Width, in pixels.
+ * - "height": Height, in pixels.
+ * - "extension": Commonly used file extension for the image.
+ * - "mime_type": MIME type ('image/jpeg', 'image/gif', 'image/png').
+ *
+ * @see image_get_info()
+ */
+function image_gd_get_info(stdClass $image) {
+ $details = FALSE;
+ $data = getimagesize($image->source);
+
+ if (isset($data) && is_array($data)) {
+ $extensions = array('1' => 'gif', '2' => 'jpg', '3' => 'png');
+ $extension = array_key_exists($data[2], $extensions) ? $extensions[$data[2]] : '';
+ $details = array(
+ 'width' => $data[0],
+ 'height' => $data[1],
+ 'extension' => $extension,
+ 'mime_type' => $data['mime'],
+ );
+ }
+
+ return $details;
+}
+
+/**
* @} End of "ingroup image".
*/