diff --git a/modules/image/image.admin.css b/modules/image/image.admin.css
new file mode 100644
index 0000000..2af28bd
--- /dev/null
+++ b/modules/image/image.admin.css
@@ -0,0 +1,59 @@
+/* $Id$ */
+
+/**
+ * Image style configuration pages
+ */
+div.image-style-new,
+div.image-style-new div {
+  display: inline;
+}
+div.image-style-preview {
+}
+div.image-style-preview div.preview-image-wrapper {
+  text-align: center;
+  padding-bottom: 2em;
+  top: 50%;
+  width: 48%;
+  float: left;
+}
+div.image-style-preview div.preview-image {
+  margin: auto;
+  position: relative;
+}
+div.image-style-preview div.preview-image div.width {
+  position: absolute;
+  bottom: -6px;
+  left: -1px;
+  border: 1px solid #666;
+  border-top: none;
+  height: 2px;
+}
+div.image-style-preview div.preview-image div.width span {
+  position: relative;
+  top: 4px;
+}
+div.image-style-preview div.preview-image div.height {
+  position: absolute;
+  top: -1px;
+  right: -6px;
+  border: 1px solid #666;
+  border-left: none;
+  width: 2px;
+}
+div.image-style-preview div.preview-image div.height span {
+  position: absolute;
+  top: 50%;
+  left: 10px;
+  height: 2em;
+  margin-top: -1em;
+}
+table.image-anchor {
+  width: auto;
+}
+table.image-anchor tr.even,
+table.image-anchor tr.odd {
+  background: none;
+}
+table.image-anchor td {
+  border: 1px solid #CCC;
+}
diff --git a/modules/image/image.admin.inc b/modules/image/image.admin.inc
new file mode 100644
index 0000000..4493de6
--- /dev/null
+++ b/modules/image/image.admin.inc
@@ -0,0 +1,803 @@
+<?php
+// $Id$
+
+/**
+ * @file
+ * Administration pages for image settings.
+ */
+
+/**
+ * Menu callback; Listing of all current image styles.
+ */
+function image_style_list() {
+  $page = array();
+
+  $page['image_style_list'] = array(
+    '#theme' => 'image_style_list',
+    '#styles' => image_styles(),
+    '#attached_css' => array(drupal_get_path('module', 'image') . '/image.admin.css' => array('preprocess' => FALSE)),
+  );
+
+  return $page;
+
+}
+
+/**
+ * Menu title callback; Title for editing, deleting, and flushing styles.
+ */
+function image_style_title($string, $style) {
+  return t($string, array('!name' => $style['name']));
+}
+
+/**
+ * Form builder; Edit a style name and effect order.
+ *
+ * @param $form_state
+ *   An associative array containing the current state of the form.
+ * @param $style
+ *   An image style array.
+ * @ingroup forms
+ * @see image_style_form_submit()
+ * @see image_style_name_validate()
+ */
+function image_style_form(&$form_state, $style) {
+  $form_state['image_style'] = $style;
+  $form = array(
+    '#tree' => TRUE,
+    '#attached_css' => array(drupal_get_path('module', 'image') . '/image.admin.css' => array('preprocess' => FALSE)),
+  );
+
+  $form['name'] = array(
+    '#type' => 'textfield',
+    '#size' => '64',
+    '#title' => t('Image style name'),
+    '#default_value' => $style['name'],
+    '#description' => t('The name is used in URLs for generated images. Use only lowercase alphanumeric characters, underscores (_), and hyphens (-).'),
+    '#element_validate' => array('image_style_name_validate'),
+  );
+
+  $form['effects'] = array(
+    '#theme' => 'image_style_effects',
+  );
+
+  foreach ($style['effects'] as $ieid => $effect) {
+    $form['effects'][$ieid]['#weight'] = isset($form_state['input']['effects']) ? $form_state['input']['effects'][$ieid]['weight'] : NULL;
+    $form['effects'][$ieid]['name'] = array(
+      '#markup' => $effect['name'],
+    );
+    $form['effects'][$ieid]['summary'] = array(
+      '#markup' => isset($effect['summary']) ? theme($effect['summary'], $effect['data']) : '',
+    );
+    $form['effects'][$ieid]['weight'] = array(
+      '#type' => 'weight',
+      '#default_value' => $effect['weight'],
+    );
+    $form['effects'][$ieid]['configure'] = array(
+      '#markup' => isset($effect['form']) ? l(t('Configure'), 'admin/settings/image-styles/edit/'. $style['name'] .'/effects/'. $effect['ieid'] ) : '',
+    );
+    $form['effects'][$ieid]['remove'] = array(
+      '#markup' => l(t('Delete'), 'admin/settings/image-styles/edit/'. $style['name'] .'/effects/'. $effect['ieid'] .'/delete'),
+    );
+  }
+
+  $new_effect_options = array('' => t('Select a new effect'));
+  foreach (image_effect_definitions() as $effect => $definition) {
+    $new_effect_options[$effect] = check_plain($definition['name']);
+  }
+  $form['effects']['new'] = array(
+    '#tree' => FALSE,
+    '#weight' => isset($form_state['input']['weight']) ? $form_state['input']['weight'] : NULL,
+  );
+  $form['effects']['new']['new'] = array(
+    '#type' => 'select',
+    '#options' => $new_effect_options,
+  );
+  $form['effects']['new']['weight'] = array(
+    '#type' => 'weight',
+    '#default_value' => count($form['effects']) - 1,
+  );
+  $form['effects']['new']['add'] = array(
+    '#type' => 'submit',
+    '#value' => t('Add'),
+    '#validate' => array('image_style_form_add_validate'),
+    '#submit' => array('image_style_form_submit', 'image_style_form_add_submit'),
+  );
+
+  $form['preview'] = array(
+    '#type' => 'item',
+    '#title' => t('Preview'),
+    '#markup' => theme('image_style_preview', $style),
+    '#description' => t('Preview images are scaled. Actual image sizes may be viewed by clicking on the preview.'),
+  );
+
+  $form['submit'] = array(
+    '#type' => 'submit',
+    '#value' => t('Update style'),
+  );
+
+  return $form;
+}
+
+/**
+ * Validate handler for adding a new effect to a style.
+ */
+function image_style_form_add_validate($form, &$form_state) {
+  if (!$form_state['values']['new']) {
+    form_error($form['effects']['new']['new'], t('Select an effect to add.'));
+    $form_state['rebuild'] = TRUE;
+  }
+}
+
+/**
+ * Submit handler for adding a new effect to a style.
+ */
+function image_style_form_add_submit($form, &$form_state) {
+  $style = $form_state['image_style'];
+  // Check if this field has any configuration options.
+  $effect = image_effect_definition_load($form_state['values']['new']);
+
+  // Load the configuration form for this option.
+  if (isset($effect['form'])) {
+    $path = 'admin/settings/image-styles/edit/' . $form_state['image_style']['name'] . '/add/' . $form_state['values']['new'];
+    $form_state['redirect'] = array($path, array('weight' => $form_state['values']['weight']));
+  }
+  // If there's no form, immediately add the effect.
+  else {
+    $effect['isid'] = $style['isid'];
+    $effect['weight'] = $form_state['values']['weight'];
+    image_effect_save($effect);
+    drupal_set_message(t('The effect was successfully applied.'));
+  }
+}
+
+/**
+ * Submit handler for saving an image style.
+ */
+function image_style_form_submit($form, &$form_state) {
+  // Update the style name if it has changed.
+  $style = $form_state['image_style'];
+  if ($style['name'] != $form_state['values']['name']) {
+    $style['name'] = $form_state['values']['name'];
+  }
+
+  // Update effect weights.
+  if (!empty($form_state['values']['effects'])) {
+    foreach ($form_state['values']['effects'] as $ieid => $effect_data) {
+      if (isset($style['effects'][$ieid])) {
+        $effect = $style['effects'][$ieid];
+        $effect['weight'] = $effect_data['weight'];
+        image_effect_save($effect);
+      }
+    }
+  }
+
+  image_style_save($style);
+  if ($form_state['values']['op'] == t('Update style')) {
+    drupal_set_message('Changes to the style have been saved.');
+  }
+  $form_state['redirect'] = 'admin/settings/image-styles/edit/' . $style['name'];
+}
+
+/**
+ * Form builder; Form for adding a new style.
+ *
+ * @ingroup forms
+ * @see image_style_add_form_submit()
+ * @see image_style_name_validate()
+ */
+function image_style_add_form(&$form_state) {
+  $form = array();
+
+  $form['name'] = array(
+    '#type' => 'textfield',
+    '#size' => '64',
+    '#title' => t('Style name'),
+    '#default_value' => '',
+    '#description' => t('The name is used in URLs for generated images. Use only lowercase alphanumeric characters, underscores (_), and hyphens (-).'),
+    '#element_validate' => array('image_style_name_validate'),
+  );
+
+  $form['submit'] = array(
+    '#type' => 'submit',
+    '#value' => t('Create new style'),
+  );
+
+  return $form;
+}
+
+/**
+ * Submit handler for adding a new style.
+ */
+function  image_style_add_form_submit($form, &$form_state) {
+  $style = array('name' => $form_state['values']['name']);
+  $style = image_style_save($style);
+  drupal_set_message(t('Style %name was created.', array('%name' => $style['name'])));
+  $form_state['redirect'] = 'admin/settings/image-styles/edit/'. $style['name'];
+}
+
+/**
+ * Element validate function to ensure unique, URL safe style names.
+ */
+function image_style_name_validate($element, $form_state) {
+  // Check for duplicates.
+  $styles = image_styles();
+  if (isset($styles[$element['#value']]) && (!isset($form_state['image_style']['isid']) || $styles[$element['#value']]['isid'] != $form_state['image_style']['isid'])) {
+    form_set_error($element['#name'], t('The image style name %name is already in use.', array('%name' => $element['#value'])));
+  }
+
+  // Check for illegal characters in style names.
+  if (preg_match('/[^0-9a-z_\-]/', $element['#value'])) {
+    form_set_error($element['#name'], t('Please only use lowercase alphanumeric characters, underscores (_), and hyphens (-) for style names.'));
+  }
+}
+
+/**
+ * Form builder; Form for deleting an image style.
+ *
+ * @param $style
+ *   An image style array.
+ *
+ * @ingroup forms
+ * @see image_style_delete_form_submit()
+ */
+function image_style_delete_form($form_state, $style) {
+  $form_state['image_style'] = $style;
+
+  $form = array();
+
+  $replacement_styles = array_diff_key(image_style_options(), array($style['name'] => ''));
+  $replacement_styles[''] = t('No replacement, just delete');
+  $form['replacement'] = array(
+    '#title' => t('Replacement style'),
+    '#type' => 'select',
+    '#options' => $replacement_styles,
+  );
+
+  return confirm_form(
+    $form,
+    t('Optionally select a style before deleting %style', array('%style' => $style['name'])),
+    'admin/settings/image-styles',
+    t('If this style is in use on the site, you may select another style to replace it. All images that have been generated for this style will be permanently deleted.'),
+    t('Delete'),  t('Cancel')
+  );
+}
+
+/**
+ * Submit handler to delete an image style.
+ */
+function image_style_delete_form_submit($form, &$form_state) {
+  $style = $form_state['image_style'];
+
+  image_style_delete($style, $form_state['values']['replacement']);
+  cache_clear_all();
+  drupal_set_message(t('Style %name was deleted.', array('%name' => $style['name'])));
+  $form_state['redirect'] = 'admin/settings/image-styles';
+}
+
+/**
+ * Form builder; Confirm flushing a style's cached images.
+ *
+ * @param $style
+ *   An image style array.
+ * @ingroup forms
+ * @see image_style_flush_form_submit()
+ */
+function image_style_flush_form(&$form_state, $style) {
+  $form_state['image_style'] = $style;
+
+  $form = array();
+  return confirm_form(
+    $form,
+    t('Are you sure you want to flush the %style style?', array('%style' => $style['name'])),
+    'admin/settings/image-styles',
+    t('This will delete all the generated images for the %style style. Regenerating the images may cause a temporary increase in your server\'s load.', array('%style' => $style['name'])),
+    t('Flush'),  t('Cancel')
+  );
+}
+
+/**
+ * Submit handler for flushing an image style's cached files.
+ */
+function image_style_flush_form_submit($form, &$form_state) {
+  $style = $form_state['image_style'];
+  image_style_flush($style);
+  drupal_set_message(t('Style %name was flushed.', array('%name' => $style['name'])));
+  $form_state['redirect'] = 'admin/settings/image-styles';
+}
+
+/**
+ * Menu title callback; Title for editing, deleting, and adding image effects.
+ *
+ * @param $effect
+ *   An image effect array.
+ */
+function image_effect_title($string, $effect) {
+  return t($string, array('!name' => $effect['name']));
+}
+
+/**
+ * Form builder; Form for adding and editing image effects.
+ *
+ * This form is used universally for editing all effects. Each effect adds its
+ * own custom section to the form by calling the form function specified in
+ * hook_image_effects().
+ *
+ * @param $form_state
+ *   An associative array containing the current state of the form.
+ * @param $style
+ *   An image style array.
+ * @param $effect
+ *   An image effect array.
+ *
+ * @ingroup forms
+ * @see hook_image_effects()
+ * @see image_effects()
+ * @see image_resize_form()
+ * @see image_scale_form()
+ * @see image_rotate_form()
+ * @see image_crop_form()
+ * @see image_effect_form_submit()
+ */
+function image_effect_form(&$form_state, $style, $effect) {
+  $form_state['image_style'] = $style;
+  $form_state['image_effect'] = $effect;
+
+  // If there's no configuration for this effect redirect to the effect list.
+  if (!isset($effect['form'])) {
+    drupal_goto('admin/settings/image-styles/edit/' . $style['name']);
+  }
+
+  $form = array(
+    '#tree' => TRUE,
+    '#attached_css' => array(drupal_get_path('module', 'image') . '/image.admin.css' => array('preprocess' => FALSE)),
+  );
+  if (drupal_function_exists($effect['form'])) {
+    $form['data'] = call_user_func($effect['form'], $effect['data']);
+  }
+
+  // Check if the URL provides a weight, then the effect, otherwise use default.
+  $form['weight'] = array(
+    '#type' => 'hidden',
+    '#value' => isset($_GET['weight']) ? intval($_GET['weight']) : (isset($effect['weight']) ? $effect['weight'] : count($style['effects'])),
+  );
+
+  $form['buttons'] = array('#tree' => FALSE);
+  $form['buttons']['submit'] = array(
+    '#type' => 'submit',
+    '#value' => isset($effect['ieid']) ? t('Update effect') : t('Add effect'),
+  );
+  $form['buttons']['cancel'] = array(
+    '#markup' => l(t('Cancel'), 'admin/settings/image-styles/edit/' . $style['name']),
+  );
+
+  return $form;
+}
+
+/**
+ * Submit handler for updating an image effect.
+ */
+function image_effect_form_submit($form, &$form_state) {
+  $style = $form_state['image_style'];
+  $effect = array_merge($form_state['image_effect'], $form_state['values']);
+  $effect['isid'] = $style['isid'];
+  image_effect_save($effect);
+  drupal_set_message(t('The effect was successfully applied.'));
+  $form_state['redirect'] = 'admin/settings/image-styles/edit/'. $style['name'];
+}
+
+/**
+ * Form builder; Form for deleting an image effect.
+ *
+ * @params $style
+ *   Name of the style to remove the effect from.
+ * @params $effect
+ *   Name of the effect to remove.
+ * @ingroup forms
+ * @see image_effect_delete_form_submit()
+ */
+function image_effect_delete_form(&$form_state, $style, $effect) {
+  $form_state['image_style'] = $style;
+  $form_state['image_effect'] = $effect;
+
+  $form = array();
+  $question = t('Are you sure you want to delete the @effect effect from the %style style?', array('%style' => $style['name'], '@effect' => $effect['name']));
+  $description = t('Deleting this effect will regenerate all images for the %style style.', array('%style' => $style['name']));
+  return confirm_form($form, $question, 'admin/settings/image-styles/edit/' . $style['name'], $description, t('Delete'));
+}
+
+/**
+ * Submit handler to delete an image effect.
+ */
+function image_effect_delete_form_submit($form, &$form_state) {
+  $style = $form_state['image_style'];
+  $effect = $form_state['image_effect'];
+
+  image_effect_delete($effect);
+  drupal_set_message(t('The image effect %name has been deleted.', array('%name' => $effect['name'])));
+  $form_state['redirect'] = 'admin/settings/image-styles/edit/'. $style['name'];
+}
+
+/**
+ * Element validate handler to ensure an integer pixel value.
+ *
+ * The property #allow_negative = TRUE may be set to allow negative integers.
+ */
+function image_effect_integer_validate($element, &$form_state) {
+  $value = empty($element['#allow_negative']) ? $element['#value'] : preg_replace('/^-/', '', $element['#value']);
+  if ($element['#value'] != '' && !ctype_digit($value)) {
+    if (empty($element['#allow_negative'])) {
+      form_error($element, t('!name must be an integer.', array('!name' => $element['#title'])));
+    }
+    else {
+      form_error($element, t('!name must be a positive integer.', array('!name' => $element['#title'])));
+    }
+  }
+}
+
+/**
+ * Element validate handler to ensure a hexadecimal color value.
+ */
+function image_effect_color_validate($element, &$form_state) {
+  if ($element['#value'] != '') {
+    $hex_value = preg_replace('/^#/', '', $element['#value']);
+    if (!preg_match('/^#/', $element['#value']) || strlen($hex_value) != 6 && strlen($hex_value) != 3 || !ctype_xdigit($hex_value)) {
+      form_error($element, t('!name must be a hexadecimal color value.', array('!name' => $element['#title'])));
+    }
+  }
+}
+
+/**
+ * Form structure for the image resize form.
+ *
+ * Note that this is not a complete form, it only contains the portion of the
+ * form for configuring the resize options. Therefor it does not not need to
+ * include metadata about the effect, nor a submit button.
+ *
+ * @param $data
+ *   The current configuration for this resize effect.
+ */
+function image_resize_form($data) {
+  $form['width'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Width'),
+    '#default_value' => isset($data['width']) ? $data['width'] : '',
+    '#field_suffix' => ' ' . t('pixels'),
+    '#required' => TRUE,
+    '#size' => 10,
+    '#element_validate' => array('image_effect_integer_validate'),
+    '#allow_negative' => FALSE,
+  );
+  $form['height'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Height'),
+    '#default_value' => isset($data['height']) ? $data['height'] : '',
+    '#field_suffix' => ' ' . t('pixels'),
+    '#required' => TRUE,
+    '#size' => 10,
+    '#element_validate' => array('image_effect_integer_validate'),
+    '#allow_negative' => FALSE,
+  );
+  return $form;
+}
+
+/**
+ * Form structure for the image scale form.
+ *
+ * Note that this is not a complete form, it only contains the portion of the
+ * form for configuring the scale options. Therefor it does not not need to
+ * include metadata about the effect, nor a submit button.
+ *
+ * @param $data
+ *   The current configuration for this scale effect.
+ */
+function image_scale_form($data) {
+  $form = image_resize_form($data);
+  $form['width']['#required'] = FALSE;
+  $form['height']['#required'] = FALSE;
+  $form['upscale'] = array(
+    '#type' => 'checkbox',
+    '#default_value' => (isset($data['upscale'])) ? $data['upscale'] : 0,
+    '#title' => t('Allow Upscaling'),
+    '#description' => t('Let scale make images larger than their original size'),
+  );
+  return $form;
+}
+
+/**
+ * Form structure for the image crop form.
+ *
+ * Note that this is not a complete form, it only contains the portion of the
+ * form for configuring the crop options. Therefor it does not not need to
+ * include metadata about the effect, nor a submit button.
+ *
+ * @param $data
+ *   The current configuration for this crop effect.
+ */
+function image_crop_form($data) {
+  $data += array(
+    'width' => '',
+    'height' => '',
+    'anchor' => 'center-center',
+  );
+
+  $form = image_resize_form($data);
+  $form['anchor'] = array(
+    '#type' => 'radios',
+    '#title' => t('Anchor'),
+    '#options' => array(
+      'left-top'      => t('Top') . ' ' . t('Left'),
+      'center-top'    => t('Top') . ' ' . t('Center'),
+      'right-top'     => t('Top') . ' ' . t('Right'),
+      'left-center'   => t('Center') . ' ' . t('Left'),
+      'center-center' => t('Center'),
+      'right-center'  => t('Center') . ' ' . t('Right'),
+      'left-bottom'   => t('Bottom') . ' ' . t('Left'),
+      'center-bottom' => t('Bottom') . ' ' . t('Center'),
+      'right-bottom'  => t('Bottom') . ' ' . t('Right'),
+    ),
+    '#theme' => 'image_anchor',
+    '#default_value' => $data['anchor'],
+    '#description' => t('The part of the image that will be retained during the crop.'),
+  );
+
+  return $form;
+}
+
+/**
+ * Form structure for the image rotate form.
+ *
+ * Note that this is not a complete form, it only contains the portion of the
+ * form for configuring the rotate options. Therefor it does not not need to
+ * include metadata about the effect, nor a submit button.
+ *
+ * @param $data
+ *   The current configuration for this rotate effect.
+ */
+function image_rotate_form($data) {
+  $form['degrees'] = array(
+    '#type' => 'textfield',
+    '#default_value' => (isset($data['degrees'])) ? $data['degrees'] : 0,
+    '#title' => t('Rotation angle'),
+    '#description' => t('The number of degrees the image should be rotated. Positive numbers are clockwise, negative are counter-clockwise.'),
+    '#field_suffix' => '&deg;',
+    '#required' => TRUE,
+    '#size' => 6,
+    '#maxlength' => 4,
+    '#element_validate' => array('image_effect_integer_validate'),
+    '#allow_negative' => TRUE,
+  );
+  $form['bgcolor'] = array(
+    '#type' => 'textfield',
+    '#default_value' => (isset($data['bgcolor'])) ? $data['bgcolor'] : '#FFFFFF',
+    '#title' => t('Background color'),
+    '#description' => t('The background color to use for exposed areas of the image. Use web-style hex colors (#FFFFFF for white, #000000 for black). Leave blank for transparency on image types that support it.'),
+    '#size' => 7,
+    '#maxlength' => 7,
+    '#element_validate' => array('image_effect_color_validate'),
+  );
+  $form['random'] = array(
+    '#type' => 'checkbox',
+    '#default_value' => (isset($data['random'])) ? $data['random'] : 0,
+    '#title' => t('Randomize'),
+    '#description' => t('Randomize the rotation angle for each image. The angle specified above is used as a maximum.'),
+  );
+  return $form;
+}
+
+/**
+ * Display the page containing the list of image styles.
+ *
+ * @param $styles
+ *   An array of all the image styles returned by image_get_styles().
+ * @see image_get_styles()
+ * @ingroup themeable
+ */
+function theme_image_style_list($styles) {
+  $header = array(t('Style name'), array('data' => t('Operations'), 'colspan' => 3));
+  $rows = array();
+  foreach ($styles as $style) {
+    $row = array();
+    $row[] = l($style['name'], 'admin/settings/image-styles/edit/' . $style['name']);
+    $link_attributes = array(
+      'attributes' => array(
+        'class' => 'image-style-link',
+      ),
+    );
+    $row[] = l(t('Edit'), 'admin/settings/image-styles/edit/' . $style['name'], $link_attributes);
+    $row[] = l(t('Flush'), 'admin/settings/image-styles/flush/' . $style['name'], $link_attributes);
+    $row[] = l(t('Delete'), 'admin/settings/image-styles/delete/' . $style['name'], $link_attributes);
+    $rows[] = $row;
+  }
+
+  if (empty($rows)) {
+    $rows[] = array(array(
+      'colspan' => 4,
+      'data' => t('There are currently no styles. <a href="!url">Add a new one</a>.', array('!url' => url('admin/settings/image-styles/add'))),
+    ));
+  }
+
+  return theme('table', $header, $rows);
+}
+
+/**
+ * Theme callback for listing the effects within a specific image style.
+ *
+ * @param $form
+ *   An associative array containing the structure of the effects group.
+ * @ingroup themeable
+ */
+function theme_image_style_effects($form) {
+  $rows = array();
+
+  foreach (element_children($form) as $key) {
+    if (is_numeric($key)) {
+      $form[$key]['weight']['#attributes']['class'] = 'image-effect-order-weight';
+      $summary = drupal_render($form[$key]['summary']);
+      $row = array();
+      $row[] = drupal_render($form[$key]['name']) . (empty($summary) ? '' : ' ' . $summary);
+      $row[] = drupal_render($form[$key]['weight']);
+      $row[] = drupal_render($form[$key]['configure']);
+      $row[] = drupal_render($form[$key]['remove']);
+    }
+    else {
+      // Add the row for adding a new effect.
+      $form['new']['weight']['#attributes']['class'] = 'image-effect-order-weight';
+      $row = array();
+      $row[] = '<div class="image-style-new">' . drupal_render($form['new']['new']) . drupal_render($form['new']['add']) . '</div>';
+      $row[] = drupal_render($form['new']['weight']);
+      $row[] = array('data' => '', 'colspan' => 2);
+    }
+
+    $rows[] = array(
+      'data' => $row,
+      'class' => 'draggable',
+    );
+  }
+
+  $header = array(
+    t('Effect'),
+    t('Weight'),
+    array('data' => t('Operations'), 'colspan' => 2),
+  );
+
+  if (count($rows) == 1) {
+    array_unshift($rows, array(array(
+      'data' => t('There are currently no effects in this style. Add one by selecting an option below.'),
+      'colspan' => 4,
+    )));
+  }
+
+  $output = theme('table', $header, $rows, array('id' => 'image-style-effects'));
+  drupal_add_tabledrag('image-style-effects', 'order', 'sibling', 'image-effect-order-weight');
+  return $output;
+}
+
+/**
+ * Theme callback for displaying a preview of a style.
+ */
+function theme_image_style_preview($style) {
+  $sample_image = variable_get('image_style_preview_image', drupal_get_path('module', 'image') . '/images/sample.jpg');
+  $sample_width = 160;
+  $sample_height = 160;
+
+  // Set up original file information.
+  $original_path = $sample_image;
+  $original_image = image_get_info($original_path);
+  if ($original_image['width'] > $original_image['height']) {
+    $original_width = min($original_image['width'], $sample_width);
+    $original_height = round($original_width / $original_image['width'] * $original_image['height']);
+  }
+  else {
+    $original_height = min($original_image['height'], $sample_height);
+    $original_width = round($original_height / $original_image['height'] * $original_image['width']);
+  }
+  $original_attributes = array_intersect_key($original_image, array('width' => '', 'height' => ''));
+  $original_attributes['style'] = 'width: ' . $original_width . 'px; height: ' . $original_height . 'px;';
+
+  // Set up preview file information.
+  $preview_file = image_style_path($style['name'], $original_path);
+  $preview_path = file_create_path($preview_file);
+  if (!file_exists($preview_path) && image_style_create_derivative($style, $original_path, $preview_file)) {
+    $preview_path = file_create_path($preview_file);
+  }
+  $preview_image = image_get_info($preview_path);
+  if ($preview_image['width'] > $preview_image['height']) {
+    $preview_width = min($preview_image['width'], $sample_width);
+    $preview_height = round($preview_width / $preview_image['width'] * $preview_image['height']);
+  }
+  else {
+    $preview_height = min($preview_image['height'], $sample_height);
+    $preview_width = round($preview_height / $preview_image['height'] * $preview_image['width']);
+  }
+  $preview_attributes = array_intersect_key($preview_image, array('width' => '', 'height' => ''));
+  $preview_attributes['style'] = 'width: ' . $preview_width . 'px; height: ' . $preview_height . 'px;';
+
+  // Timestamps are added on output to prevent caching of preview images.
+  $output = '';
+  $output .= '<div class="image-style-preview preview clearfix">';
+  $output .= '<div class="preview-image-wrapper">';
+  $output .= t('original image');
+  $output .= '<div class="preview-image original-image" style="' . $original_attributes['style'] . '">';
+  $output .= '<a href="' . url($original_path) . '?' . time() . '">' . theme('image', $original_path . '?' . time(), t('Sample original image'), '', $original_attributes, FALSE) . '</a>';
+  $output .= '<div class="height" style="height: ' . $original_height . 'px"><span>' . $original_image['height'] . 'px</span></div>';
+  $output .= '<div class="width" style="width: ' . $original_width . 'px"><span>' . $original_image['width'] . 'px</span></div>';
+  $output .= '</div>'; // End preview-image.
+  $output .= '</div>'; // End preview-image-wrapper.
+  $output .= '<div class="preview-image-wrapper">';
+  $output .= check_plain($style['name']);
+  $output .= '<div class="preview-image modified-image" style="' . $preview_attributes['style'] . '">';
+  $output .= '<a href="' . file_create_url($preview_file) . '?' . time() . '">' . theme('image', file_create_url($preview_file) . '?' . time(), t('Sample modified image'), '', $preview_attributes, FALSE) . '</a>';
+  $output .= '<div class="height" style="height: ' . $preview_height . 'px"><span>' . $preview_image['height'] . 'px</span></div>';
+  $output .= '<div class="width" style="width: ' . $preview_width . 'px"><span>' . $preview_image['width'] . 'px</span></div>';
+  $output .= '</div>'; // End preview-image.
+  $output .= '</div>'; // End preview-image-wrapper.
+  $output .= '</div>'; // End image-style-preview.
+
+  return $output;
+}
+
+/**
+ * Theme callback for displaying a grid of checkboxes.
+ */
+function theme_image_anchor($element) {
+  $element_children = element_children($element);
+  $size = ceil(sqrt(count($element_children)));
+
+  $rows = array();
+  $row = array();
+  foreach ($element_children as $n => $key) {
+    $element[$key]['#attributes']['title'] = $element[$key]['#title'];
+    unset($element[$key]['#title']);
+    $row[] = drupal_render($element[$key]);
+    if ($n % $size == $size - 1) {
+      $rows[] = $row;
+      $row = array();
+    }
+  }
+
+  return theme('table', array(), $rows, array('class' => 'image-anchor'));
+}
+
+/**
+ * Theme callback for image resize effect summary output.
+ *
+ * @param $data
+ *   The current configuration for this resize effect.
+ * @ingroup themeable
+ */
+function theme_image_resize_summary($data) {
+  return $data['width'] . 'x' . $data['height'];
+}
+
+/**
+ * Theme callback for image scale effect summary output.
+ *
+ * @param $data
+ *   The current configuration for this scale effect.
+ * @ingroup themeable
+ */
+function theme_image_scale_summary($data) {
+  return theme('image_resize_summary', $data) . ' ' . ($data['upscale'] ? '(' . t('upscaling allowed') . ')' : '');
+}
+
+/**
+ * Theme callback for image crop effect summary output.
+ *
+ * @param $data
+ *   The current configuration for this crop effect.
+ * @ingroup themeable
+ */
+function theme_image_crop_summary($data) {
+  return $data['width'] . 'x' . $data['height'];
+}
+
+/**
+ * Theme callback for image rotate effect summary output.
+ *
+ * @param $data
+ *   The current configuration for this rotate effect.
+ * @ingroup themeable
+ */
+function theme_image_rotate_summary($data) {
+  return t('@degrees&deg;', array('@degrees' => $data['degrees'])) . ($data['random'] ? (' (' . t('random') . ')') : '');
+}
diff --git a/modules/image/image.api.php b/modules/image/image.api.php
new file mode 100644
index 0000000..aef2334
--- /dev/null
+++ b/modules/image/image.api.php
@@ -0,0 +1,111 @@
+<?php
+// $Id$
+
+/**
+ * @file
+ * Hooks related to image styles and effects.
+ */
+ 
+/**
+ * @addtogroup hooks
+ * @{
+ */
+
+/**
+ * Define image effects.
+ *
+ * This hook enables modules to define image manipulation effects for use with
+ * an image style.
+ *
+ * @return
+ *   An array of image effects. Each effect has a key corresponding to the
+ *   machine-readable effect name. The effect is an associative array that may
+ *   contain the following key-value paris:
+ *
+ *   - "name": Required. The human-readable name of the effect.
+ *   - "description": Required. A brief description of the effect.
+ *   - "function": Required. The function to call to perform this effect.
+ *   - "form": The name of a function that will return a $form array providing
+ *     a configuration form for this effect.
+ *   - "summary": The name of a theme function that will output a summary of
+ *     this effects configuration.
+ *   - "file": The name of an include file that the effect can be found in
+ *     relative to the implementing module's path.
+ *   - "file path": The directory path in which the include file resides. If
+ *     left empty this will default to the implementing module's directory.
+ */
+function hook_image_effects() {
+  $effects = array();
+
+  $effects['mymodule_resize'] = array(
+    'name' => t('Resize'),
+    'descritpion' => t('Resize an image to an exact set of dimensions, ignoring aspect ratio.'),
+    'function' => 'mymodule_resize_image',
+    'form' => 'mymodule_resize_form',
+    'summary' => 'mymodule_resize_summary',
+    'file' => 'mymodule.effects.inc',
+  );
+
+  return $effects;
+}
+
+/**
+ * Respond to style updating.
+ *
+ * This hook enables modules to update settings that might be affected by
+ * changes to an image. For example, updating a module specific variable to
+ * reflect a change in the style's name.
+ *
+ * @param $style
+ *   The style being updated.
+ * @return
+ *   None.
+ */
+function hook_image_style_save($style) {
+  // If a module defines an image style and that style is renamed by the user
+  // the module should update any references to that style.
+  if (isset($style['old_name']) && $style['old_name'] == variable_get('mymodule_image_style', '')) {
+    variable_set('mymodule_image_style', $style['name']);
+  }
+}
+
+/**
+ * Respond to image style deletion.
+ *
+ * This hook enables modules to update settings when a style is being deleted.
+ * If a style is deleted, a replacement name may be specified in $style['name']
+ * and the style being deleted will be specified in $style['old_name'].
+ *
+ * @param $style
+ *   The style being deleted.
+ * @return
+ *   None.
+ */
+function hook_image_style_delete($style) {
+  // Administrators can choose an optional replacement style when deleting.
+  // Update the modules style variable accordingly.
+  if (isset($style['old_name']) && $style['old_name'] == variable_get('mymodule_image_style', '')) {
+    variable_set('mymodule_image_style', $style['name']);
+  }
+}
+
+/**
+ * Respond to image style flushing.
+ *
+ * This hook enables modules to take effect when a style is being flushed (all
+ * images are being deleted from the server and regenerated). Any
+ * module-specific caches that contain information related to the style should
+ * be cleared using this hook. This hook is called whenever a style is updated,
+ * deleted, any effect associated with the style is update or deleted, or when
+ * the user selects the style flush option.
+ *
+ * @param $style
+ *   The image style being flushed.
+ */
+function hook_image_style_flush($style) {
+  // Empty cached data that contains information about the style.
+  cache_clear_all('*', 'cache_mymodule', TRUE);
+}
+ /**
+  * @} End of "addtogroup hooks".
+  */
diff --git a/modules/image/image.effects.inc b/modules/image/image.effects.inc
new file mode 100644
index 0000000..3b50dec
--- /dev/null
+++ b/modules/image/image.effects.inc
@@ -0,0 +1,330 @@
+<?php
+// $Id$
+
+/**
+ * @file
+ * Functions needed to execute image effects provided by Image module.
+ */
+
+/**
+ * Implements hook_image_effects().
+ *
+ * @return array
+ *   An array of information on the effects implemented by a module. The array
+ *   contains a sub-array for each effect node type, with the machine-readable
+ *   effect name as the key. Each sub-array has the following possible
+ *    attributes:
+ *    - name: The human-readable name of the effect. Required.
+ *    - description: a brief description of the effect. Required.
+ *    - function: The name of the function that will perform this effect.
+ *      Required.
+ *    - form: The name of the function providing a configuration form for this
+ *      effect. Required.
+ *    - summary: The name of a theme function for outputting a summary of the
+ *      effect configuration. Required.
+ *    - file: The name of the include file the effect can be found in relative
+ *      to the implementing module's path.
+ *    - file path: The directory path to the include file. If left empty, this
+ *      will default to the implementing module's directory.
+ */
+function image_image_effects() {
+  $effects = array(
+    'image_resize' => array(
+      'name' => t('Resize'),
+      'description' => t('Resize an image to an exact set of dimensions, ignoring aspect ratio.'),
+      'function' => 'image_resize_effect',
+      'form' => 'image_resize_form',
+      'summary' => 'image_resize_summary',
+    ),
+    'image_scale' => array(
+      'name' => t('Scale'),
+      'description' => t('Resize an image maintaining the original aspect-ratio (only one value necessary).'),
+      'function' => 'image_scale_effect',
+      'form' => 'image_scale_form',
+      'summary' => 'image_scale_summary',
+    ),
+    'image_scale_and_crop' => array(
+      'name' => t('Scale and Crop'),
+      'description' => t('Resize an image maintaining the original aspect-ratio, then crop the center of the image to specific dimensions.'),
+      'function' => 'image_scale_and_crop_effect',
+      'form' => 'image_resize_form',
+      'summary' => 'image_resize_summary',
+    ),
+    'image_crop' => array(
+      'name' => t('Crop'),
+      'description' => t('Crop an image to the rectangle specified by the given offsets and dimensions.'),
+      'function' => 'image_crop_effect',
+      'form' => 'image_crop_form',
+      'summary' => 'image_crop_summary',
+    ),
+    'image_desaturate' => array(
+      'name' => t('Desaturate'),
+      'description' => t('Convert an image to grayscale.'),
+      'function' => 'image_desaturate_effect',
+    ),
+    'image_rotate' => array(
+      'name' => t('Rotate'),
+      'description' => t('Rotate an image.'),
+      'function' => 'image_rotate_effect',
+      'form' => 'image_rotate_form',
+      'summary' => 'image_rotate_summary',
+    ),
+  );
+
+  return $effects;
+}
+
+/**
+ * Return the URL for an image derivative given a style and image path.
+ *
+ * This function is the default image generation method. It returns a URL for
+ * an image that can be used in an <img> tag. When the browser requests the
+ * image at image/generate/[style_name]/[path] the image is generated if it does
+ * not already exist and then served to the browser. This allows each image to
+ * have its own PHP instance (and memory limit) for generation of the new image.
+ *
+ * @param $style
+ *   An image style array.
+ * @param $path
+ *   The local path of the image to be generated, excluding the files
+ *   directory.
+ * @return
+ *   Absolute URL where the image can be downloaded, suitale for use in an
+ *   <img> tag. Requesting the URL will cause the image to be created.
+ * @see image_style_generate()
+ * @see image_style_generate_url()
+ */
+function image_style_generate_url($style, $path) {
+  $destination = image_style_path($style['name'], $path);
+
+  // If the image already exists return true.
+  if (file_exists($destination)) {
+    return image_style_url($style['name'], $path);
+  }
+
+  // Disable page cache for this request. This prevents anonymous users from
+  // needlessly hitting the image generation URL when the image already exists.
+  $GLOBALS['conf']['cache'] = CACHE_DISABLED;
+
+  // Set a cache entry to grant access to this style/image path. This will be
+  // checked by image_style_generate().
+  cache_set('access:' . $style['name'] . ':' . md5($path), 1, 'cache_image', time() + 600);
+
+  // Generate a callback path for the image.
+  $url = url('image/generate/' . $style['name'] . '/' . $path, array('absolute' => TRUE));
+  return $url;
+}
+
+/**
+ * Menu callback; Given a style and image path, generate a derivative.
+ *
+ * This menu callback is always served after checking a token to prevent
+ * generation of unnecessary images. After generating an image transfer it to
+ * the requesting agent via file_transfer().
+ */
+function image_style_generate() {
+  $args = func_get_args();
+  $style = array_shift($args);
+  $style_name = $style['name'];
+  $path = implode('/', $args);
+
+  $source = file_create_path($path);
+  $path_md5 = md5($path);
+  $destination = image_style_path($style['name'], $path);
+
+  // Check that it's a defined style and that access was granted by
+  // image_style_generate_url().
+  if (!$style || !cache_get('access:' . $style_name . ':' . $path_md5, 'cache_image')) {
+    drupal_access_denied();
+    exit();
+  }
+
+  // Don't start generating the image if it is already in progress.
+  $cid = 'generate:' . $style_name . ':' . $path_md5;
+  if (cache_get($cid, 'cache_image')) {
+    print t('Image generation in progress, please try again shortly.');
+    exit();
+  }
+
+  // If the image has already been generated then send it.
+  if ($image = image_load($destination)) {
+    file_transfer($image->source, array('Content-type: ' . $image->info['mime_type'], 'Content-length: ' . $image->info['file_size']));
+  }
+
+  // Set a cache entry designating this image as being in-process.
+  cache_set($cid, $destination, 'cache_image');
+
+  // Try to generate the image.
+  if (image_style_create_derivative($style, $source, $destination)) {
+    $image = image_load($destination);
+    cache_clear_all($cid, 'cache_image');
+    file_transfer($image->source, array('Content-type: ' . $image->info['mime_type'], 'Content-length: ' . $image->info['file_size']));
+  }
+  else {
+    cache_clear_all($cid, 'cache_image');
+    watchdog('image', 'Unable to generate the derived image located at %path.', $destination);
+    print t('Error generating image.');
+    exit();
+  }
+}
+
+/**
+ * Access callback for image/generate.
+ *
+ * Ensure this request is made by Drupal by checking for a valid site token.
+ */
+function image_style_generate_access() {
+  $args = func_get_args();
+  $style_name = array_shift($args);
+  $path = implode('/', $args);
+
+  return isset($_GET['token']) && drupal_valid_token($_GET['token'], $path);
+}
+
+/**
+ * Implements the default image resize effect.
+ *
+ * @param $image
+ *   An image object.
+ * @param $data
+ *   An array of attributes to use when performing the resize effect.
+ *   array('width' => int, 'height' => int)
+ * @return
+ *   TRUE on success. FALSE on failure to resize image.
+ * @see image_resize()
+ */
+function image_resize_effect(&$image, $data) {
+  if (!image_resize($image, $data['width'], $data['height'])) {
+    watchdog('image', 'Image resize failed. image: %image, data: %data.', array('%image' => $image, '%data' => print_r($data, TRUE)), WATCHDOG_ERROR);
+    return FALSE;
+  }
+  return TRUE;
+}
+
+/**
+ * Implements the default image scale effect.
+ *
+ * @param $image
+ *   An image object.
+ * @param $data
+ *   An array of attributes to use when performing the scale effect.
+ *   array('width' => int, 'height' => int, 'upscale' => bool)
+ * @return
+ *   TRUE on success. FALSE on failure to scale image.
+ * @see image_scale()
+ */
+function image_scale_effect(&$image, $data) {
+  // Set impossibly large values if the width and height aren't set.
+  $data['width'] = $data['width'] ? $data['width'] : PHP_INT_MAX;
+  $data['height'] = $data['height'] ? $data['height'] : PHP_INT_MAX;
+  if (!image_scale($image, $data['width'], $data['height'], $data['upscale'])) {
+    watchdog('image', 'Image scale failed. image: %image, data: %data.', array('%image' => $image, '%data' => print_r($data, TRUE)), WATCHDOG_ERROR);
+    return FALSE;
+  }
+  return TRUE;
+}
+
+/**
+ * Implements the default image crop effect.
+ *
+ * @param $image
+ *   An image object.
+ * @param $data
+ *   An array containting attributes to use when preforming the crop effect.
+ *   array('xoffset' => int, 'yoffset' => int, 'width' => int, 'height' => int)
+ * @return
+ *   TRUE on success. FALSE on failure to crop image.
+ * @see image_crop()
+ */
+function image_crop_effect(&$image, $data) {
+  list($x, $y) = explode('-', $data['anchor']);
+  $x = image_filter_keyword($x, $image->info['width'], $data['width']);
+  $y = image_filter_keyword($y, $image->info['height'], $data['height']);
+  if (!image_crop($image, $x, $y, $data['width'], $data['height'])) {
+    watchdog('image', 'Image crop failed. image: %image, data: %data.', array('%image' => $image, '%data' => print_r($data, TRUE)), WATCHDOG_ERROR);
+    return FALSE;
+  }
+  return TRUE;
+}
+
+/**
+ * Implements the default image scale and crop effect.
+ *
+ * @param $image
+ *   An image object.
+ * @param $data
+ *   An array of attributes to use when performing the scale and crop effect.
+ *   array('width' => int, 'height' => int)
+ * @return
+ *   TRUE on success. FALSE on failure to scale and crop image.
+ * @see image_scale_and_crop()
+ */
+function image_scale_and_crop_effect(&$image, $data) {
+  if (!image_scale_and_crop($image, $data['width'], $data['height'])) {
+    watchdog('image', t('Image scale and crop failed. image: %image, data: %data.', array('%image' => $image, '%data' => print_r($data, TRUE))), WATCHDOG_ERROR);
+    return FALSE;
+  }
+  return TRUE;
+}
+
+/**
+ * Implements the default image desaturate effect.
+ *
+ * @param $image
+ *   An image object.
+ * @param $data
+ *   An array of attributes to use when performing the desaturate effect.
+ * @return
+ *   TRUE on success. FALSE on failure to desaturate image.
+ * @see image_desaturate()
+ */
+function image_desaturate_effect(&$image, $data) {
+  if (!image_desaturate($image)) {
+    watchdog('image', 'Image desaturate failed. image: %image, data: %data.', array('%image' => $image, '%data' => print_r($data, TRUE)), WATCHDOG_ERROR);
+    return FALSE;
+  }
+  return TRUE;
+}
+
+/**
+ * Implements the default image rotate effect.
+ *
+ * @param $image
+ *   An image object.
+ * @param $data
+ *   An array of attributes to use when performing the rotate effect.
+ *   array('degrees' => int, 'random' => bool, 'bgcolor' => string)
+ * @return
+ *   TRUE on success. FALSE on failure to rotate image.
+ * @see image_rotate().
+ */
+function image_rotate_effect(&$image, $data) {
+  // Set sane default values.
+  $data['degrees'] = $data['degrees'] ? $data['degrees'] : 0;
+  $data['random'] = $data['random'] ? $data['random'] : FALSE;
+
+  // Convert short #FFF syntax to full #FFFFFF syntax.
+  if (strlen($data['bgcolor']) == 4) {
+    $c = $data['bgcolor'];
+    $data['bgcolor'] = $c[0] . $c[1] . $c[1] . $c[2] . $c[2] . $c[3] . $c[3];
+  }
+
+  // Convert #FFFFFF syntax to hexadecimal colors.
+  if ($data['bgcolor'] != '') {
+    $data['bgcolor'] = hexdec(str_replace('#', '0x', $data['bgcolor']));
+  }
+  else {
+    $data['bgcolor'] = NULL;
+  }
+
+  if (!empty($data['random'])) {
+    $degrees = abs((float)$data['degrees']);
+    $data['degrees'] = rand(-1 * $degrees, $degrees);
+  }
+
+  if (!image_rotate($image, $data['degrees'], $data['bgcolor'])) {
+    watchdog('image', t('Image rotate failed. image: %image, data: %data.', array('%image' => $image, '%data' => print_r($data, TRUE))), WATCHDOG_ERROR);
+    return FALSE;
+  }
+  return TRUE;
+}
diff --git a/modules/image/image.info b/modules/image/image.info
new file mode 100644
index 0000000..08b5695
--- /dev/null
+++ b/modules/image/image.info
@@ -0,0 +1,12 @@
+; $Id: blog.info,v 1.11 2009/06/08 09:23:51 dries Exp $
+
+name = Image
+description = Provides image manipulation tools.
+package = Core
+version = VERSION
+core = 7.x
+files[] = image.module
+files[] = image.admin.inc
+files[] = image.effects.inc
+files[] = image.install
+files[] = image.test
diff --git a/modules/image/image.install b/modules/image/image.install
new file mode 100644
index 0000000..db11474
--- /dev/null
+++ b/modules/image/image.install
@@ -0,0 +1,133 @@
+<?php
+// $Id$
+
+/**
+ * @file
+ * Install, update and uninstall functions for the image module.
+ */
+
+/**
+ * Implement hook_install().
+ */
+function image_install() {
+  drupal_install_schema('image');
+}
+
+/**
+ * Implement hook_uninstall().
+ */
+function image_uninstall() {
+  drupal_uninstall_schema('image');
+}
+
+/**
+ * Implement hook_schema().
+ */
+function image_schema() {
+  $schema = array();
+
+  $schema['cache_image'] = array(
+    'description' => 'Cache table used to store information about image maniupaltions that are in-progress.',
+    'fields' => array(
+      'cid' => array(
+        'description' => 'Primary Key: Unique cache ID.',
+        'type' => 'varchar',
+        'length' => 255,
+        'not null' => TRUE,
+        'default' => '',
+      ),
+      'data' => array(
+        'description' => 'A collection of data to cache.',
+        'type' => 'blob',
+        'not null' => FALSE,
+        'size' => 'big',
+      ),
+      'expire' => array(
+        'description' => 'A Unix timestamp indicating when the cache entry should expire, or 0 for never.',
+        'type' => 'int',
+        'not null' => TRUE,
+        'default' => 0,
+      ),
+      'created' => array(
+        'description' => 'A Unix timestamp indicating when the cache entry was created.',
+        'type' => 'int',
+        'not null' => TRUE,
+        'default' => 0,
+      ),
+      'headers' => array(
+        'description' => 'Any custom HTTP headers to be added to cached data.',
+        'type' => 'text',
+        'not null' => FALSE,
+      ),
+      'serialized' => array(
+        'description' => 'A flag to indicate whether content is serialized (1) or not (0).',
+        'type' => 'int',
+        'size' => 'small',
+        'not null' => TRUE,
+        'default' => 0,
+      ),
+    ),
+    'indexes' => array(
+      'expire' => array('expire'),
+    ),
+    'primary key' => array('cid'),
+  );
+
+  $schema['image_styles'] = array(
+    'fields' => array(
+      'isid' => array(
+        'description' => 'The primary identifier for an image style.',
+        'type' => 'serial',
+        'unsigned' => TRUE,
+        'not null' => TRUE),
+      'name' => array(
+        'description' => 'The style name.',
+        'type' => 'varchar',
+        'length' => 255,
+        'not null' => TRUE),
+    ),
+    'primary key' => array('isid'),
+    'indexes' => array(
+      'name' => array('name'),
+    ),
+  );
+
+  $schema['image_effects'] = array(
+    'fields' => array(
+      'ieid' => array(
+        'description' => 'The primary identifier for an image effect.',
+        'type' => 'serial',
+        'unsigned' => TRUE,
+        'not null' => TRUE),
+      'isid' => array(
+        'description' => 'The primary identifier for an image style.',
+        'type' => 'int',
+        'unsigned' => TRUE,
+        'not null' => TRUE,
+        'default' => 0),
+      'weight' => array(
+        'description' => 'The weight of the effect in the style.',
+        'type' => 'int',
+        'unsigned' => FALSE,
+        'not null' => TRUE,
+        'default' => 0),
+      'effect' => array(
+        'description' => 'The unique ID of the effect to be executed.',
+        'type' => 'varchar',
+        'length' => 255,
+        'not null' => TRUE),
+      'data' => array(
+        'description' => 'The configuration data for the effect.',
+        'type' => 'text',
+        'not null' => TRUE,
+        'size' => 'big',
+        'serialize' => TRUE),
+    ),
+    'primary key' => array('ieid'),
+    'indexes' => array(
+      'isid' => array('isid'),
+    ),
+  );
+
+  return $schema;
+}
diff --git a/modules/image/image.module b/modules/image/image.module
new file mode 100644
index 0000000..55d44f7
--- /dev/null
+++ b/modules/image/image.module
@@ -0,0 +1,753 @@
+<?php
+// $Id$
+
+/**
+ * @file
+ * Exposes global functionality for creating image styles.
+ */
+
+/**
+ * Implement hook_menu().
+ */
+function image_menu() {
+  $items = array();
+
+  $items['image/generate/%image_style'] = array(
+    'title' => 'Generate image style',
+    'page callback' => 'image_style_generate',
+    'page arguments' => array(2),
+    'access callback' => TRUE,
+    'type' => MENU_CALLBACK,
+  );
+  $items['admin/settings/image-styles'] = array(
+    'title' => 'Image styles',
+    'description' => 'Configure styles that can be used for resizing or adjusting images on display.',
+    'page callback' => 'image_style_list',
+    'access arguments' => array('administer image styles'),
+  );
+  $items['admin/settings/image-styles/list'] = array(
+    'title' => 'List',
+    'description' => 'List the current image styles on the site.',
+    'page callback' => 'image_style_list',
+    'access arguments' => array('administer image styles'),
+    'type' => MENU_DEFAULT_LOCAL_TASK,
+    'weight' => 1,
+  );
+  $items['admin/settings/image-styles/add'] = array(
+    'title' => 'Add style',
+    'description' => 'Add a new image style.',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('image_style_add_form'),
+    'access arguments' => array('administer image styles'),
+    'type' => MENU_LOCAL_TASK,
+    'weight' => 2,
+  );
+  $items['admin/settings/image-styles/edit/%image_style'] = array(
+    'title' => 'Edit style',
+    'title callback' => 'image_style_title',
+    'title arguments' => array('!name', 4),
+    'description' => 'Configure an image style.',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('image_style_form', 4),
+    'access arguments' => array('administer image styles'),
+    'type' => MENU_CALLBACK,
+  );
+  $items['admin/settings/image-styles/delete/%image_style'] = array(
+    'title' => 'Delete style',
+    'title callback' => 'image_style_title',
+    'title arguments' => array('Delete !name', 4),
+    'description' => 'Delete an image style.',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('image_style_delete_form', 4, TRUE),
+    'access arguments' => array('administer image styles'),
+    'type' => MENU_CALLBACK,
+  );
+  $items['admin/settings/image-styles/flush/%image_style'] = array(
+    'title' => 'Flush style',
+    'title callback' => 'image_style_title',
+    'title arguments' => array('Flush !name', 4),
+    'description' => 'Flush all the created images for a style.',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('image_style_flush_form', 4, TRUE),
+    'access arguments' => array('administer image styles'),
+    'type' => MENU_CALLBACK,
+  );
+  $items['admin/settings/image-styles/edit/%image_style/effects/%image_effect'] = array(
+    'title' => 'Edit image effect',
+    'title callback' => 'image_effect_title',
+    'title arguments' => array('!name effect', 6),
+    'description' => 'Edit an exiting effect within a style.',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('image_effect_form', 4, 6),
+    'access arguments' => array('administer image styles'),
+    'type' => MENU_CALLBACK,
+  );
+  $items['admin/settings/image-styles/edit/%image_style/effects/%image_effect/delete'] = array(
+    'title' => 'Delete image effect',
+    'title callback' => 'image_effect_title',
+    'title arguments' => array('Delete !name', 6),
+    'description' => 'Delete an exiting effect from a style.',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('image_effect_delete_form', 4, 6),
+    'access arguments' => array('administer image styles'),
+    'type' => MENU_CALLBACK,
+  );
+  $items['admin/settings/image-styles/edit/%image_style/add/%image_effect_definition'] = array(
+    'title' => 'Add image effect',
+    'title callback' => 'image_effect_title',
+    'title arguments' => array('Add !name effect', 6),
+    'description' => 'Add a new effect to a style.',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('image_effect_form', 4, 6),
+    'access arguments' => array('administer image styles'),
+    'type' => MENU_CALLBACK,
+  );
+
+  return $items;
+}
+
+/**
+ * Implement hook_theme().
+ */
+function image_theme() {
+  return array(
+    'image_style' => array(
+      'arguments' => array('style' => NULL, 'path' => NULL, 'alt' => '', 'title' => '', 'attributes' => NULL, 'getsize' => TRUE),
+    ),
+    'image_style_list' => array(
+      // TODO: Remove 'page' => TRUE when two parameters become unnecessary.
+      'arguments' => array('styles' => NULL, 'page' => TRUE),
+      'file' => 'image.admin.inc',
+    ),
+    'image_style_effects' => array(
+      'arguments' => array('form' => NULL),
+      'file' => 'image.admin.inc',
+    ),
+    'image_style_preview' => array(
+      'arguments' => array('style' => NULL),
+    ),
+    'image_resize_summary' => array(
+      'arguments' => array('data' => NULL),
+      'file' => 'image.effects.inc',
+    ),
+    'image_scale_summary' => array(
+      'arguments' => array('data' => NULL),
+      'file' => 'image.effects.inc',
+    ),
+    'image_crop_summary' => array(
+      'arguments' => array('data' => NULL),
+      'file' => 'image.effects.inc',
+    ),
+    'image_rotate_summary' => array(
+      'arguments' => array('data' => NULL),
+      'file' => 'image.effects.inc',
+    ),
+    'image_anchor' => array(
+      'arguments' => array('element' => NULL),
+    ),
+  );
+}
+
+/**
+ * Implement hook_perm().
+ */
+function image_perm() {
+  return array(
+    'administer image styles' => array(
+      'title' => t('Administer image styles'),
+      'description' => t('Create and modify styles for generating image modifications such as thumbnails.'),
+    ),
+  );
+}
+
+/**
+ * Implement hook_flush_caches().
+ */
+function image_flush_caches() {
+  return array('cache_image');
+}
+
+/**
+ * Implements hook_file_download().
+ *
+ * Control the access to files underneath the image/generate/style directory.
+ */
+function image_file_download($filepath) {
+  if (strpos($filepath, 'styles/') === 0) {
+    $args = explode('/', $filepath);
+    array_shift($args); // Remove the "styles" item.
+    $style_name = array_shift($args);
+    $original_path = implode('/', $args);
+
+    // Check that the file exists and is an image.
+    if ($info = image_get_info(file_create_path($filepath))) {
+      // Check the permissions of the original image to grant access to this
+      // image.
+      $headers = module_invoke_all('file_download', $original_path);
+      if (!in_array(-1, $headers)) {
+        return array(
+          'Content-Type: ' . $info['mime_type'],
+          'Content-Length: ' . $info['file_size'],
+        );
+      }
+    }
+    return -1;
+  }
+}
+
+/**
+ * Implements hook_file_move().
+ */
+function image_file_move($file, $source) {
+  // Delete any image derivatives at the original image path.
+  image_path_flush($file->filepath);
+}
+
+/**
+ * Implements hook_file_delete().
+ */
+function image_file_delete($file) {
+  // Delete any image derivatives of this image.
+  image_path_flush($file->filepath);
+}
+
+/**
+ * Clear cached versions of a specific file in all styles.
+ *
+ * @param $path
+ *   The Drupal file path to the original image.
+ */
+function image_path_flush($path) {
+  $path = _image_strip_file_directory($path);
+  foreach (image_styles() as $style) {
+    if ($path = file_create_path('styles/' . $style['name'] . '/' . $path)) {
+      file_unmanaged_delete($path);
+    }
+  }
+}
+
+
+/**
+ * Get an array of all styles and their settings.
+ *
+ * @return
+ *   Array of styles array($pid => array('id' => integer, 'name' => string)).
+ */
+function image_styles() {
+  $styles = &drupal_static(__FUNCTION__, array());
+
+  // Grab from cache or build the array.
+  if ($cache = cache_get('image_styles', 'cache')) {
+    $styles = $cache->data;
+  }
+  else {
+    $result = db_select('image_styles', NULL, array('fetch' => PDO::FETCH_ASSOC))
+      ->fields('image_styles')
+      ->orderBy('name')
+      ->execute();
+    foreach ($result as $style) {
+      $styles[$style['name']] = $style;
+      $styles[$style['name']]['effects'] = image_style_effects($style);
+    }
+
+    cache_set('image_styles', $styles);
+  }
+
+  return $styles;
+}
+
+/**
+ * Load a style by style name or ID. May be used as a loader for menu items.
+ *
+ * @param $name
+ *   The name of the style.
+ * @param $pid
+ *   Optional. The numeric id of a style if the name is not known.
+ * @return
+ *   An image style with the format of
+ *   array('name' => array('isid' => int, 'name' => string, 'effects' => array())).
+ *   If the style name or ID is not valid, an empty array is returned.
+ */
+function image_style_load($name = NULL, $pid = NULL) {
+  $styles = image_styles();
+
+  // If retrieving by name.
+  if (isset($name) && isset($styles[$name])) {
+    return $styles[$name];
+  }
+
+  // If retrieving by PID.
+  if (isset($pid)) {
+    foreach ($styles as $name => $style) {
+      if ($style['isid'] == $pid) {
+        return $style;
+      }
+    }
+  }
+
+  // Otherwise the style was not found.
+  return FALSE;
+}
+
+/**
+ * Save an image style.
+ *
+ * @param style
+ *   An image style array.
+ * @return
+ *   A style array. In the case of a new style, 'isid' will be populated.
+ */
+function image_style_save($style) {
+  if (isset($style['isid']) && is_numeric($style['isid'])) {
+    // Load the existing style to make sure we account for renamed styles.
+    $old_style = image_style_load(NULL, $style['isid']);
+    image_style_flush($old_style);
+    drupal_write_record('image_styles', $style, 'isid');
+    if ($old_style['name'] != $style['name']) {
+      $style['old_name'] = $old_style['name'];
+    }
+  }
+  else {
+    drupal_write_record('image_styles', $style);
+    $style['is_new'] = TRUE;
+  }
+
+  // Let other modules update as necessary on save.
+  module_invoke_all('image_style_save', $style);
+
+  // Clear all caches and flush.
+  image_style_flush($style);
+
+  return $style;
+}
+
+/**
+ * Delete an image style.
+ *
+ * @param $style
+ *   An image style array.
+ * @param $replacement_style_name
+ *   (optional) When deleting a style, specify a replacement style name so
+ *   that existing settings (if any) may be converted to a new style.
+ * @return
+ *   TRUE on success.
+ */
+function image_style_delete($style, $replacement_style_name = '') {
+  image_style_flush($style);
+
+  db_delete('image_effects')->condition('isid', $style['isid'])->execute();
+  db_delete('image_styles')->condition('isid', $style['isid'])->execute();
+
+  // Let other modules update as necessary on save.
+  $style['old_name'] = $style['name'];
+  $style['name'] = $replacement_style_name;
+  module_invoke_all('image_style_delete', $style);
+
+  return TRUE;
+}
+
+/**
+ * Load all the effects for an image style.
+ *
+ * @param $style
+ *   An image style array.
+ * @return
+ *   An array of effects associated with specified style in the format
+ *   array('isid' => array()), or an empty array if the specified style has
+ *   no effects.
+ */
+function image_style_effects($style) {
+  $effects = image_effects();
+  $style_effects = array();
+  foreach ($effects as $effect) {
+    if ($style['isid'] == $effect['isid']) {
+      $style_effects[$effect['ieid']] = $effect;
+    }
+  }
+
+  return $style_effects;
+}
+
+
+/**
+ * Get an array of image styles suitable for using as select list options.
+ *
+ * @param $include_empty
+ *   If TRUE a <none> option will be inserted in the options array.
+ * @return
+ *   Array of image styles both key and value are set to style name.
+ */
+function image_style_options($include_empty = TRUE) {
+  $styles = image_styles();
+  $options = array();
+  if ($include_empty && !empty($styles)) {
+    $options[''] = t('<none>');
+  }
+  $options = array_merge($options, drupal_map_assoc(array_keys($styles)));
+  if (empty($options)) {
+    $options[''] = t('No defined styles');
+  }
+  return $options;
+}
+
+/**
+ * Flush cached media for a style.
+ *
+ * @param $style
+ *   An image style array.
+ */
+function image_style_flush($style) {
+  $style_directory = realpath(file_directory_path() . '/styles/' . $style['name']);
+  if (is_dir($style_directory)) {
+    file_unmanaged_delete_recursive($style_directory);
+  }
+
+  // Let other modules update as necessary on flush.
+  module_invoke_all('image_style_flush', $style);
+
+  // Clear image style and effect caches.
+  cache_clear_all('image_styles', 'cache');
+  cache_clear_all('image_effects', 'cache');
+  drupal_static_reset('image_styles');
+  drupal_static_reset('image_effects');
+
+  // Clear page caches when flushing.
+  cache_clear_all('*', 'cache_block', TRUE);
+  cache_clear_all('*', 'cache_page', TRUE);
+}
+
+/**
+ * Return the complete URL to an image when using a style.
+ *
+ * If the image has already been created then its location will be returned. If
+ * it does not then image_style_generate_url() will be called.
+ *
+ * @param $style_name
+ *   The name of the style to be used with this image.
+ * @param $path
+ *   The path to the image.
+ * @return
+ *   The absolute URL to a style image. If the site is using the default
+ *   method for generating images, the may not yet and will only be created
+ *   when a visitor's browser requests the file.
+ * @see image_style_generate_url()
+ */
+function image_style_url($style_name, $path) {
+  $style_path = image_style_path($style_name, $path);
+  if (file_exists($style_path)) {
+    return file_create_url($style_path);
+  }
+  return image_style_generate_url($style_name, $path);
+}
+
+/**
+ * Return a relative path to an image when using a style.
+ *
+ * The path returned by this function may not exist. The default generation
+ * method only creates images when they are requested by a user's browser.
+ *
+ * @param $style_name
+ *   The name of the style to be used with this image.
+ * @param $path
+ *   The path to the image.
+ * @return
+ *   The path to an image style image relative to Drupal's root.
+ */
+function image_style_path($style_name, $path) {
+  return file_directory_path() . '/styles/' . $style_name . '/' . _image_strip_file_directory($path);
+}
+
+/**
+ * Create a new image based on an image style.
+ *
+ * @param $style
+ *   An image style array.
+ * @param $source
+ *   Path of the source file.
+ * @param $destination
+ *   Path of the destination file.
+ * @return
+ *   TRUE if an image derivative is generated, FALSE if no image derivative
+ *   is generated. NULL if the derivative is being generated.
+ */
+function image_style_create_derivative($style, $source, $destination) {
+  // Get the folder for the final location of this style.
+  $directory = dirname($destination);
+
+  // Build the destination folder tree if it doesn't already exist.
+  if (!file_check_directory($directory, FILE_CREATE_DIRECTORY) && !mkdir($directory, 0775, TRUE)) {
+    watchdog('image', 'Failed to create style directory: %directory', array('%directory' => $directory), WATCHDOG_ERROR);
+    return FALSE;
+  }
+
+  if (!$image = image_load($source)) {
+    return FALSE;
+  }
+
+  foreach ($style['effects'] as $effect) {
+    image_effect_apply($image, $effect);
+  }
+
+  if (!image_save($image, $destination)) {
+    if (file_exists($destination)) {
+      watchdog('image', 'Cached image file %destination already exists. There may be an issue with your rewrite configuration.', array('%destination' => $destination), WATCHDOG_ERROR);
+    }
+    return FALSE;
+  }
+
+  return TRUE;
+}
+
+/**
+ * Load all image effects from the database.
+ *
+ * @return
+ *   Array of image effects.
+ */
+function image_effects() {
+  $effects = &drupal_static(__FUNCTION__);
+
+  if (!isset($effects)) {
+    $effects = array();
+
+    // Add database image effects.
+    $result = db_select('image_effects', NULL, array('fetch' => PDO::FETCH_ASSOC))
+      ->fields('image_effects')
+      ->orderBy('image_effects.weight', 'ASC')
+      ->execute();
+    foreach ($result as $effect) {
+      $effect['data'] = unserialize($effect['data']);
+      $definition = image_effect_definition_load($effect['effect']);
+      // Do not load effects whose definition cannot be found.
+      if ($definition) {
+        $effect = array_merge($definition, $effect);
+        $effects[$effect['ieid']] = $effect;
+      }
+    }
+  }
+
+  return $effects;
+}
+
+/**
+ * Pull in effects exposed by other modules using hook_image_effects().
+ *
+ * @param $toolkit
+ *   Name of the image toolkit to use. Toolkit set by image_get_toolkit()
+ *   will be used if none is specified.
+ * @return
+ *   An array of effects to be used when transforming images.
+ */
+function image_effect_definitions($toolkit = NULL) {
+  $effects = &drupal_static(__FUNCTION__);
+
+  if (!isset($toolkit)) {
+    $toolkit = image_get_toolkit();
+  }
+
+  if (!isset($effects)) {
+    if ($cache = cache_get('image_effects') && !empty($cache->data)) {
+      $effects = $cache->data;
+    }
+    else {
+      $effects = array();
+      foreach (module_implements('image_effects') as $module) {
+        foreach (module_invoke($module, 'image_effects') as $key => $effect) {
+          // Ensure the current toolkit supports the effect.
+          $effect['module'] = $module;
+          $effect['effect'] = $key;
+          $effect['data'] = isset($effect['data']) ? $effect['data'] : array();
+          $effects[$key] = $effect;
+        };
+      }
+      uasort($effects, '_image_effects_definitions_sort');
+      cache_set('image_effects', $effects);
+    }
+  }
+
+  return $effects;
+}
+
+/**
+ * Load the definition for an effect.
+ *
+ * The effect definition is a set of default values that applies to an effect
+ * regardless of user settings. This definition consists of an array containing
+ * at least the following values:
+ *  - effect: The unique name for the effect being performed. Usually prefixed
+ *    with the name of the module providing the effect.
+ *  - module: The module providing the effect.
+ *  - description: A description of the effect.
+ *
+ * @param $effect
+ *   The name of the effect definition to load.
+ * @return
+ *   An array containing at least the following values.
+ *   array(
+ *    'effect' => Unique name of the effect being performed.
+ *    'module' => Name of module providing the effect.
+ *    'description' => A description of the effect.
+ *   )
+ */
+function image_effect_definition_load($effect) {
+  $definition_cache = &drupal_static(__FUNCTION__);
+
+  if (!isset($definition_cache[$effect])) {
+    $definitions = image_effect_definitions();
+    $definition = (isset($definitions[$effect])) ? $definitions[$effect] : array();
+    $definition_cache[$effect] = $definition;
+  }
+
+  return isset($definition_cache[$effect]) ? $definition_cache[$effect] : FALSE;
+}
+
+/**
+ * Load a single image effect.
+ *
+ * @param $ieid
+ *   The image effect ID.
+ * @return
+ *   An image effect array or FALSE if the specified effect can not be found.
+ */
+function image_effect_load($ieid) {
+  $effects = image_effects();
+  return isset($effects[$ieid]) ? $effects[$ieid] : FALSE;
+}
+
+/**
+ * Save an image effect.
+ *
+ * @param $effect
+ *   An image effect array.
+ * @return
+ *   An image effect array. In the case of a new effect 'ieid' will be set.
+ */
+function image_effect_save($effect) {
+  if (!empty($effect['ieid'])) {
+    drupal_write_record('image_effects', $effect, 'ieid');
+  }
+  else {
+    drupal_write_record('image_effects', $effect);
+  }
+  $style = image_style_load(NULL, $effect['isid']);
+  image_style_flush($style);
+  return $effect;
+}
+
+/**
+ * Delete an image effect.
+ *
+ * @param $effect
+ *   An image effect array.
+ */
+function image_effect_delete($effect) {
+  db_delete('image_effects')->condition('ieid', $effect['ieid'])->execute();
+  $style = image_style_load(NULL, $effect['isid']);
+  image_style_flush($style);
+}
+
+/**
+ * Given an image object and effect, perform the effect on the file.
+ *
+ * @param $image
+ *   An image object.
+ * @param $effect
+ *   An image effect array.
+ * @return
+ *   TRUE on success. FALSE if unable to perform effect on image.
+ */
+function image_effect_apply(&$image, $effect) {
+  if (drupal_function_exists($effect['function'])) {
+    return call_user_func($effect['function'], $image, $effect['data']);
+  }
+  return FALSE;
+}
+
+/**
+ * Return a themed image using a specific image style.
+ *
+ * @param $style_name
+ *   The name of the style to be used to alter the original image.
+ * @param $path
+ *   The path of the image file relative to the Drupal files directory.
+ *   This function does not work with images outside the files directory nor
+ *   with remotely hosted images.
+ * @param $alt
+ *   The alternative text for text-based browsers.
+ * @param $title
+ *   The title text is displayed when the image is hovered in some popular
+ *   browsers.
+ * @param $attributes
+ *   Associative array of attributes to be placed in the img tag.
+ * @param $getsize
+ *   If set to TRUE, the image's dimension are fetched and added as
+ *   width/height attributes.
+ * @return
+ *   A string containing the image tag.
+ */
+function theme_image_style($style_name, $path, $alt = '', $title = '', $attributes = NULL, $getsize = TRUE) {
+  // theme_image() can only honor the $getsize parameter with local file paths.
+  // The derivative image is not created until it has been requested so the file
+  // may not yet exist, in this case we just fallback to the URL.
+  $style_path = image_style_path($style_name, $path);
+  if (!file_exists($style_path)) {
+    $style_path = image_style_url($style_name, $path);
+  }
+  return theme('image', $style_path, $alt, $title, $attributes, $getsize);
+}
+
+/**
+ * Accept a percentage and return it in pixels.
+ */
+function image_filter_percent($value, $current_pixels) {
+  if (strpos($value, '%') !== FALSE) {
+    $value = str_replace('%', '', $value) * 0.01 * $current_pixels;
+  }
+  return $value;
+}
+
+/**
+ * Accept a keyword (center, top, left, etc) and return it as a pixel offset.
+ */
+function image_filter_keyword($value, $current_pixels, $new_pixels) {
+  switch ($value) {
+    case 'top':
+    case 'left':
+      $value = 0;
+      break;
+    case 'bottom':
+    case 'right':
+      $value = $current_pixels - $new_pixels;
+      break;
+    case 'center':
+      $value = $current_pixels/2 - $new_pixels/2;
+      break;
+  }
+  return $value;
+}
+
+/**
+ * Remove a possible leading file directory path from the given path.
+ *
+ * @param $path
+ *   Path to a file that may be in Drupal's files directory.
+ * @return
+ *   String with Drupal's files directory removed from it.
+ */
+function _image_strip_file_directory($path) {
+  $dirpath = file_directory_path();
+  $dirlen = strlen($dirpath);
+  if (substr($path, 0, $dirlen + 1) == $dirpath . '/') {
+    $path = substr($path, $dirlen + 1);
+  }
+  return $path;
+}
+
+/**
+ * Internal function for sorting image effect definitions through uasort().
+ *
+ * @see image_effect_definitions()
+ */
+function _image_effects_definitions_sort($a, $b) {
+  return strcasecmp($a['name'], $b['name']);
+}
diff --git a/modules/image/image.test b/modules/image/image.test
new file mode 100644
index 0000000..8fc38c0
--- /dev/null
+++ b/modules/image/image.test
@@ -0,0 +1,217 @@
+<?php
+// $Id$
+
+/**
+ * @file
+ * Image module tests.
+ */
+
+/**
+ * Tests creation, deletion, and editing of image styles and effects.
+ */
+class ImageAdminstyles extends DrupalWebTestCase {
+
+  /**
+   * Implementation of getInfo().
+   */
+  function getInfo() {
+    return array(
+      'name' => t('Image styles and effects configuration'),
+      'description' => t('Tests creation, deletion, and editing of image styles and effects.'),
+      'group' => t('Image')
+    );
+  }
+
+  /**
+   * Implementation of setUp().
+   */
+  function setUp() {
+    parent::setUp();
+
+    // Create an administrative user.
+    $this->admin_user = $this->drupalCreateUser(array('administer site configuration', 'administer image styles'));
+    $this->drupalLogin($this->admin_user);
+  }
+
+  /**
+   * Given an image style, generate an image.
+   */
+  function createSampleImage($style) {
+    static $file_path;
+
+    // First, we need to make sure we have an image in our testing
+    // file directory. Copy over an image on the first run.
+    if (!isset($file_path)) {
+      $file = reset($this->drupalGetTestFiles('image'));
+      $file_path = file_unmanaged_copy($file->filename);
+    }
+
+    return image_style_generate($style['name'], $file_path) ? $file_path : FALSE;
+  }
+
+  /**
+   * Count the number of images currently create for a style.
+   */
+  function getImageCount($style) {
+    $directory = file_directory_path() . '/styles/' . $style['name'];
+    return count(file_scan_directory($directory, '/.*/'));
+  }
+
+  function teststyle() {
+    // Setup a style to be created and effects to add to it.
+    $style_name = strtolower($this->randomName(10));
+    $style_path = 'admin/settings/image-styles/' . $style_name;
+    $effect_edits = array(
+      'image_resize_effect' => array(
+        'data[width]' => 100,
+        'data[height]' => 101,
+      ),
+      'image_scale_effect' => array(
+        'data[width]' => 110,
+        'data[height]' => 111,
+        'data[upscale]' => 1,
+      ),
+      'image_scale_and_crop_effect' => array(
+        'data[width]' => 120,
+        'data[height]' => 121,
+      ),
+      'image_crop_effect' => array(
+        'data[width]' => 130,
+        'data[height]' => 131,
+        'data[anchor]' => 'center-center',
+      ),
+      'image_desaturate_effect' => array(
+        // No options for desaturate.
+      ),
+      'image_rotate_effect' => array(
+        'data[degrees]' => 5,
+        'data[random]' => 1,
+        'data[bgcolor]' => '#FFFF00',
+      ),
+    );
+
+    /* Add style form. */
+
+    $edit = array(
+      'name' => $style_name,
+    );
+    $this->drupalPost('admin/settings/image-styles/add', $edit, t('Create new style'));
+    $this->assertRaw(t('style %name was created.', array('%name' => $style_name)), t('Image style successfully created.'));
+
+    /* Add effect form. */
+
+    // Add each sample effect to the style.
+    foreach ($effect_edits as $effect => $edit) {
+      // Add the effect.
+      $this->drupalPost($style_path . '/add/' . $effect, $edit, t('Add effect'));
+    }
+
+    /* Edit effect form. */
+
+    // Revisit each form to make sure the effect was saved.
+    $style = image_style_load($style_name);
+
+    foreach ($style['effects'] as $ieid => $effect) {
+      $this->drupalGet($style_path . '/' . $ieid);
+      foreach ($effect_edits[$effect['effect']] as $field => $value) {
+        $this->assertFieldByName($field, $value, t('The %field field in the %effect effect has the correct value of %value.', array('%field' => $field, '%effect' => $effect['effect'], '%value' => $value)));
+      }
+    }
+
+    /* Image style overview form (ordering and renaming). */
+
+    // Confirm the order of effects is maintained according to the order we
+    // added the fields.
+    $effect_edits_order = array_keys($effect_edits);
+    $effects_order = array_values($style['effects']);
+    $order_correct = TRUE;
+    foreach ($effects_order as $index => $effect) {
+      if ($effect_edits_order[$index] != $effect['effect']) {
+        $order_correct = FALSE;
+      }
+    }
+    $this->assertTrue($order_correct, t('The order of the effects is correctly set by default.'));
+
+    // Test the style overview form.
+    // Change the name of the style and adjust the weights of effects.
+    $style_name = strtolower($this->randomName(10));
+    $weight = count($effect_edits);
+    $edit = array(
+      'name' => $style_name,
+    );
+    foreach ($style['effects'] as $ieid => $effect) {
+      $edit['effects[' . $ieid . '][weight]'] = $weight;
+      $weight--;
+    }
+
+    // Create an image to make sure it gets flushed after saving.
+    $image_path = $this->createSampleImage($style);
+    $this->assertEqual($this->getImageCount($style), 1, t('Image style %style image %file successfully generated.', array('%style' => $style['name'], '%file' => $image_path)));
+
+    $this->drupalPost($style_path, $edit, t('Update style'));
+
+    // Note that after changing the style name, the style path is changed.
+    $style_path = 'admin/settings/image-styles/' . $style_name;
+
+    // Check that the URL was updated.
+    $this->drupalGet($style_path);
+    $this->assertResponse(200, t('Image style %original renamed to %new', array('%original' => $style['name'], '%new' => $style_name)));
+
+    // Check that the image was flushed after updating the style.
+    // This is especially important when renaming the style. Make sure that
+    // the old image directory has been deleted.
+    $this->assertEqual($this->getImageCount($style), 0, t('Image style %style was flushed after renaming the style and updating the order of effects.', array('%style' => $style['name'])));
+
+    // Load the style by the new name with the new weights.
+    $style = image_style_load($style_name, NULL, TRUE);
+
+    // Confirm the new style order was saved.
+    $effect_edits_order = array_reverse($effect_edits_order);
+    $effects_order = array_values($style['effects']);
+    $order_correct = TRUE;
+    foreach ($effects_order as $index => $effect) {
+      if ($effect_edits_order[$index] != $effect['effect']) {
+        $order_correct = FALSE;
+      }
+    }
+    $this->assertTrue($order_correct, t('The order of the effects is correctly set by default.'));
+
+    /* Image effect deletion form. */
+
+    // Create an image to make sure it gets flushed after deleting an effect.
+    $image_path = $this->createSampleImage($style);
+    $this->assertEqual($this->getImageCount($style), 1, t('Image style %style image %file successfully generated.', array('%style' => $style['name'], '%file' => $image_path)));
+
+    // Test effect deletion form.
+    $effect = array_pop($style['effects']);
+    $this->drupalPost($style_path . '/' . $effect['ieid'] . '/delete', array(), t('Delete'));
+    $this->assertRaw(t('The image effect %name has been deleted.', array('%name' => $effect['name'])), t('Image effect deleted.'));
+
+    // Check that the style was flushed after deleting an effect.
+    $this->assertEqual($this->getImageCount($style), 0, t('Image style %style was flushed after deleting an effect.', array('%style' => $style['name'])));
+
+    /* style flush form. */
+
+    // Create an image to make sure it gets flushed after deleting an effect.
+    $image_path = $this->createSampleImage($style);
+    $this->assertEqual($this->getImageCount($style), 1, t('Image style %style image %file successfully generated.', array('%style' => $style['name'], '%file' => $image_path)));
+
+    $this->drupalPost($style_path . '/flush', array(), t('Flush'));
+    $this->assertRaw(t('style %name was flushed.', array('%name' => $style['name'])), t('Image style %style flush form submitted.'));
+
+    $this->assertEqual($this->getImageCount($style), 0, t('Image style %style was flushed after submitting the flush form.', array('%style' => $style['name'])));
+
+    /* style deletion form. */
+
+    // Delete the style.
+    $this->drupalPost($style_path . '/delete', array(), t('Delete'));
+
+    // Confirm the style directory has been removed.
+    $directory = file_directory_path() . '/styles/' . $style_name;
+    $this->assertFalse(is_dir($directory), t('Image style %style directory removed on style deletion.', array('%style' => $style['name'])));
+
+    // Confirm the style is no longer available.
+    $this->assertFalse(image_style_load($style_name), t('Image style %style successfully deleted.', array('%style' => $style['name'])));
+
+  }
+}
diff --git a/modules/user/user.module b/modules/user/user.module
index 857df97..aa37f83 100644
--- a/modules/user/user.module
+++ b/modules/user/user.module
@@ -1162,7 +1162,12 @@ function template_preprocess_user_picture(&$variables) {
     }
     if (isset($filepath)) {
       $alt = t("@user's picture", array('@user' => $account->name ? $account->name : variable_get('anonymous', t('Anonymous'))));
-      $variables['picture'] = theme('image', $filepath, $alt, $alt, '', FALSE);
+      if (module_exists('image') && $style = variable_get('user_picture_style', '')) {
+        $variables['picture'] = theme('image_style', $style, $filepath, $alt, $alt, NULL, FALSE);
+      }
+      else {
+        $variables['picture'] = theme('image', $filepath, $alt, $alt, NULL, FALSE);
+      }
       if (!empty($account->uid) && user_access('access user profiles')) {
         $attributes = array('attributes' => array('title' => t('View user profile.')), 'html' => TRUE);
         $variables['picture'] = l($variables['picture'], "user/$account->uid", $attributes);
diff --git a/profiles/default/default.profile b/profiles/default/default.profile
index 9ec0a34..740d673 100644
--- a/profiles/default/default.profile
+++ b/profiles/default/default.profile
@@ -8,7 +8,7 @@
  *   An array of modules to enable.
  */
 function default_profile_modules() {
-  return array('block', 'color', 'comment', 'help', 'menu', 'path', 'taxonomy', 'dblog', 'search', 'toolbar');
+  return array('block', 'color', 'comment', 'help', 'image', 'menu', 'path', 'taxonomy', 'dblog', 'search', 'toolbar');
 }
 
 /**
@@ -196,6 +196,27 @@ function default_profile_tasks(&$task, $url) {
   // Don't display date and author information for page nodes by default.
   variable_set('node_submitted_page', FALSE);
 
+  // Create an image style.
+  $style = array('name' => 'thumbnail_square');
+  $style = image_style_save($style);
+  $effect = array(
+    'isid' => $style['isid'],
+    'effect' => 'image_scale_and_crop',
+    'data' => array('width' => '85', 'height' => '85'),
+  );
+  image_effect_save($effect);
+
+  // Enable user picture support and set the default to a square thumbnail option.
+  variable_set('user_pictures', '1');
+  variable_set('user_picture_dimensions', '1024x1024');
+  variable_set('user_picture_file_size', '800');
+  variable_set('user_picture_style', 'thumbnail_square');
+
+  $theme_settings = theme_get_settings();
+  $theme_settings['toggle_node_user_picture'] = '1';
+  $theme_settings['toggle_comment_user_picture'] = '1';
+  variable_set('theme_settings', $theme_settings);
+
   // Create a default vocabulary named "Tags", enabled for the 'article' content type.
   $description = st('Use tags to group articles on similar topics into categories.');
   $help = st('Enter a comma-separated list of words.');
