diff --git a/modules/image/image.module b/modules/image/image.module
index fe3cfcd..4592149 100644
--- a/modules/image/image.module
+++ b/modules/image/image.module
@@ -797,6 +797,13 @@ function image_style_deliver($style, $scheme) {
     }
   }
 
+  // Don't try to generate file if source is missing.
+  if (!file_exists($image_uri)) {
+    drupal_add_http_header('Status', '404 Not Found');
+    print t('Error generating image, missing source file.');
+    drupal_exit();
+  }
+
   // Don't start generating the image if the derivative already exists or if
   // generation is in progress in another thread.
   $lock_name = 'image_style_deliver:' . $style['name'] . ':' . drupal_hash_base64($image_uri);
