? .DS_Store
? image_captcha_png.patch
? fonts/.DS_Store
? fonts/.gitignore
? fonts/1456Gutenberg.TTF
? fonts/Army.ttf
? fonts/BABYK___.TTF
? fonts/actionj.ttf
? fonts/dropacha.ttf
? fonts/skinck.ttf
? fonts/subeve.ttf
? fonts/tiza.ttf
? fonts/Tesox/.DS_Store
Index: image_captcha.admin.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/captcha/image_captcha/image_captcha.admin.inc,v
retrieving revision 1.25
diff -u -b -u -p -w -r1.25 image_captcha.admin.inc
--- image_captcha.admin.inc	17 Sep 2009 23:16:32 -0000	1.25
+++ image_captcha.admin.inc	19 Sep 2009 22:38:20 -0000
@@ -138,16 +138,16 @@ function image_captcha_settings_form() {
     ),
   );
 
-    // color settings
+    // Color and file format settings.
   $form['image_captcha_color_settings'] = array(
     '#type' => 'fieldset',
-    '#title' => t('Color settings'),
-    '#description' => t('Configuration of the background and text colors in the image CAPTCHA.'),
+    '#title' => t('Color and image settings'),
+    '#description' => t('Configuration of the background, text colors and file format of the image CAPTCHA.'),
   );
   $form['image_captcha_color_settings']['image_captcha_background_color'] = array(
     '#type' => 'textfield',
     '#title' => t('Background color'),
-    '#description' => t('Enter the hexadecimal code for the background color (e.g. #FFF or #FFCE90).'),
+    '#description' => t('Enter the hexadecimal code for the background color (e.g. #FFF or #FFCE90). When using the PNG file format with transparent background, it is recommended to set this close to the underlying background color.'),
     '#default_value' => variable_get('image_captcha_background_color', '#ffffff'),
     '#maxlength' => 7,
     '#size' => 8,
@@ -173,7 +173,17 @@ function image_captcha_settings_form() {
     '#default_value' => (int) variable_get('image_captcha_foreground_color_randomness', 100),
     '#description' => t('The different characters will have randomized colors in the specified range around the text color.'),
   );
-
+  $form['image_captcha_color_settings']['image_captcha_file_format'] = array(
+    '#type' => 'select',
+    '#title' => t('File format'),
+    '#description' => t('Select the file format for the image. JPEG usually results in smaller files, PNG allows tranparency.'),
+    '#default_value' => variable_get('image_captcha_file_format', IMAGE_CAPTCHA_FILE_FORMAT_JPG),
+    '#options' => array(
+      IMAGE_CAPTCHA_FILE_FORMAT_JPG => t('JPEG'),
+      IMAGE_CAPTCHA_FILE_FORMAT_PNG => t('PNG'),
+      IMAGE_CAPTCHA_FILE_FORMAT_TRANSPARENT_PNG => t('PNG with transparent background'),
+    ),
+  );
 
   // distortion and noise settings
   $form['image_captcha_distortion_and_noise'] = array(
Index: image_captcha.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/captcha/image_captcha/image_captcha.module,v
retrieving revision 1.29
diff -u -b -u -p -w -r1.29 image_captcha.module
--- image_captcha.module	17 Sep 2009 22:58:43 -0000	1.29
+++ image_captcha.module	19 Sep 2009 22:38:20 -0000
@@ -18,6 +18,10 @@ define('IMAGE_CAPTCHA_ERROR_NO_GDLIB_WIT
 define('IMAGE_CAPTCHA_ERROR_NO_TTF_SUPPORT', 2);
 define('IMAGE_CAPTCHA_ERROR_TTF_FILE_READ_PROBLEM', 4);
 
+define('IMAGE_CAPTCHA_FILE_FORMAT_JPG', 1);
+define('IMAGE_CAPTCHA_FILE_FORMAT_PNG', 2);
+define('IMAGE_CAPTCHA_FILE_FORMAT_TRANSPARENT_PNG', 3);
+
 
 /**
  * Implementation of hook_help().
Index: image_captcha.user.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/captcha/image_captcha/image_captcha.user.inc,v
retrieving revision 1.20
diff -u -b -u -p -w -r1.20 image_captcha.user.inc
--- image_captcha.user.inc	17 Sep 2009 23:16:32 -0000	1.20
+++ image_captcha.user.inc	19 Sep 2009 22:38:20 -0000
@@ -1,5 +1,5 @@
 <?php
-// $Id: image_captcha.user.inc,v 1.20 2009/09/17 23:16:32 soxofaan Exp $
+// $Id: image_captcha.user.inc,v 1.20-x 2009/09/19 13:16:00 soxofaan Exp $
 
 /**
  * @file
@@ -29,16 +29,17 @@ function image_captcha_image($captcha_si
       watchdog('CAPTCHA', 'Generation of image CAPTCHA failed. Check your image CAPTCHA configuration and especially the used font.', array(), WATCHDOG_ERROR);
       exit();
     }
-    // Send the image resource as an image to the client
+    // Send the image resource as an image file to the client.
+    $img_type = variable_get('image_captcha_file_format', IMAGE_CAPTCHA_FILE_FORMAT_JPG);
+    if ($img_type == IMAGE_CAPTCHA_FILE_FORMAT_JPG) {
     drupal_set_header("Content-type: image/jpeg");
-    // Following header is needed for Konqueror, which would re-request the image
-    // on a mouseover event, which failes because the image can only be generated
-    // once. This cache directive forces Konqueror to use cache instead of
-    // re-requesting
-    drupal_set_header("Cache-Control: max-age=3600, must-revalidate");
-    // print the image as jpg to the client
     imagejpeg($image);
-    // Clean up
+    }
+    else {
+      drupal_set_header("Content-type: image/png");
+      imagepng($image);
+    }
+    // Clean up the image resource.
     imagedestroy($image);
   }
   exit();
@@ -86,9 +87,14 @@ function _image_captcha_generate_image($
     return FALSE;
   }
 
-  // get background color and paint
+  // Get the background color and paint the background.
   $background_rgb = _image_captcha_hex_to_rgb(variable_get('image_captcha_background_color', '#ffffff'));
   $background_color = imagecolorallocate($image, $background_rgb[0], $background_rgb[1], $background_rgb[2]);
+  // Set transparency if needed.
+  $file_format = variable_get('image_captcha_file_format', IMAGE_CAPTCHA_FILE_FORMAT_JPG);
+  if ($file_format == IMAGE_CAPTCHA_FILE_FORMAT_TRANSPARENT_PNG) {
+    imagecolortransparent($image, $background_color);
+  }
   imagefilledrectangle($image, 0, 0, $width, $height, $background_color);
 
   // draw text
@@ -124,6 +130,9 @@ function _image_captcha_generate_image($
     $freq_yt = 2 * 3.141592 / $wavelength_yt;
 
     $distorted_image = imagecreatetruecolor($width, $height);
+    if ($file_format == IMAGE_CAPTCHA_FILE_FORMAT_TRANSPARENT_PNG) {
+      imagecolortransparent($distorted_image, $background_color);
+    }
     if (!$distorted_image) {
       return FALSE;
     }
