--- imagecache.module	Thu May  7 08:15:04 2009
+++ imagecache.module	Fri May 22 02:08:36 2009
@@ -1095,3 +1095,137 @@
   imagecache_preset_flush($preset);
   imagecache_presets(TRUE);
 }
+
+/**
+* Implementation of hook_action_info().
+*
+*/
+function imagecache_action_info() {
+  return array(
+    'imagecache_flush_action' => array(
+      'type' => 'node',
+      'description' => t('Flush all imagecache presets for this node'),
+      'configurable' => FALSE,
+      'hooks' => array(
+        'nodeapi' => array('presave', 'delete', 'insert', 'update'),
+      )
+    ),
+    'imagecache_generate_all_action' => array(
+      'type' => 'node',
+      'description' => t('Generate all imagecache presets for this node'),
+      'configurable' => FALSE,
+      'hooks' => array(
+        'nodeapi' => array('presave', 'insert', 'update'),
+      )
+    ),
+    'imagecache_generate_action' => array(
+    'type' => 'node',
+    'description' => t('Generate imagecache preset(s) for this node'),
+    'configurable' => TRUE,
+    'hooks' => array(
+      'nodeapi' => array('presave', 'insert', 'update'),
+    )
+  ),
+  );
+}
+
+/**
+* Flush all imagecache presets for the a given node.
+* @param &$node
+* 
+*/
+function imagecache_flush_action(&$node, $context) {
+  $files = filefield_get_node_files($node);
+  foreach ($files as $file) {
+    if (stristr($file['filemime'], 'image')) {
+      imagecache_image_flush($file['filepath']);
+    }
+  }
+}
+
+/**
+* Generate all imagecache presets for the given node.
+* @param &$node
+* 
+*/
+function imagecache_generate_all_action(&$node, $context) {
+  $files = filefield_get_node_files($node);
+  foreach ($files as $file) {
+    if (stristr($file['filemime'], 'image')) {
+      imagecache_generate_all_presets($file['filepath']);
+    }
+  }
+}
+
+/**
+* Generate imagecache presets for the given node and presets.
+* @param &$node
+* @param $context
+*   Contains values from the configurable form.
+* 
+*/
+function imagecache_generate_action(&$node, $context) {
+  $files = filefield_get_node_files($node);
+  foreach ($files as $file) {
+    if (stristr($file['filemime'], 'image')) {
+      foreach ($context['imagecache_presets'] as $preset) {
+        imagecache_image_generate_preset($file['filepath'], $preset);
+      }
+    }
+  }
+}
+
+/**
+* Implementation of hook_form().
+*
+*/
+function imagecache_generate_action_form($context) {
+  $options = array();
+  foreach (imagecache_presets() as $preset) {
+    $options[$preset['presetname']] = $preset['presetname'];
+  }
+  $form['presets'] = array(
+    '#type' => 'checkboxes',
+    '#options' => $options, 
+    '#description' => t('Select which imagecache presets will be effected'),
+    '#required' => TRUE,
+  );
+  return $form;
+} 
+
+/**
+* Form submit handler.
+*
+*/
+function imagecache_generate_action_submit($form, $form_state) {
+  $presets = array();
+  foreach ($form_state['values']['presets'] as $preset) {
+    if (!empty($preset)) {
+      $presets['imagecache_presets'][] = $preset;
+    }
+  }
+  return $presets;
+} 
+
+/**
+ * Generate cached version of a specific file for a specific preset.
+ * @param $path
+ *   The Drupal file path to the original image.
+  * @param $preset_name
+ *   The imagecache preset name.
+ */
+function imagecache_image_generate_preset($path, $preset_name) {
+  global $base_url;
+  file_get_contents($base_url . '/' . imagecache_create_path($preset_name, $path));
+}
+
+/**
+* Generate cached versions of a specific file for all presets.
+* @param $path
+*   The path to the orginal file.
+*/
+function imagecache_generate_all_presets($path) {
+  foreach (imagecache_presets() as $preset) {
+    file_get_contents($base_url . '/' . imagecache_create_path($preset['presetname'], $path));
+  }
+}
\ No newline at end of file
