--- imagecache.module.original	2009-08-19 22:59:07.000000000 +0200
+++ imagecache.module	2009-11-24 11:54:51.771875700 +0100
@@ -393,6 +393,7 @@ function _imagecache_cache($presetname, 
   // umm yeah deliver it early if it is there. especially useful
   // to prevent lock files from being created when delivering private files.
   $dst = imagecache_create_path($preset['presetname'], $path);
+  if ($gs = in_array(strtolower(substr($dst, strrpos($dst, '.'))), array('.pdf'))) $dst .= '.jpg';
   if (is_file($dst)) {
     imagecache_transfer($dst);
   }
@@ -409,7 +410,7 @@ function _imagecache_cache($presetname, 
 
   // Bail if the requested file isn't an image you can't request .php files
   // etc...
-  if (!getimagesize($src)) {
+  if (!getimagesize($src) && !$gs) {
     watchdog('imagecache', '403: File is not an image %image ', array('%image' => $src), WATCHDOG_ERROR);
     header('HTTP/1.0 403 Forbidden');
     exit;
@@ -562,7 +563,8 @@ function imagecache_build_derivative($ac
     return file_copy($src, $dst, FILE_EXISTS_REPLACE);
   }
 
-  if (!$image = imageapi_image_open($src)) {
+  $gs = in_array(strtolower(substr($src, strrpos($src, '.'))), array('.pdf'));
+  if (!$image = imageapi_image_open($src, ($gs) ? 'imageapi_imagemagick' : FALSE)) {
     return FALSE;
   }
 
