diff --git a/core/modules/image/image.admin.inc b/core/modules/image/image.admin.inc
index 9675e98..9a06142 100644
--- a/core/modules/image/image.admin.inc
+++ b/core/modules/image/image.admin.inc
@@ -6,6 +6,718 @@
  */
 
 /**
+ * Menu callback; Listing of all current image styles.
+ */
+function image_style_list() {
+  $page = array();
+
+  $styles = entity_load_multiple('image_style');
+  $page['image_style_list'] = array(
+    '#markup' => theme('image_style_list', array('styles' => $styles)),
+    '#attached' => array(
+      'css' => array(drupal_get_path('module', 'image') . '/image.admin.css' => array()),
+    ),
+  );
+
+  return $page;
+
+}
+
+/**
+ * Form builder; Edit an image style name and effects 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()
+ */
+function image_style_form($form, &$form_state, $style) {
+  $title = t('Edit style %name', array('%name' => $style->label()));
+  drupal_set_title($title, PASS_THROUGH);
+
+  $form_state['image_style'] = $style;
+  $form['#tree'] = TRUE;
+  $form['#attached']['css'][drupal_get_path('module', 'image') . '/image.admin.css'] = array();
+
+  // Show the thumbnail preview.
+  $form['preview'] = array(
+    '#type' => 'item',
+    '#title' => t('Preview'),
+    '#markup' => theme('image_style_preview', array('style' => $style)),
+  );
+
+  $form['label'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Administrative label'),
+    '#default_value' => $style->label(),
+    '#required' => TRUE,
+  );
+  $form['name'] = array(
+    '#type' => 'machine_name',
+    '#default_value' => $style->id(),
+    '#machine_name' => array(
+      'exists' => 'image_style_load',
+    ),
+    '#required' => TRUE,
+  );
+
+  // Build the list of existing image effects for this image style.
+  $form['effects'] = array(
+    '#theme' => 'image_style_effects',
+  );
+  if (!empty($style->effects)) {
+    foreach ($style->effects as $key => $effect) {
+      $form['effects'][$key]['#weight'] = isset($form_state['input']['effects']) ? $form_state['input']['effects'][$key]['weight'] : NULL;
+      $form['effects'][$key]['label'] = array(
+        '#markup' => check_plain($effect['label']),
+      );
+      $form['effects'][$key]['summary'] = array(
+        '#markup' => isset($effect['summary theme']) ? theme($effect['summary theme'], array('data' => $effect['data'])) : '',
+      );
+      $form['effects'][$key]['weight'] = array(
+        '#type' => 'weight',
+        '#title' => t('Weight for @title', array('@title' => $effect['label'])),
+        '#title_display' => 'invisible',
+        '#default_value' => $effect['weight'],
+      );
+
+      $links = array();
+      if (isset($effect['form callback'])) {
+        $links['edit'] = array(
+          'title' => t('edit'),
+          'href' => 'admin/config/media/image-styles/manage/' . $style->id() . '/effects/' . $key,
+        );
+      }
+      $links['delete'] = array(
+        'title' => t('delete'),
+        'href' => 'admin/config/media/image-styles/manage/' . $style->id() . '/effects/' . $key . '/delete',
+      );
+      $form['effects'][$key]['operations'] = array(
+        '#type' => 'operations',
+        '#links' => $links,
+      );
+      $form['effects'][$key]['configure'] = array(
+        '#type' => 'link',
+        '#title' => t('edit'),
+        '#href' => 'admin/config/media/image-styles/manage/' . $style->id() . '/effects/' . $key,
+        '#access' => isset($effect['form callback']),
+      );
+      $form['effects'][$key]['remove'] = array(
+        '#type' => 'link',
+        '#title' => t('delete'),
+        '#href' => 'admin/config/media/image-styles/manage/' . $style->id() . '/effects/' . $key . '/delete',
+      );
+    }
+  }
+
+  // Build the new image effect addition form and add it to the effect list.
+  $new_effect_options = array();
+  foreach (image_effect_definitions() as $effect => $definition) {
+    $new_effect_options[$effect] = $definition['label'];
+  }
+  $form['effects']['new'] = array(
+    '#tree' => FALSE,
+    '#weight' => isset($form_state['input']['weight']) ? $form_state['input']['weight'] : NULL,
+  );
+  $form['effects']['new']['new'] = array(
+    '#type' => 'select',
+    '#title' => t('Effect'),
+    '#title_display' => 'invisible',
+    '#options' => $new_effect_options,
+    '#empty_option' => t('Select a new effect'),
+  );
+  $form['effects']['new']['weight'] = array(
+    '#type' => 'weight',
+    '#title' => t('Weight for new effect'),
+    '#title_display' => 'invisible',
+    '#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'),
+  );
+
+  // Show the Override or Submit button for this style.
+  $form['actions'] = array('#type' => 'actions');
+  $form['actions']['submit'] = array(
+    '#type' => 'submit',
+    '#value' => t('Update style'),
+  );
+
+  return $form;
+}
+
+/**
+ * Validate handler for adding a new image effect to an image 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.'));
+  }
+}
+
+/**
+ * Submit handler for adding a new image effect to an image 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 callback'])) {
+    $path = 'admin/config/media/image-styles/manage/' . $style->id() . '/add/' . $form_state['values']['new'];
+    $form_state['redirect'] = array($path, array('query' => array('weight' => $form_state['values']['weight'])));
+  }
+  // If there's no form, immediately add the image effect.
+  else {
+    $effect = array(
+      'name' => $effect['name'],
+      'data' => array(),
+      'weight' => $form_state['values']['weight'],
+    );
+    image_effect_save($style, $effect);
+    drupal_set_message(t('The image effect was successfully applied.'));
+  }
+}
+
+/**
+ * Submit handler for saving an image style.
+ */
+function image_style_form_submit($form, &$form_state) {
+  $style = $form_state['image_style'];
+
+  // Update image effect weights.
+  if (!empty($form_state['values']['effects'])) {
+    foreach ($form_state['values']['effects'] as $ieid => $effect_data) {
+      if (isset($style->effects[$ieid])) {
+        $effect = array(
+          'name' => $style->effects[$ieid]['name'],
+          'data' => $style->effects[$ieid]['data'],
+          'weight' => $effect_data['weight'],
+          'ieid' => $ieid,
+        );
+        $style->effects[$ieid] = $effect;
+      }
+    }
+  }
+
+  $style->set('name', $form_state['values']['name']);
+  $style->set('label', $form_state['values']['label']);
+  $status = $style->save();
+
+  if ($status == SAVED_UPDATED) {
+    drupal_set_message(t('Changes to the style have been saved.'));
+  }
+  $form_state['redirect'] = 'admin/config/media/image-styles/manage/' . $style->id();
+}
+
+/**
+ * Form builder; Form for adding a new image style.
+ *
+ * @ingroup forms
+ * @see image_style_add_form_submit()
+ */
+function image_style_add_form($form, &$form_state) {
+  $form['label'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Administrative label'),
+    '#default_value' => '',
+    '#required' => TRUE,
+  );
+  $form['name'] = array(
+    '#type' => 'machine_name',
+    '#machine_name' => array(
+      'exists' => 'image_style_load',
+    ),
+    '#default_value' => '',
+    '#required' => TRUE,
+  );
+
+  $form['submit'] = array(
+    '#type' => 'submit',
+    '#value' => t('Create new style'),
+  );
+
+  return $form;
+}
+
+/**
+ * Submit handler for adding a new image style.
+ */
+function image_style_add_form_submit($form, &$form_state) {
+  $style = entity_create('image_style', array(
+    'name' => $form_state['values']['name'],
+    'label' => $form_state['values']['label'],
+  ));
+  $style->save();
+  drupal_set_message(t('Style %name was created.', array('%name' => $style->label())));
+  $form_state['redirect'] = 'admin/config/media/image-styles/manage/' . $style->id();
+}
+
+/**
+ * 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, &$form_state, $style) {
+  $form_state['image_style'] = $style;
+
+  $replacement_styles = array_diff_key(image_style_options(), array($style->id() => ''));
+  $form['replacement'] = array(
+    '#title' => t('Replacement style'),
+    '#type' => 'select',
+    '#options' => $replacement_styles,
+    '#empty_option' => t('No replacement, just delete'),
+  );
+
+  return confirm_form(
+    $form,
+    t('Optionally select a style before deleting %style', array('%style' => $style->label())),
+    'admin/config/media/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'];
+  $style->set('replacementID', $form_state['values']['replacement']);
+  $style->delete();
+  drupal_set_message(t('Style %name was deleted.', array('%name' => $style->label())));
+  $form_state['redirect'] = 'admin/config/media/image-styles';
+}
+
+/**
+ * Form builder; Form for adding and editing image effects.
+ *
+ * This form is used universally for editing all image effects. Each effect adds
+ * its own custom section to the form by calling the 'form callback' specified
+ * in hook_image_effect_info().
+ *
+ * @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 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, &$form_state, $style, $effect) {
+  // If there's no configuration for this image effect, return to
+  // the image style page.
+  if (!isset($effect['form callback'])) {
+    drupal_goto('admin/config/media/image-styles/manage/' . $style->id());
+  }
+  $form_state['image_style'] = $style;
+  $form_state['image_effect'] = $effect;
+
+  if (!empty($effect['ieid'])) {
+    $title = t('Edit %label effect', array('%label' => $effect['label']));
+  }
+  else{
+    $title = t('Add %label effect', array('%label' => $effect['label']));
+  }
+  drupal_set_title($title, PASS_THROUGH);
+
+  $form['#attached']['css'][drupal_get_path('module', 'image') . '/image.admin.css'] = array();
+
+  $form['ieid'] = array(
+    '#type' => 'value',
+    '#value' => !empty($effect['ieid']) ? $effect['ieid'] : NULL,
+  );
+  $form['name'] = array(
+    '#type' => 'value',
+    '#value' => $effect['name'],
+  );
+
+  $form['data'] = call_user_func($effect['form callback'], $effect['data']);
+  $form['data']['#tree'] = TRUE;
+
+  // Check the URL for a weight, then the image 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['actions'] = array('#type' => 'actions');
+  $form['actions']['submit'] = array(
+    '#type' => 'submit',
+    '#value' => !empty($effect['ieid']) ? t('Update effect') : t('Add effect'),
+  );
+  $form['actions']['cancel'] = array(
+    '#type' => 'link',
+    '#title' => t('Cancel'),
+    '#href' => 'admin/config/media/image-styles/manage/' . $style->id(),
+  );
+
+  return $form;
+}
+
+/**
+ * Submit handler for updating an image effect.
+ */
+function image_effect_form_submit($form, &$form_state) {
+  form_state_values_clean($form_state);
+
+  $effect = $form_state['values'];
+  $style = $form_state['image_style'];
+  image_effect_save($style, $effect);
+
+  drupal_set_message(t('The image effect was successfully applied.'));
+  $form_state['redirect'] = 'admin/config/media/image-styles/manage/' . $style->id();
+}
+
+/**
+ * Form builder; Form for deleting an image effect.
+ *
+ * @param $style
+ *   Name of the image style from which the image effect will be removed.
+ * @param $effect
+ *   Name of the image effect to remove.
+ * @ingroup forms
+ * @see image_effect_delete_form_submit()
+ */
+function image_effect_delete_form($form, &$form_state, $style, $effect) {
+  $form_state['image_style'] = $style;
+  $form_state['image_effect'] = $effect;
+
+  $question = t('Are you sure you want to delete the @effect effect from the %style style?', array('%style' => $style->label(), '@effect' => $effect['label']));
+  return confirm_form($form, $question, 'admin/config/media/image-styles/manage/' . $style->id(), '', 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($style, $effect);
+  drupal_set_message(t('The image effect %name has been deleted.', array('%name' => $effect['label'])));
+  $form_state['redirect'] = 'admin/config/media/image-styles/manage/' . $style->id();
+}
+
+/**
+ * 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('/^#[0-9A-F]{3}([0-9A-F]{3})?$/', $element['#value'])) {
+      form_error($element, t('!name must be a hexadecimal color value.', array('!name' => $element['#title'])));
+    }
+  }
+}
+
+/**
+ * Element validate handler to ensure that either a height or a width is
+ * specified.
+ */
+function image_effect_scale_validate($element, &$form_state) {
+  if (empty($element['width']['#value']) && empty($element['height']['#value'])) {
+    form_error($element, t('Width and height can not both be blank.'));
+  }
+}
+
+/**
+ * Form element validation handler for a specified percent value.
+ */
+function image_effect_percent_validate($element, &$form_state) {
+  if ($element['#value'] !== '') {
+    if (!is_numeric($element['#value']) || $element['#value'] < 1 || $element['#value'] > 100) {
+      form_error($element, t('!name must be a number between 1 and 100.', array('!name' => $element['#title'])));
+    }
+  }
+}
+
+/**
+ * Form element validation handler to ensure the filter options are selected correctly.
+ */
+function image_effect_png_filter_validate($element, &$form_state) {
+  if (isset($element['#value'])) {
+    $count = count($element['#value']);
+    foreach ($element['#value'] as $value) {
+      // 'None' or 'All' can only be selected on its own, never with others
+      if (($value == 8 || $value ==248) && $count > 1) {
+        form_error($element, t("The options @none or @all can only be applied on its own", array('@none' => 'None', '@all' => 'All')));
+      }
+    }
+  }
+}
+
+/**
+ * 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. Therefore 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' => 'number',
+    '#title' => t('Width'),
+    '#default_value' => isset($data['width']) ? $data['width'] : '',
+    '#field_suffix' => ' ' . t('pixels'),
+    '#required' => TRUE,
+    '#min' => 1,
+  );
+  $form['height'] = array(
+    '#type' => 'number',
+    '#title' => t('Height'),
+    '#default_value' => isset($data['height']) ? $data['height'] : '',
+    '#field_suffix' => ' ' . t('pixels'),
+    '#required' => TRUE,
+    '#min' => 1,
+  );
+  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. Therefore 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['#element_validate'] = array('image_effect_scale_validate');
+  $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. Therefore 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. Therefore 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' => 'number',
+    '#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,
+  );
+  $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;
+}
+
+/**
+ * Form structure for the image quality effect form.
+ *
+ * Note that this is not a complete form, it only contains the portion of the
+ * form for configuring the quality options. Therefore it does not not need to
+ * include metadata about the effect, nor a submit button.
+ *
+ * @param $data
+ *   The current configuration for this quality effect.
+ */
+function image_quality_form($data) {
+  // Obtain the option values from the serialized constant
+  $image_quality_options = _image_quality_png_settings();
+
+  $form['quality'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Quality'),
+    '#default_value' => isset($data['quality']) ? $data['quality'] : 75,
+    '#field_suffix' => t('%'),
+    '#required' => TRUE,
+    '#element_validate' => array('image_effect_percent_validate'),
+    '#size' => 10,
+    '#maxlength' => 3,
+    '#description' => t('Define the image quality for JPEG manipulations. Ranges from 1 to 100. Higher values mean better image quality but bigger files.'),
+  );
+  $form['png'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('PNG'),
+    '#description' => t('This setting will only apply for images in PNG format.'),
+    '#collapsible' => FALSE
+  );
+
+  $form['png']['filter'] = array(
+    '#type' => 'select',
+    '#title' => t('Filter'),
+    '#default_value' => isset($data['png']['filter']) ? $data['png']['filter'] : 8,
+    '#required' => TRUE,
+    '#options' => $image_quality_options['filter'],
+    '#multiple' => TRUE,
+    '#element_validate' => array('image_effect_png_filter_validate'),
+    '#description' => t("Select the filter(s) to be applied. More than one filter can be selected, but 'None' or 'All' can only be selected on its own."),
+    '#size' => 6
+  );
+
+  $form['png']['compression'] = array(
+    '#type' => 'select',
+    '#title' => t('Compression'),
+    '#default_value' => isset($data['png']['compression']) ? $data['png']['compression'] : 4,
+    '#required' => TRUE,
+    '#options' => $image_quality_options['compression'],
+    '#multiple' => FALSE,
+    '#description' => t('Define the image quality for PNG manipulations. Ranges from 0 - 9. Higher value means smaller file size but may incur slow processing.'),
+  );
+  return $form;
+}
+
+/**
+ * An internal function that returns configuration options for PNG filter and
+ * compression rate.
+ */
+function _image_quality_png_settings() {
+  return array(
+    'filter' => array(
+      8   => t('None'),
+      16  => t('Sub'),
+      32  => t('Up'),
+      64  => t('Average'),
+      128 => t('Perth'),
+      248 => t('All')
+    ),
+    'compression' => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)
+  );
+}
+
+/**
+ * Returns HTML for the page containing the list of image styles.
+ *
+ * @param $variables
+ *   An associative array containing:
+ *   - styles: An array of all the image styles returned by image_get_styles().
+ *
+ * @see image_get_styles()
+ * @ingroup themeable
+ */
+function theme_image_style_list($variables) {
+  $styles = $variables['styles'];
+
+  $header = array(t('Style name'), t('Operations'));
+  $rows = array();
+
+  foreach ($styles as $style) {
+    $row = array();
+    $row[] = l($style->label(), 'admin/config/media/image-styles/manage/' . $style->id());
+    $links = array();
+    $links['edit'] = array(
+      'title' => t('edit'),
+      'href' => 'admin/config/media/image-styles/manage/' . $style->id(),
+      'class' => array('image-style-link'),
+    );
+    $links['delete'] = array(
+      'title' => t('delete'),
+      'href' => 'admin/config/media/image-styles/manage/' . $style->id() . '/delete',
+      'class' => array('image-style-link'),
+    );
+    $row[] = array(
+      'data' => array(
+        '#type' => 'operations',
+        '#links' => $links,
+      ),
+    );
+    $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/config/media/image-styles/add'))),
+    ));
+  }
+
+  return theme('table', array('header' => $header, 'rows' => $rows));
+}
+
+/**
  * Returns HTML for a listing of the effects within a specific image style.
  *
  * @param $variables
@@ -267,3 +979,39 @@ function theme_image_rotate_summary($variables) {
   $data = $variables['data'];
   return ($data['random']) ? t('random between -@degrees&deg and @degrees&deg', array('@degrees' => str_replace('-', '', $data['degrees']))) : t('@degrees&deg', array('@degrees' => $data['degrees']));
 }
+
+/**
+ * Returns HTML for a summary of an image quality effect.
+ *
+ * @param $variables
+ *   An associative array containing:
+ *   - data: The current configuration for this quality effect.
+ *
+ * @ingroup themeable
+ */
+function theme_image_quality_summary($variables) {
+  $data = $variables['data'];
+
+  // JPEG quality
+  $summary = t('JPEG: !quality%; ', array('!quality' => $data['quality']));
+
+  // Get the key-value pairs for PNG quality, then display the labels
+  $image_quality_options = _image_quality_png_settings();
+
+  if (!empty($data['png']['compression'])) {
+    $summary .= t('PNG compression: ') . $image_quality_options['compression'][$data['png']['compression']] . '; ';
+  }
+
+  // Create a list of applied PNG filters
+  $filter_values = '';
+  foreach ($data['png']['filter'] as $filter) {
+    if (isset($image_quality_options['filter'][$filter])) {
+      $filter_values[] = $image_quality_options['filter'][$filter];
+    }
+  }
+  if (!empty($filter_values)) {
+    $summary .= format_plural(count($filter_values), 'Applied PNG filter: @filter', 'Applied PNG filters: @filter', $args = array('@filter' => implode(', ', $filter_values)));
+  }
+
+  return check_plain($summary);
+}
diff --git a/core/modules/image/image.effects.inc b/core/modules/image/image.effects.inc
new file mode 100644
index 0000000..a14bb3c
--- /dev/null
+++ b/core/modules/image/image.effects.inc
@@ -0,0 +1,347 @@
+<?php
+
+/**
+ * @file
+ * Functions needed to execute image effects provided by Image module.
+ */
+
+/**
+ * Implements hook_image_effect_info().
+ */
+function image_image_effect_info() {
+  $effects = array(
+    'image_resize' => array(
+      'label' => t('Resize'),
+      'help' => t('Resizing will make images an exact set of dimensions. This may cause images to be stretched or shrunk disproportionately.'),
+      'effect callback' => 'image_resize_effect',
+      'dimensions callback' => 'image_resize_dimensions',
+      'form callback' => 'image_resize_form',
+      'summary theme' => 'image_resize_summary',
+    ),
+    'image_scale' => array(
+      'label' => t('Scale'),
+      'help' => t('Scaling will maintain the aspect-ratio of the original image. If only a single dimension is specified, the other dimension will be calculated.'),
+      'effect callback' => 'image_scale_effect',
+      'dimensions callback' => 'image_scale_dimensions',
+      'form callback' => 'image_scale_form',
+      'summary theme' => 'image_scale_summary',
+    ),
+    'image_scale_and_crop' => array(
+      'label' => t('Scale and crop'),
+      'help' => t('Scale and crop will maintain the aspect-ratio of the original image, then crop the larger dimension. This is most useful for creating perfectly square thumbnails without stretching the image.'),
+      'effect callback' => 'image_scale_and_crop_effect',
+      'dimensions callback' => 'image_resize_dimensions',
+      'form callback' => 'image_resize_form',
+      'summary theme' => 'image_resize_summary',
+    ),
+    'image_crop' => array(
+      'label' => t('Crop'),
+      'help' => t('Cropping will remove portions of an image to make it the specified dimensions.'),
+      'effect callback' => 'image_crop_effect',
+      'dimensions callback' => 'image_resize_dimensions',
+      'form callback' => 'image_crop_form',
+      'summary theme' => 'image_crop_summary',
+    ),
+    'image_desaturate' => array(
+      'label' => t('Desaturate'),
+      'help' => t('Desaturate converts an image to grayscale.'),
+      'effect callback' => 'image_desaturate_effect',
+      'dimensions passthrough' => TRUE,
+    ),
+    'image_rotate' => array(
+      'label' => t('Rotate'),
+      'help' => t('Rotating an image may cause the dimensions of an image to increase to fit the diagonal.'),
+      'effect callback' => 'image_rotate_effect',
+      'dimensions callback' => 'image_rotate_dimensions',
+      'form callback' => 'image_rotate_form',
+      'summary theme' => 'image_rotate_summary',
+    ),
+    'image_quality' => array(
+      'label' => t('Quality'),
+      'help' => t('Decreasing the quality will make image file sizes smaller.'),
+      'effect callback' => 'image_quality_effect',
+      'dimensions passthrough' => TRUE,
+      'form callback' => 'image_quality_form',
+      'summary theme' => 'image_quality_summary',
+    ),
+  );
+
+  return $effects;
+}
+
+/**
+ * Image effect callback; Resize an image resource.
+ *
+ * @param $image
+ *   An image object returned by image_load().
+ * @param $data
+ *   An array of attributes to use when performing the resize effect with the
+ *   following items:
+ *   - "width": An integer representing the desired width in pixels.
+ *   - "height": An integer representing the desired height in pixels.
+ *
+ * @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 using the %toolkit toolkit on %path (%mimetype, %dimensions)', array('%toolkit' => $image->toolkit, '%path' => $image->source, '%mimetype' => $image->info['mime_type'], '%dimensions' => $image->info['width'] . 'x' . $image->info['height']), WATCHDOG_ERROR);
+    return FALSE;
+  }
+  return TRUE;
+}
+
+/**
+ * Image dimensions callback; Resize.
+ *
+ * @param $dimensions
+ *   Dimensions to be modified - an array with components width and height, in
+ *   pixels.
+ * @param $data
+ *   An array of attributes to use when performing the resize effect with the
+ *   following items:
+ *   - "width": An integer representing the desired width in pixels.
+ *   - "height": An integer representing the desired height in pixels.
+ */
+function image_resize_dimensions(array &$dimensions, array $data) {
+  // The new image will have the exact dimensions defined for the effect.
+  $dimensions['width'] = $data['width'];
+  $dimensions['height'] = $data['height'];
+}
+
+/**
+ * Image effect callback; Scale an image resource.
+ *
+ * @param $image
+ *   An image object returned by image_load().
+ * @param $data
+ *   An array of attributes to use when performing the scale effect with the
+ *   following items:
+ *   - "width": An integer representing the desired width in pixels.
+ *   - "height": An integer representing the desired height in pixels.
+ *   - "upscale": A boolean indicating that the image should be upscaled if the
+ *     dimensions are larger than the original image.
+ *
+ * @return
+ *   TRUE on success. FALSE on failure to scale image.
+ *
+ * @see image_scale()
+ */
+function image_scale_effect($image, $data) {
+  // Set sane default values.
+  $data += array(
+    'width' => NULL,
+    'height' => NULL,
+    'upscale' => FALSE,
+  );
+
+  if (!image_scale($image, $data['width'], $data['height'], $data['upscale'])) {
+    watchdog('image', 'Image scale failed using the %toolkit toolkit on %path (%mimetype, %dimensions)', array('%toolkit' => $image->toolkit, '%path' => $image->source, '%mimetype' => $image->info['mime_type'], '%dimensions' => $image->info['width'] . 'x' . $image->info['height']), WATCHDOG_ERROR);
+    return FALSE;
+  }
+  return TRUE;
+}
+
+/**
+ * Image dimensions callback; Scale.
+ *
+ * @param $dimensions
+ *   Dimensions to be modified - an array with components width and height, in
+ *   pixels.
+ * @param $data
+ *   An array of attributes to use when performing the scale effect with the
+ *   following items:
+ *   - "width": An integer representing the desired width in pixels.
+ *   - "height": An integer representing the desired height in pixels.
+ *   - "upscale": A boolean indicating that the image should be upscaled if the
+ *     dimensions are larger than the original image.
+ */
+function image_scale_dimensions(array &$dimensions, array $data) {
+  if ($dimensions['width'] && $dimensions['height']) {
+    image_dimensions_scale($dimensions, $data['width'], $data['height'], $data['upscale']);
+  }
+}
+
+/**
+ * Image effect callback; Crop an image resource.
+ *
+ * @param $image
+ *   An image object returned by image_load().
+ * @param $data
+ *   An array of attributes to use when performing the crop effect with the
+ *   following items:
+ *   - "width": An integer representing the desired width in pixels.
+ *   - "height": An integer representing the desired height in pixels.
+ *   - "anchor": A string describing where the crop should originate in the form
+ *     of "XOFFSET-YOFFSET". XOFFSET is either a number of pixels or
+ *     "left", "center", "right" and YOFFSET is either a number of pixels or
+ *     "top", "center", "bottom".
+ * @return
+ *   TRUE on success. FALSE on failure to crop image.
+ * @see image_crop()
+ */
+function image_crop_effect($image, $data) {
+  // Set sane default values.
+  $data += array(
+    'anchor' => 'center-center',
+  );
+
+  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 using the %toolkit toolkit on %path (%mimetype, %dimensions)', array('%toolkit' => $image->toolkit, '%path' => $image->source, '%mimetype' => $image->info['mime_type'], '%dimensions' => $image->info['width'] . 'x' . $image->info['height']), WATCHDOG_ERROR);
+    return FALSE;
+  }
+  return TRUE;
+}
+
+/**
+ * Image effect callback; Scale and crop an image resource.
+ *
+ * @param $image
+ *   An image object returned by image_load().
+ * @param $data
+ *   An array of attributes to use when performing the scale and crop effect
+ *   with the following items:
+ *   - "width": An integer representing the desired width in pixels.
+ *   - "height": An integer representing the desired height in pixels.
+ * @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', 'Image scale and crop failed using the %toolkit toolkit on %path (%mimetype, %dimensions)', array('%toolkit' => $image->toolkit, '%path' => $image->source, '%mimetype' => $image->info['mime_type'], '%dimensions' => $image->info['width'] . 'x' . $image->info['height']), WATCHDOG_ERROR);
+    return FALSE;
+  }
+  return TRUE;
+}
+
+/**
+ * Image effect callback; Desaturate (grayscale) an image resource.
+ *
+ * @param $image
+ *   An image object returned by image_load().
+ * @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 using the %toolkit toolkit on %path (%mimetype, %dimensions)', array('%toolkit' => $image->toolkit, '%path' => $image->source, '%mimetype' => $image->info['mime_type'], '%dimensions' => $image->info['width'] . 'x' . $image->info['height']), WATCHDOG_ERROR);
+    return FALSE;
+  }
+  return TRUE;
+}
+
+/**
+ * Image effect callback; Rotate an image resource.
+ *
+ * @param $image
+ *   An image object returned by image_load().
+ * @param $data
+ *   An array of attributes to use when performing the rotate effect containing
+ *   the following items:
+ *   - "degrees": The number of (clockwise) degrees to rotate the image.
+ *   - "random": A boolean indicating that a random rotation angle should be
+ *     used for this image. The angle specified in "degrees" is used as a
+ *     positive and negative maximum.
+ *   - "bgcolor": 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.
+ * @return
+ *   TRUE on success. FALSE on failure to rotate image.
+ * @see image_rotate().
+ */
+function image_rotate_effect($image, $data) {
+  // Set sane default values.
+  $data += array(
+    'degrees' => 0,
+    'bgcolor' => NULL,
+    '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', 'Image rotate failed using the %toolkit toolkit on %path (%mimetype, %dimensions)', array('%toolkit' => $image->toolkit, '%path' => $image->source, '%mimetype' => $image->info['mime_type'], '%dimensions' => $image->info['width'] . 'x' . $image->info['height']), WATCHDOG_ERROR);
+    return FALSE;
+  }
+  return TRUE;
+}
+
+/**
+ * Image dimensions callback; Rotate.
+ *
+ * @param $dimensions
+ *   Dimensions to be modified - an array with components width and height, in
+ *   pixels.
+ * @param $data
+ *   An array of attributes to use when performing the rotate effect containing
+ *   the following items:
+ *   - "degrees": The number of (clockwise) degrees to rotate the image.
+ *   - "random": A boolean indicating that a random rotation angle should be
+ *     used for this image. The angle specified in "degrees" is used as a
+ *     positive and negative maximum.
+ */
+function image_rotate_dimensions(array &$dimensions, array $data) {
+  // If the rotate is not random and the angle is a multiple of 90 degrees,
+  // then the new dimensions can be determined.
+  if (!$data['random'] && ((int) ($data['degrees']) == $data['degrees']) && ($data['degrees'] % 90 == 0)) {
+    if ($data['degrees'] % 180 != 0) {
+      $temp = $dimensions['width'];
+      $dimensions['width'] = $dimensions['height'];
+      $dimensions['height'] = $temp;
+    }
+  }
+  else {
+    $dimensions['width'] = $dimensions['height'] = NULL;
+  }
+}
+
+/**
+ * Image effect callback; Change the quality for a target image.
+ *
+ * @param $image
+ *   An image object returned by image_load().
+ * @param $data
+ *   An associative array containing the effect configuration values:
+ *   - quality (JPEG): An integer representing the desired image quality in percent.
+ *   - compression (PNG): An integer representing the desired image quality in compression rate.
+ *   - filter (PNG): An array of integer values representing the desired PNG filters to be applied.
+ *
+ * @return
+ *   Always TRUE. The quality is set as a property on the $image, so the image
+ *   toolkit's save callback may apply it when the image is written to disk.
+ *
+ * @see image_save()
+ * @see image_gd_save()
+ */
+function image_quality_effect(&$image, $data) {
+  $image->quality = $data['quality'];
+  $image->filter = $data['png']['filter'];
+  $image->png_compression = $data['png']['compression'];
+  return TRUE;
+}
diff --git a/core/modules/image/image.module b/core/modules/image/image.module
index 3751b8c..96216b4 100644
--- a/core/modules/image/image.module
+++ b/core/modules/image/image.module
@@ -192,6 +192,9 @@ function image_theme() {
       'variables' => array('data' => NULL),
       'file' => 'image.admin.inc',
     ),
+    'image_quality_summary' => array(
+      'variables' => array('data' => NULL),
+    ),
 
     // Theme functions in image.field.inc.
     'image_widget' => array(
diff --git a/core/modules/system/image.gd.inc b/core/modules/system/image.gd.inc
new file mode 100644
index 0000000..40e52d8
--- /dev/null
+++ b/core/modules/system/image.gd.inc
@@ -0,0 +1,404 @@
+<?php
+
+/**
+ * @file
+ * GD2 toolkit for image manipulation within Drupal.
+ */
+
+/**
+ * @addtogroup image
+ * @{
+ */
+
+/**
+ * Image toolkit callback: Returns GD-specific image toolkit settings.
+ *
+ * This function verifies that the GD PHP extension is installed.  If it is not,
+ * a form error message is set, informing the user about the missing extension.
+ *
+ * The form elements returned by this function are integrated into the form
+ * built by system_image_toolkit_settings().
+ *
+ * @return
+ *   An array of Form API elements to be added to the form.
+ *
+ * @see hook_image_toolkits()
+ * @see system_image_toolkit_settings()
+ */
+function image_gd_settings() {
+  if (image_gd_check_settings()) {
+    $form['status'] = array(
+      '#markup' => t('The GD toolkit is installed and working properly.')
+    );
+
+    $form['image_jpeg_quality'] = array(
+      '#type' => 'number',
+      '#title' => t('JPEG quality'),
+      '#description' => t('Define the image quality for JPEG manipulations. Ranges from 0 to 100. Higher values mean better image quality but bigger files.'),
+      '#min' => 0,
+      '#max' => 100,
+      '#default_value' => variable_get('image_jpeg_quality', 75),
+      '#field_suffix' => t('%'),
+    );
+
+    return $form;
+  }
+  else {
+    form_set_error('image_toolkit', t('The GD image toolkit requires that the GD module for PHP be installed and configured properly. For more information see <a href="@url">PHP\'s image documentation</a>.', array('@url' => 'http://php.net/image')));
+    return FALSE;
+  }
+}
+
+/**
+ * Verifies GD2 settings (that the right version is actually installed).
+ *
+ * @return
+ *   A Boolean indicating whether the correct version of the GD toolkit is
+ *   available on this machine.
+ *
+ * @see image_gd_settings()
+ * @see system_image_toolkits()
+ */
+function image_gd_check_settings() {
+  if ($check = get_extension_funcs('gd')) {
+    if (in_array('imagegd2', $check)) {
+      // GD2 support is available.
+      return TRUE;
+    }
+  }
+  return FALSE;
+}
+
+/**
+ * Image toolkit callback: Scales an image to the specified size using GD.
+ *
+ * @param $image
+ *   An image object. The $image->resource, $image->info['width'], and
+ *   $image->info['height'] values will be modified by this call.
+ * @param $width
+ *   The new width of the resized image, in pixels.
+ * @param $height
+ *   The new height of the resized image, in pixels.
+ *
+ * @return
+ *   TRUE or FALSE, based on success.
+ *
+ * @see hook_image_toolkits()
+ * @see image_resize()
+ */
+function image_gd_resize(stdClass $image, $width, $height) {
+  $res = image_gd_create_tmp($image, $width, $height);
+
+  if (!imagecopyresampled($res, $image->resource, 0, 0, 0, 0, $width, $height, $image->info['width'], $image->info['height'])) {
+    return FALSE;
+  }
+
+  imagedestroy($image->resource);
+  // Update image object.
+  $image->resource = $res;
+  $image->info['width'] = $width;
+  $image->info['height'] = $height;
+  return TRUE;
+}
+
+/**
+ * Image toolkit callback: Rotates an image a specified number of degrees.
+ *
+ * @param $image
+ *   An image object. The $image->resource, $image->info['width'], and
+ *   $image->info['height'] values will be modified by this call.
+ * @param $degrees
+ *   The number of (clockwise) degrees to rotate the image.
+ * @param $background
+ *   (optional) A hexadecimal integer specifying the background color to use
+ *   for the uncovered area of the image after the rotation. E.g. 0x000000 for
+ *   black, 0xff00ff for magenta, and 0xffffff for white. For images that
+ *   support transparency, this will default to transparent. Otherwise it will
+ *   be white.
+ *
+ * @return
+ *   TRUE or FALSE, based on success.
+ *
+ * @see image_rotate()
+ */
+function image_gd_rotate(stdClass $image, $degrees, $background = NULL) {
+  // PHP installations using non-bundled GD do not have imagerotate.
+  if (!function_exists('imagerotate')) {
+    watchdog('image', 'The image %file could not be rotated because the imagerotate() function is not available in this PHP installation.', array('%file' => $image->source));
+    return FALSE;
+  }
+
+  $width = $image->info['width'];
+  $height = $image->info['height'];
+
+  // Convert the hexadecimal background value to a color index value.
+  if (isset($background)) {
+    $rgb = array();
+    for ($i = 16; $i >= 0; $i -= 8) {
+      $rgb[] = (($background >> $i) & 0xFF);
+    }
+    $background = imagecolorallocatealpha($image->resource, $rgb[0], $rgb[1], $rgb[2], 0);
+  }
+  // Set the background color as transparent if $background is NULL.
+  else {
+    // Get the current transparent color.
+    $background = imagecolortransparent($image->resource);
+
+    // If no transparent colors, use white.
+    if ($background == 0) {
+      $background = imagecolorallocatealpha($image->resource, 255, 255, 255, 0);
+    }
+  }
+
+  // Images are assigned a new color palette when rotating, removing any
+  // transparency flags. For GIF images, keep a record of the transparent color.
+  if ($image->info['extension'] == 'gif') {
+    $transparent_index = imagecolortransparent($image->resource);
+    if ($transparent_index != 0) {
+      $transparent_gif_color = imagecolorsforindex($image->resource, $transparent_index);
+    }
+  }
+
+  $image->resource = imagerotate($image->resource, 360 - $degrees, $background);
+
+  // GIFs need to reassign the transparent color after performing the rotate.
+  if (isset($transparent_gif_color)) {
+    $background = imagecolorexactalpha($image->resource, $transparent_gif_color['red'], $transparent_gif_color['green'], $transparent_gif_color['blue'], $transparent_gif_color['alpha']);
+    imagecolortransparent($image->resource, $background);
+  }
+
+  $image->info['width'] = imagesx($image->resource);
+  $image->info['height'] = imagesy($image->resource);
+  return TRUE;
+}
+
+/**
+ * Image toolkit callback: Crops an image using the GD toolkit.
+ *
+ * @param $image
+ *   An image object. The $image->resource, $image->info['width'], and
+ *   $image->info['height'] values will be modified by this call.
+ * @param $x
+ *   The starting x offset at which to start the crop, in pixels.
+ * @param $y
+ *   The starting y offset at which to start the crop, in pixels.
+ * @param $width
+ *   The width of the cropped area, in pixels.
+ * @param $height
+ *   The height of the cropped area, in pixels.
+ *
+ * @return
+ *   TRUE or FALSE, based on success.
+ *
+ * @see hook_image_toolkits()
+ * @see image_crop()
+ */
+function image_gd_crop(stdClass $image, $x, $y, $width, $height) {
+  $res = image_gd_create_tmp($image, $width, $height);
+
+  if (!imagecopyresampled($res, $image->resource, 0, 0, $x, $y, $width, $height, $width, $height)) {
+    return FALSE;
+  }
+
+  // Destroy the original image and return the modified image.
+  imagedestroy($image->resource);
+  $image->resource = $res;
+  $image->info['width'] = $width;
+  $image->info['height'] = $height;
+  return TRUE;
+}
+
+/**
+ * Image toolkit callback: Converts an image to grayscale using the GD toolkit.
+ *
+ * Note that transparent GIFs loose transparency when desaturated.
+ *
+ * @param $image
+ *   An image object. The $image->resource value will be modified by this call.
+ *
+ * @return
+ *   TRUE or FALSE, based on success.
+ *
+ * @see hook_image_toolkits()
+ * @see image_desaturate()
+ */
+function image_gd_desaturate(stdClass $image) {
+  // PHP installations using non-bundled GD do not have imagefilter.
+  if (!function_exists('imagefilter')) {
+    watchdog('image', 'The image %file could not be desaturated because the imagefilter() function is not available in this PHP installation.', array('%file' => $image->source));
+    return FALSE;
+  }
+
+  return imagefilter($image->resource, IMG_FILTER_GRAYSCALE);
+}
+
+/**
+ * Image toolkit callback: Creates a GD image resource from a file.
+ *
+ * @param $image
+ *   An image object. The $image->resource value will populated by this call.
+ *
+ * @return
+ *   TRUE or FALSE, based on success.
+ *
+ * @see hook_image_toolkits()
+ * @see image_load()
+ */
+function image_gd_load(stdClass $image) {
+  $extension = str_replace('jpg', 'jpeg', $image->info['extension']);
+  $function = 'imagecreatefrom' . $extension;
+  if (function_exists($function) && $image->resource = $function($image->source)) {
+    if (!imageistruecolor($image->resource)) {
+      // Convert indexed images to true color, so that filters work
+      // correctly and don't result in unnecessary dither.
+      $new_image = image_gd_create_tmp($image, $image->info['width'], $image->info['height']);
+      imagecopy($new_image, $image->resource, 0, 0, 0, 0, $image->info['width'], $image->info['height']);
+      imagedestroy($image->resource);
+      $image->resource = $new_image;
+    }
+    return (bool) $image->resource;
+  }
+
+  return FALSE;
+}
+
+/**
+ * Image toolkit callback: Writes an image resource to a destination file.
+ *
+ * @param $image
+ *   An image object.
+ * @param $destination
+ *   A string file URI or path where the image should be saved.
+ *
+ * @return
+ *   TRUE or FALSE, based on success.
+ *
+ * @see hook_image_toolkits()
+ * @see image_save()
+ */
+function image_gd_save(stdClass $image, $destination) {
+  $scheme = file_uri_scheme($destination);
+  // Work around lack of stream wrapper support in imagejpeg() and imagepng().
+  if (file_stream_wrapper_valid_scheme($scheme)) {
+    // If destination is not local, save image to temporary local file.
+    $local_wrappers = file_get_stream_wrappers(STREAM_WRAPPERS_LOCAL);
+    if (!isset($local_wrappers[$scheme])) {
+      $permanent_destination = $destination;
+      $destination = drupal_tempnam('temporary://', 'gd_');
+    }
+    // Convert stream wrapper URI to normal path.
+    $destination = drupal_realpath($destination);
+  }
+
+  $extension = str_replace('jpg', 'jpeg', $image->info['extension']);
+  $function = 'image' . $extension;
+  if (!function_exists($function)) {
+    return FALSE;
+  }
+  if ($extension == 'jpeg') {
+    $success = $function($image->resource, $destination, variable_get('image_jpeg_quality', 75));
+  }
+  else {
+    // Always save PNG images with full transparency.
+    if ($extension == 'png') {
+      imagealphablending($image->resource, FALSE);
+      imagesavealpha($image->resource, TRUE);
+    }
+    // Set the png filter value. Convert the png filter settings into a bitmask.
+    // Defaults to 8 (NONE)
+    $png_filter = isset($image->filter) ? array_sum($image->filter) : 8;
+
+    // Set the compression rate. Defaults to 4
+    $png_compression = empty($image->png_compression) ? 4 : $image->png_compression;
+    $success = $function($image->resource, $destination, $png_compression, $png_filter);
+  }
+  // Move temporary local file to remote destination.
+  if (isset($permanent_destination) && $success) {
+    return (bool) file_unmanaged_move($destination, $permanent_destination, FILE_EXISTS_REPLACE);
+  }
+  return $success;
+}
+
+/**
+ * Creates a truecolor image preserving transparency from a provided image.
+ *
+ * @param $image
+ *   An image object.
+ * @param $width
+ *   The new width of the new image, in pixels.
+ * @param $height
+ *   The new height of the new image, in pixels.
+ *
+ * @return
+ *   A GD image handle.
+ */
+function image_gd_create_tmp(stdClass $image, $width, $height) {
+  $res = imagecreatetruecolor($width, $height);
+
+  if ($image->info['extension'] == 'gif') {
+    // Grab transparent color index from image resource.
+    $transparent = imagecolortransparent($image->resource);
+
+    if ($transparent >= 0) {
+      // The original must have a transparent color, allocate to the new image.
+      $transparent_color = imagecolorsforindex($image->resource, $transparent);
+      $transparent = imagecolorallocate($res, $transparent_color['red'], $transparent_color['green'], $transparent_color['blue']);
+
+      // Flood with our new transparent color.
+      imagefill($res, 0, 0, $transparent);
+      imagecolortransparent($res, $transparent);
+    }
+  }
+  elseif ($image->info['extension'] == 'png') {
+    imagealphablending($res, FALSE);
+    $transparency = imagecolorallocatealpha($res, 0, 0, 0, 127);
+    imagefill($res, 0, 0, $transparency);
+    imagealphablending($res, TRUE);
+    imagesavealpha($res, TRUE);
+  }
+  else {
+    imagefill($res, 0, 0, imagecolorallocate($res, 255, 255, 255));
+  }
+
+  return $res;
+}
+
+/**
+ * Get details about an image.
+ * Image toolkit callback: Retrieves details about an image.
+ *
+ * @param $image
+ *   An image object.
+ *
+ * @return
+ *   FALSE, if the file could not be found or is not an image. Otherwise, a
+ *   keyed array containing information about the image:
+ *   - "width": Width, in pixels.
+ *   - "height": Height, in pixels.
+ *   - "extension": Commonly used file extension for the image.
+ *   - "mime_type": MIME type ('image/jpeg', 'image/gif', 'image/png').
+ *
+ * @see hook_image_toolkits()
+ * @see image_get_info()
+ */
+function image_gd_get_info(stdClass $image) {
+  $details = FALSE;
+  $data = getimagesize($image->source);
+
+  if (isset($data) && is_array($data)) {
+    $extensions = array('1' => 'gif', '2' => 'jpg', '3' => 'png');
+    $extension = isset($extensions[$data[2]]) ?  $extensions[$data[2]] : '';
+    $details = array(
+      'width'     => $data[0],
+      'height'    => $data[1],
+      'extension' => $extension,
+      'mime_type' => $data['mime'],
+    );
+  }
+
+  return $details;
+}
+
+/**
+ * @} End of "addtogroup image".
+ */
diff --git a/core/modules/system/tests/modules/image_test/image_test.module b/core/modules/system/tests/modules/image_test/image_test.module
index 92f1ca2..610c2c6 100644
--- a/core/modules/system/tests/modules/image_test/image_test.module
+++ b/core/modules/system/tests/modules/image_test/image_test.module
@@ -4,3 +4,136 @@
  * @file
  * Helper module for the image tests.
  */
+
+/**
+ * Implements hook_image_toolkits().
+ */
+function image_test_image_toolkits() {
+  return array(
+    'test' => array(
+      'title' => t('A dummy toolkit that works'),
+      'available' => TRUE,
+    ),
+    'broken' => array(
+      'title' => t('A dummy toolkit that is "broken"'),
+      'available' => FALSE,
+    ),
+  );
+}
+
+/**
+ * Reset/initialize the history of calls to the toolkit functions.
+ *
+ * @see image_test_get_all_calls()
+ */
+function image_test_reset() {
+  // Keep track of calls to these operations
+  $results = array(
+    'load' => array(),
+    'save' => array(),
+    'settings' => array(),
+    'resize' => array(),
+    'rotate' => array(),
+    'crop' => array(),
+    'desaturate' => array(),
+    'quality' => array(),
+  );
+  state()->set('image_test.results', $results);
+}
+
+/**
+ * Get an array with the all the calls to the toolkits since image_test_reset()
+ * was called.
+ *
+ * @return
+ *   An array keyed by operation name ('load', 'save', 'settings', 'resize',
+ *   'rotate', 'crop', 'desaturate') with values being arrays of parameters
+ *   passed to each call.
+ */
+function image_test_get_all_calls() {
+  return state()->get('image_test.results') ?: array();
+}
+
+/**
+ * Store the values passed to a toolkit call.
+ *
+ * @param $op
+ *   One of the image toolkit operations: 'get_info', 'load', 'save',
+ *   'settings', 'resize', 'rotate', 'crop', 'desaturate'.
+ * @param $args
+ *   Values passed to hook.
+ *
+ * @see image_test_get_all_calls()
+ * @see image_test_reset()
+ */
+function _image_test_log_call($op, $args) {
+  $results = state()->get('image_test.results') ?: array();
+  $results[$op][] = $args;
+  state()->set('image_test.results', $results);
+}
+
+/**
+ * Image tookit's settings operation.
+ */
+function image_test_settings() {
+  _image_test_log_call('settings', array());
+  return array();
+}
+
+/**
+ * Image toolkit's get_info operation.
+ */
+function image_test_get_info(stdClass $image) {
+  _image_test_log_call('get_info', array($image));
+  return array();
+}
+
+/**
+ * Image tookit's load operation.
+ */
+function image_test_load(stdClass $image) {
+  _image_test_log_call('load', array($image));
+  return $image;
+}
+
+/**
+ * Image tookit's save operation.
+ */
+function image_test_save(stdClass $image, $destination) {
+  _image_test_log_call('save', array($image, $destination));
+  // Return false so that image_save() doesn't try to chmod the destination
+  // file that we didn't bother to create.
+  return FALSE;
+}
+
+/**
+ * Image tookit's crop operation.
+ */
+function image_test_crop(stdClass $image, $x, $y, $width, $height) {
+  _image_test_log_call('crop', array($image, $x, $y, $width, $height));
+  return TRUE;
+}
+
+/**
+ * Image tookit's resize operation.
+ */
+function image_test_resize(stdClass $image, $width, $height) {
+  _image_test_log_call('resize', array($image, $width, $height));
+  return TRUE;
+}
+
+/**
+ * Image tookit's rotate operation.
+ */
+function image_test_rotate(stdClass $image, $degrees, $background = NULL) {
+  _image_test_log_call('rotate', array($image, $degrees, $background));
+  return TRUE;
+}
+
+/**
+ * Image tookit's desaturate operation.
+ */
+function image_test_desaturate(stdClass $image) {
+  _image_test_log_call('desaturate', array($image));
+  return TRUE;
+}
