--- imagecache.module.orig	2008-03-08 12:07:03.000000000 +0100
+++ imagecache.module	2008-03-08 12:21:24.000000000 +0100
@@ -320,7 +320,7 @@
 
   // check if deriv exists... (file was created between apaches request handler and reaching this code)
   // otherwise try to create the derivative. 
-  if (!file_exists($dst) && !imagecache_build_derivative($preset['actions'], $src, $dst)) {
+  if (!file_exists($dst) && !imagecache_build_derivative($preset, $src, $dst)) {
     // Generate an error if image could not generate.
     watchdog('imagecache', t('Failed generating an image from %image using imagecache preset %preset.', array('%image' => $path, '%preset' => $preset)), WATCHDOG_ERROR);
     header("HTTP/1.0 500 Internal Server Error");
@@ -333,7 +333,7 @@
   $actions = imagecache_action_definitions();
  
   if ($definition = imagecache_action_definition($action['action'])) {
-    return call_user_func($action['action'] .'_image', $image, $action['data']);
+    return call_user_func($action['action'] .'_image', $image, $action['data'], $action['presetid']);
   }
   // skip undefined actions.. module probably got uninstalled or disabled.
   watchdog('imagecache', t('non-existant action %action', array('%action' => $action['action'])), WATCHDOG_NOTICE);
@@ -436,7 +436,7 @@
  * @param $tmp      Path of the temporary file used for manipulating the image.
  * @return TRUE - derivative generated, FALSE - no derivative generated, NULL - derivative being generated
  */
-function imagecache_build_derivative($actions, $src, $dst) {
+function imagecache_build_derivative($preset, $src, $dst) {
   // get the folder for the final location of this preset...
   $dir = dirname($dst);
 
@@ -450,8 +450,7 @@
     return FALSE; 
   }
 
-
-  foreach ($actions as $action) {
+  foreach ($preset['actions'] as $action) {
     if (!empty($action['data'])) {
       // QuickSketch, why do these run first/twice? - dopry.
       if (isset($action['data']['width'])) {
@@ -464,6 +463,8 @@
         $action['data'][$key] = _imagecache_filter($key, $value, $image->info['width'], $image->info['height'], $width, $height);
       }
     }
+    // add preset id
+    $action['presetid'] = $preset['presetid'];
     if (!_imagecache_apply_action($action, $image)) {
       watchdog( 'imagecache', t('action(id:%id): %action failed for %src', array('%id' => $action['actionid'], '%action' => $action['action'], '%src' => $src)), WATCHDOG_ERROR);
       return FALSE;
