--- image_exact.module-orig	2007-02-05 17:32:04.000000000 -0500
+++ image_exact.module	2007-02-05 17:32:07.000000000 -0500
@@ -65,29 +65,38 @@ function image_exact_settings() {
   return $form;
 }
 
-/*
-* Implementation of hook_nodeapi
-*
-* Looks for images and if the setting is set will resize thumbs
-*/
+/**
+ * Implementation of hook_image_alter()
+ */
 
-function image_exact_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) {
-  //Set thumbnail final dimensions here - use settings from image content type.
-  if ($node->type == 'image' && $op == 'validate' && variable_get('image_exact_thumbs', 1)) {
-    $sizes = _image_get_sizes();
-    foreach(variable_get('image_exact_size', array('size-0')) as $i) {
-      if($i){ // unchecked options return 0
-        $i = str_replace('size-', '', $i);
-        $source = file_create_path($node->images['_original']);
-        $destination = file_create_path($node->images[$sizes[$i]['label']]);
-        $final_w = $sizes[$i]['width'];
-        $final_h = $sizes[$i]['height'];
-        if ($final_w && $final_h) {
-          image_exact_resize($source, $destination, $final_w, $final_h);
-        }
-      }
+function image_exact_image_alter($node, $destination, $size) {
+  if ($size == '_original') {
+    return;
+  }
+  
+  if (!variable_get('image_exact_thumbs', 1)) {
+    return;
+  }
+  
+  $sizes = _image_get_sizes();
+  foreach ($sizes as $key => $params) {
+    if ($params['label'] == $size) {
+      $size_key = $key;
+      break;
     }
   }
+  
+  $exact = variable_get('image_exact_size', array('size-0'));
+  if (!isset($size_key) || empty($exact['size-'. $size_key])) {
+    return;
+  }
+  
+  $source = file_create_path($node->images['_original']);
+  $final_w = $sizes[$size_key]['width'];
+  $final_h = $sizes[$size_key]['height'];
+  if ($final_w && $final_h) {
+    image_exact_resize($source, $destination, $final_w, $final_h);
+  }
 }
 
 /*
