--- loncom/homework/randomlylabel.pm	2003/01/23 18:26:10	1.5
+++ loncom/homework/randomlylabel.pm	2003/02/27 21:36:27	1.8
@@ -2,7 +2,7 @@
 # The LearningOnline Network with CAPA
 # randomlabel.png: composite together text and images into 1 image
 #
-# $Id: randomlylabel.pm,v 1.5 2003/01/23 18:26:10 www Exp $
+# $Id: randomlylabel.pm,v 1.8 2003/02/27 21:36:27 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -47,6 +47,7 @@ sub get_image {
 	undef $conv_image;
 	$image = GD::Image->new($blobs[0]);
     } else {
+	GD::Image->trueColor(1);
 	$image = GD::Image->new($imgsrc);
     }
     if ($set_trans) {
@@ -62,14 +63,17 @@ sub handler {
     my (undef,$token) = split(/=/,$ENV{'QUERY_STRING'});
     &Apache::loncommon::get_unprocessed_cgi(
                &Apache::lonnet::unescape($ENV{'imagerequest.'.$token}));
-    &Apache::lonnet::delenv('imagerequest\.'.$token);
     my $image=&get_image($ENV{"form.BGIMG"},0);
     if (! defined($image)) {
-        &Apache::lonnet::logthis('Unable to create image object for '.$ENV{"form.BGIMG"});
+        &Apache::lonnet::logthis('Unable to create image object for '.
+				 $ENV{"form.BGIMG"});
         return OK;
     }
     #binmode(STDOUT);
-    my $black = $image->colorAllocate(0,0,0);
+    my $black;
+    if (!($black=$image->colorResolve(0,0,0))) {
+	$black = $image->colorClosestHWB(0,0,0);
+    }
     for(my $i=0;$i<$ENV{"form.ICOUNT"};$i++) {
 	my $subimage=&get_image($ENV{"form.IMG$i"},1);
 	$image->copy($subimage,$ENV{"form.X$i"},$ENV{"form.Y$i"},