diff -up ../drupal-6.10-unpatched/includes/image.gd.inc includes/image.gd.inc --- ../drupal-6.10-unpatched/includes/image.gd.inc 2008-01-15 05:17:42.000000000 -0500 +++ includes/image.gd.inc 2009-03-13 01:34:39.000000000 -0400 @@ -74,6 +74,52 @@ function image_gd_check_settings() { return FALSE; } + /** + * Get any info about the image that image_get_info wasn't able to provide. + */ +function image_gd_get_info($file) { + return FALSE; +} + +/** + * Convert an image from one type to another based on file extension. + */ +function image_gd_convert($source, $destination) { + $source_info = image_get_info($source); + switch ($source_info['extension']) { + case 'gif': + $image = imagecreatefromgif($source); + break; + case 'jpg': + $image = imagecreatefromjpeg($source); + break; + case 'png': + $image = imagecreatefrompng($source); + break; + default: + watchdog('php', t("The GD image toolkit cannot convert from %source.", array('%source' => $source))); + return FALSE; + } + + $destination_info = path_info($destination, PATHINFO_EXTENSION); + switch ($destination_info['extension']) { + case 'gif': + imagegif($image, $destination); + break; + case 'jpg': + case 'jpeg': + imagejpeg($image, $destination); + break; + case 'png': + imagepng($image, $destination); + break; + default: + watchdog('php', t("The GD image toolkit cannot create images of type %extension.", array('%extension' => $destination_info['extension']))); + return FALSE; + } + return TRUE; +} + /** * Scale an image to the specified size using GD. */ Only in includes/: image.imagemagick.inc diff -up ../drupal-6.10-unpatched/includes/image.inc includes/image.inc --- ../drupal-6.10-unpatched/includes/image.inc 2008-01-28 11:05:17.000000000 -0500 +++ includes/image.inc 2009-03-13 01:33:00.000000000 -0400 @@ -123,18 +123,60 @@ function image_get_info($file) { $file_size = @filesize($file); if (isset($data) && is_array($data)) { - $extensions = array('1' => 'gif', '2' => 'jpg', '3' => 'png'); - $extension = array_key_exists($data[2], $extensions) ? $extensions[$data[2]] : ''; + switch ($data[2]) { + case IMAGETYPE_GIF: + $extension = 'gif'; + break; + case IMAGETYPE_JPEG: + $extension = 'jpg'; + break; + case IMAGETYPE_PNG: + $extension = 'png'; + break; + case IMAGETYPE_SWF: + $extension = 'swf'; + break; + case IMAGETYPE_PSD: + $extension = 'psd'; + break; + case IMAGETYPE_BMP: + case IMAGETYPE_WBMP: + $extension = 'bmp'; + break; + case IMAGETYPE_XBM: + $extension = 'xbm'; + break; + case IMAGETYPE_TIFF_II: + case IMAGETYPE_TIFF_MM: + $extension = 'tiff'; + break; + case IMAGETYPE_IFF: + $extension = 'iff'; + break; + default: + $extension = ''; + } $details = array('width' => $data[0], 'height' => $data[1], 'extension' => $extension, 'file_size' => $file_size, 'mime_type' => $data['mime']); } + else { + $details = image_toolkit_invoke('get_info', $file); + $details['file_size'] = $file_size; + } return $details; } + /** + * Convert an image from one type to another based on file extension. + */ +function image_convert($source, $destination) { + return image_toolkit_invoke('convert', array($source, $destination)); +} + /** * Scales an image to the exact width and height given. Achieves the * target aspect ratio by cropping the original image equally on both