Index: contributions/modules/imagecrop/imagecrop.js
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/imagecrop/imagecrop.js,v
retrieving revision 1.1.4.6
diff -u -p -r1.1.4.6 imagecrop.js
--- contributions/modules/imagecrop/imagecrop.js	29 May 2009 22:44:59 -0000	1.1.4.6
+++ contributions/modules/imagecrop/imagecrop.js	13 Jul 2009 20:28:38 -0000
@@ -15,7 +15,7 @@ $(document).ready(function(){
 		handles: 'all',
 		knobHandles: true,
 		//transparent: true,
-		aspectRatio: false,
+		aspectRatio: Drupal.settings.aspect,
 		autohide: true,
 
 		resize: function(e, ui) {
Index: contributions/modules/imagecrop/imagecrop.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/imagecrop/imagecrop.module,v
retrieving revision 1.1.4.16
diff -u -p -r1.1.4.16 imagecrop.module
--- contributions/modules/imagecrop/imagecrop.module	4 Jun 2009 14:01:44 -0000	1.1.4.16
+++ contributions/modules/imagecrop/imagecrop.module	13 Jul 2009 20:28:38 -0000
@@ -406,10 +406,26 @@ function imagecrop_docrop($fid, $preseti
       }
 
       // add jquery ui
-      if ($file->resizable)
-      jquery_ui_add(array('ui.resizable', 'ui.draggable', 'effects.scale'));
-      else
-      jquery_ui_add(array('ui.draggable'));
+      if ($file->resizable) {
+        jquery_ui_add(array('ui.resizable', 'ui.draggable', 'effects.scale'));
+ 
+        // set aspect ration if needed
+        if ($file->aspect) {
+          if(is_numeric($file->aspect)) {
+            drupal_add_js(array('aspect' => $file->aspect), 'setting');
+            // set the initial aspect ratio of the crop region to the ratio chosen in the preset
+            $file->crop_width = round($file->crop_height * $file->aspect);
+          }
+          elseif ($file->aspect == 'KEEP') {
+            drupal_add_js(array('aspect' => TRUE), 'setting');
+            // set the initial aspect ratio of the crop region to the original image aspect ratio
+            $file->crop_width = round(($width * $file->crop_height) / $height);
+          }
+        }
+      }
+      else {
+        jquery_ui_add(array('ui.draggable'));
+      }
 
       // output
       if ($size_warning == FALSE) {
@@ -619,6 +635,7 @@ function create_image_object($fid, $pres
           $crop_width = $preset['actions'][$key]['data']['width'];
           $crop_height = $preset['actions'][$key]['data']['height'];
           $resizable = $preset['actions'][$key]['data']['resizable'];
+          $aspect = $preset['actions'][$key]['data']['aspect'];
           $break = TRUE;
         }
         if ($break == TRUE) {
@@ -644,6 +661,9 @@ function create_image_object($fid, $pres
       // resizable or not
       $file->resizable = $resizable;
 
+      // aspect ratio
+      $file->aspect = $aspect;
+
       // add scale action if necessary
       if ($row->scale != 'original' && $firstscale == TRUE) {
         $preset['actions'][] = array(
@@ -768,3 +788,23 @@ function imagecrop_markup($js, $css) {
   if ($js == TRUE) drupal_add_js($path .'/imagecrop.js');
   if ($css == TRUE) drupal_add_css($path .'/imagecrop.css');
 }
+
+/**
+ * Validation of the aspect ratio entry
+ */
+function imagecrop_validate_aspect(&$element, &$form_state) {
+  if (!is_numeric($element['#value'])) {
+    if (strtolower($element['#value']) != 'keep') {
+      if (!empty($element['#value'])) {
+        drupal_set_message(t('Aspect ratio must be a number, the string KEEP, or empty if you don\'t want to fix it. Defaulting to empty.'));
+      }
+      form_set_value($element, FALSE, $form_state);
+    }
+    else {
+      form_set_value($element, 'KEEP', $form_state);
+    }
+  }
+  else {
+    form_set_value($element, abs((float)$element['#value']), $form_state);
+  }
+}
Index: contributions/modules/imagecrop/imagecrop_actions.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/imagecrop/imagecrop_actions.inc,v
retrieving revision 1.1.4.7
diff -u -p -r1.1.4.7 imagecrop_actions.inc
--- contributions/modules/imagecrop/imagecrop_actions.inc	3 Jun 2009 17:00:52 -0000	1.1.4.7
+++ contributions/modules/imagecrop/imagecrop_actions.inc	13 Jul 2009 20:28:38 -0000
@@ -39,6 +39,14 @@ function imagecrop_javascript_form($data
     '#type' => 'checkbox',
     '#title' => t('Is the toolbox resizable or not?'),
     '#default_value' => $data['resizable'],
+    '#description' => t('If the toolbox is resized, the crop values won\'t be respected, so you should add a Scale action after the ImageCrop.'),
+  );
+  $form['aspect'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Aspect ratio'),
+    '#default_value' => $data['aspect'],
+    '#description' => t('Enter an aspect ratio (width / height) to preserve during resizing. It can be a float (like 0.5 or 2) or the string KEEP. In that case the original aspect ratio of the picture will be preserved. Any other non-numeric value will empty that value and not fix any aspect ratio.'),
+    '#element_validate' => array('imagecrop_validate_aspect'),
   );
   $form['disable_if_no_data'] = array(
     '#type' => 'checkbox',
@@ -56,7 +64,7 @@ function imagecrop_javascript_form($data
  */
 function theme_imagecrop_javascript($element) {
   $data = $element['#value'];
-  return 'width: '. $data['width'] .', height: '. $data['height'] .', xoffset: '. $data['xoffset'] .', yoffset: '. $data['yoffset'] .', resizable: '. $data['resizable'] .', don\'t crop if region is not set: '. $data['disable_if_no_data'];
+  return 'width: '. $data['width'] .', height: '. $data['height'] .', xoffset: '. $data['xoffset'] .', yoffset: '. $data['yoffset'] .', resizable: '. $data['resizable'] .', aspect ratio: '.$data['aspect'] .', don\'t crop if region is not set: '. $data['disable_if_no_data'];
 }
 
 /**
