[LON-CAPA-cvs] cvs: loncom /homework randomlylabel.pm
albertel
lon-capa-cvs@mail.lon-capa.org
Mon, 23 Feb 2004 23:24:53 -0000
albertel Mon Feb 23 18:24:53 2004 EDT
Modified files:
/loncom/homework randomlylabel.pm
Log:
- correct and no longer ISEs
Index: loncom/homework/randomlylabel.pm
diff -u loncom/homework/randomlylabel.pm:1.16 loncom/homework/randomlylabel.pm:1.17
--- loncom/homework/randomlylabel.pm:1.16 Mon Feb 23 17:52:30 2004
+++ loncom/homework/randomlylabel.pm Mon Feb 23 18:24:50 2004
@@ -2,7 +2,7 @@
# The LearningOnline Network with CAPA
# randomlabel.png: composite together text and images into 1 image
#
-# $Id: randomlylabel.pm,v 1.16 2004/02/23 22:52:30 albertel Exp $
+# $Id: randomlylabel.pm,v 1.17 2004/02/23 23:24:50 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -34,7 +34,7 @@
use Image::Magick;
use Apache::Constants qw(:common);
use Apache::loncommon();
-use GD();
+use GD;
use GD::Polyline();
use LWP::UserAgent();
@@ -54,7 +54,7 @@
$request->header(Cookie => $ENV{'HTTP_COOKIE'});
my $file="/tmp/imagetmp".$$;
my $response=$ua->request($request,$file);
- &Apache::lonnet::logthis("contetn is ".$response->content_type);
+ &Apache::lonnet::logthis("content is ".$response->content_type);
&Apache::lonnet::logthis($response->is_success);
&Apache::lonnet::logthis($response->status_line);
if ($response->is_success) {
@@ -73,13 +73,19 @@
} elsif ($imgsrc !~ /\.(png|jpg|jpeg)$/i) {
my $conv_image = Image::Magick->new;
my $current_figure = $conv_image->Read('filename'=>$imgsrc);
+ &Apache::lonnet::logthis("Read said $current_figure");
$conv_image->Set('magick'=>'png');
my @blobs=$conv_image->ImageToBlob();
undef $conv_image;
$image = GD::Image->new($blobs[0]);
} else {
- GD::Image->trueColor(1);
+ $image = GD::Image->trueColor(1);
$image = GD::Image->new($imgsrc);
+ if (!defined($image)) {
+ &Apache::lonnet::logthis("Read said bluh");
+ } else {
+ &Apache::lonnet::logthis("looks good");
+ }
}
if ($set_trans && defined($image)) {
my $white=$image->colorExact(255,255,255);
@@ -105,12 +111,16 @@
$r->content_type('image/png');
$r->send_http_header;
my (undef,$id) = split(/=/,$ENV{'QUERY_STRING'});
- &Apache::lonnet::logthis("BGIMG is ".$ENV{"cgi.$id.BGIMG"});
- my $image=&get_image(&Apache::lonnet::unescape($ENV{"cgi.$id.BGIMG"}),0);
- if (! defined($image)) {
- &Apache::lonnet::logthis('Unable to create image object for -'.$id.'-'.
- $ENV{"cgi.$id.BGIMG"});
- return OK;
+ my $image;
+ if (defined($ENV{"cgi.$id.BGIMG"})) {
+ my $bgimg=&Apache::lonnet::unescape($ENV{"cgi.$id.BGIMG"});
+ &Apache::lonnet::logthis("BGIMG is ".$bgimg);
+ $image=&get_image($bgimg,0);
+ if (! defined($image)) {
+ &Apache::lonnet::logthis('Unable to create image object for -'.
+ $id.'-'.$bgimg);
+ return OK;
+ }
} elsif (defined($ENV{"cgi.$id.SIZE"})) {
my ($width,$height)=split(':',$ENV{"cgi.$id.SIZE"});
$image = new GD::Image($width,$height,1);
@@ -204,9 +214,7 @@
$text=&Apache::lonnet::unescape($text);
my $imcolor=&get_color_from_hexstring($image,$color);
my $height=GD::Font->Giant->height;
- for(my $i=0;$i<$ENV{"cgi.$id.COUNT"};$i++) {
- $image->string(GD::gdGiantFont,$x,$y-$height,$text,$black);
- }
+ $image->string(GD::gdGiantFont,$x,$y-$height,$text,$imcolor);
}
}
$image->setThickness(1);