Index: includes/image.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/image.inc,v
retrieving revision 1.17
diff -u -F^f -r1.17 image.inc
--- includes/image.inc	26 Dec 2006 14:01:41 -0000	1.17
+++ includes/image.inc	9 May 2007 23:40:32 -0000
@@ -103,10 +103,38 @@ function image_get_info($file) {
 }
 
 /**
+ * Scales an image to the given width and height by scaling and cropping.
+ *
+ * The resulting image always has the exact target dimensions.
+ *
+ * @param $source         The file path of the source image
+ * @param $destination    The file path of the destination image
+ * @param $width          The target width
+ * @param $height         The target height
+ *
+ * @return True or FALSE, based on success
+ */
+function image_scale_and_crop($source, $destination, $width, $height) {
+  $info = image_get_info($source);
+  
+  print_r($info);
+
+  $scale = max($width / $info['width'], $height / $info['height']);
+  $x = round(($info['width'] * $scale - $width) / 2);
+  $y = round(($info['height'] * $scale - $height) / 2);
+
+  if (image_toolkit_invoke('resize', array($source, $destination, $info['width'] * $scale, $info['height'] * $scale))) {
+    return image_toolkit_invoke('crop', array($destination, $destination, $x, $y, $width, $height));
+  }
+}
+
+/**
  * Scales an image to the given width and height while maintaining aspect
  * ratio.
  *
- * @param $source         The filepath of the source image
+ * The resulting image can be smaller for one or both target dimensions.
+ *
+ * @param $source         The file path of the source image
  * @param $destination    The file path of the destination image
  * @param $width          The target width
  * @param $height         The target height
@@ -116,7 +144,7 @@ function image_get_info($file) {
 function image_scale($source, $destination, $width, $height) {
   $info = image_get_info($source);
 
-  // don't scale up
+  // Don't scale up.
   if ($width >= $info['width'] && $height >= $info['height']) {
     return FALSE;
   }

