--- textimage_HEAD.module	Tue Aug 31 18:02:47 2010
+++ textimage.module	Tue Aug 31 17:57:52 2010
@@ -343,6 +343,9 @@
  *   preset uses the result of another preset as its background image.
  */
 function textimage_image_from_preset($pid, $text, $additional_text) {
+  $antialias = TRUE;
+  $factor = 8.;
+
   $preset = _textimage_preset_load($pid);
   $text = str_replace('_', ' ', $text);
 
@@ -378,6 +381,13 @@
     foreach ($values as $key => $value) {
       // Strip prefixes like 'back_' for array lookups.
       $array_key = preg_replace('/^back_/', '', $key);
+      
+      // Scale up values for antialiasing.
+      if ($antialias && in_array($key, array('size', 'stroke_width', 'maximum_width', 'margin_top', 'margin_right', 'margin_bottom', 'margin_left'))) {
+        $value *= $factor;
+        $settings[$array_key] *= $factor;
+      }
+
       // Assign to variable and fill in default.
       $$key = $settings[$array_key] ? $settings[$array_key] : $value;
     }
@@ -415,6 +425,15 @@
     $img = textimage_image_add_stroke($img, $stroke_width, $stroke_color);
   }
 
+  if ($antialias) {
+    $text_width = imagesx($img);
+    $text_height = imagesy($img);
+    $aa_img = _textimage_create_transparent_image($text_width/$factor, $text_height/$factor);
+    imagecopyresampled($aa_img, $img, 0, 0, 0, 0, $text_width/$factor, $text_height/$factor, $text_width, $text_height);
+    imagedestroy($img);
+    $img = $aa_img;
+  }
+
   // Place result on top of another preset's result
   if (is_numeric($back_image) && _textimage_preset_load($back_image)) {
     $next_preset = $back_image;
@@ -440,7 +459,6 @@
     imagesavealpha($background_resource, TRUE);
     $img = $background_resource;
   }
-
   return $img;
 }
 
