--- sites/all/modules/imageapi/imageapi_gd.module-orig  2009-07-16 02:23:16.000000000 -0400
+++ sites/all/modules/imageapi/imageapi_gd.module       2009-07-16 02:28:10.000000000 -0400
@@ -240,7 +240,8 @@
  *   A GD image handle.
  */
 function imageapi_gd_create_tmp($image, $width, $height) {
-  $res = imagecreatetruecolor($width, $height);
+  $truecolor = (($colors = imagecolorstotal($image->resource)) == 0 || $colors > 255);
+  $res = $truecolor? imagecreatetruecolor($width, $height): imagecreate($width, $height);

   if ($image->info['extension'] == 'gif') {
     // Grab transparent color index from image resource.
