version 1.16, 2004/02/23 22:52:30
|
version 1.17, 2004/02/23 23:24:50
|
Line 34 use strict;
|
Line 34 use strict;
|
use Image::Magick; |
use Image::Magick; |
use Apache::Constants qw(:common); |
use Apache::Constants qw(:common); |
use Apache::loncommon(); |
use Apache::loncommon(); |
use GD(); |
use GD; |
use GD::Polyline(); |
use GD::Polyline(); |
use LWP::UserAgent(); |
use LWP::UserAgent(); |
|
|
Line 54 sub get_image {
|
Line 54 sub get_image {
|
$request->header(Cookie => $ENV{'HTTP_COOKIE'}); |
$request->header(Cookie => $ENV{'HTTP_COOKIE'}); |
my $file="/tmp/imagetmp".$$; |
my $file="/tmp/imagetmp".$$; |
my $response=$ua->request($request,$file); |
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->is_success); |
&Apache::lonnet::logthis($response->status_line); |
&Apache::lonnet::logthis($response->status_line); |
if ($response->is_success) { |
if ($response->is_success) { |
Line 73 sub get_image {
|
Line 73 sub get_image {
|
} elsif ($imgsrc !~ /\.(png|jpg|jpeg)$/i) { |
} elsif ($imgsrc !~ /\.(png|jpg|jpeg)$/i) { |
my $conv_image = Image::Magick->new; |
my $conv_image = Image::Magick->new; |
my $current_figure = $conv_image->Read('filename'=>$imgsrc); |
my $current_figure = $conv_image->Read('filename'=>$imgsrc); |
|
&Apache::lonnet::logthis("Read said $current_figure"); |
$conv_image->Set('magick'=>'png'); |
$conv_image->Set('magick'=>'png'); |
my @blobs=$conv_image->ImageToBlob(); |
my @blobs=$conv_image->ImageToBlob(); |
undef $conv_image; |
undef $conv_image; |
$image = GD::Image->new($blobs[0]); |
$image = GD::Image->new($blobs[0]); |
} else { |
} else { |
GD::Image->trueColor(1); |
$image = GD::Image->trueColor(1); |
$image = GD::Image->new($imgsrc); |
$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)) { |
if ($set_trans && defined($image)) { |
my $white=$image->colorExact(255,255,255); |
my $white=$image->colorExact(255,255,255); |
Line 105 sub handler {
|
Line 111 sub handler {
|
$r->content_type('image/png'); |
$r->content_type('image/png'); |
$r->send_http_header; |
$r->send_http_header; |
my (undef,$id) = split(/=/,$ENV{'QUERY_STRING'}); |
my (undef,$id) = split(/=/,$ENV{'QUERY_STRING'}); |
&Apache::lonnet::logthis("BGIMG is ".$ENV{"cgi.$id.BGIMG"}); |
my $image; |
my $image=&get_image(&Apache::lonnet::unescape($ENV{"cgi.$id.BGIMG"}),0); |
if (defined($ENV{"cgi.$id.BGIMG"})) { |
if (! defined($image)) { |
my $bgimg=&Apache::lonnet::unescape($ENV{"cgi.$id.BGIMG"}); |
&Apache::lonnet::logthis('Unable to create image object for -'.$id.'-'. |
&Apache::lonnet::logthis("BGIMG is ".$bgimg); |
$ENV{"cgi.$id.BGIMG"}); |
$image=&get_image($bgimg,0); |
return OK; |
if (! defined($image)) { |
|
&Apache::lonnet::logthis('Unable to create image object for -'. |
|
$id.'-'.$bgimg); |
|
return OK; |
|
} |
} elsif (defined($ENV{"cgi.$id.SIZE"})) { |
} elsif (defined($ENV{"cgi.$id.SIZE"})) { |
my ($width,$height)=split(':',$ENV{"cgi.$id.SIZE"}); |
my ($width,$height)=split(':',$ENV{"cgi.$id.SIZE"}); |
$image = new GD::Image($width,$height,1); |
$image = new GD::Image($width,$height,1); |
Line 204 sub handler {
|
Line 214 sub handler {
|
$text=&Apache::lonnet::unescape($text); |
$text=&Apache::lonnet::unescape($text); |
my $imcolor=&get_color_from_hexstring($image,$color); |
my $imcolor=&get_color_from_hexstring($image,$color); |
my $height=GD::Font->Giant->height; |
my $height=GD::Font->Giant->height; |
for(my $i=0;$i<$ENV{"cgi.$id.COUNT"};$i++) { |
$image->string(GD::gdGiantFont,$x,$y-$height,$text,$imcolor); |
$image->string(GD::gdGiantFont,$x,$y-$height,$text,$black); |
|
} |
|
} |
} |
} |
} |
$image->setThickness(1); |
$image->setThickness(1); |