Annotation of loncom/homework/randomlylabel.pm, revision 1.1

1.1     ! albertel    1: #!/usr/bin/perl
        !             2: # The LearningOnline Network with CAPA
        !             3: # randomlabel.png: composite together text and images into 1 image
        !             4: #
        !             5: # $Id: randomlabel.png,v 1.1 2002/11/07 19:48:51 albertel Exp $
        !             6: #
        !             7: # Copyright Michigan State University Board of Trustees
        !             8: #
        !             9: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
        !            10: #
        !            11: # LON-CAPA is free software; you can redistribute it and/or modify
        !            12: # it under the terms of the GNU General Public License as published by
        !            13: # the Free Software Foundation; either version 2 of the License, or
        !            14: # (at your option) any later version.
        !            15: #
        !            16: # LON-CAPA is distributed in the hope that it will be useful,
        !            17: # but WITHOUT ANY WARRANTY; without even the implied warranty of
        !            18: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
        !            19: # GNU General Public License for more details.
        !            20: #
        !            21: # You should have received a copy of the GNU General Public License
        !            22: # along with LON-CAPA; if not, write to the Free Software
        !            23: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
        !            24: #
        !            25: # /home/httpd/html/adm/gpl.txt
        !            26: #
        !            27: # http://www.lon-capa.org/
        !            28: #
        !            29: ###
        !            30: 
        !            31: package Apache::randomlylabel;
        !            32: 
        !            33: use strict;
        !            34: use Image::Magick;
        !            35: use Apache::Constants qw(:common);
        !            36: use Apache::loncommon();
        !            37: 
        !            38: sub handler {
        !            39:     my $r = shift;
        !            40:     $r->content_type('image/png');
        !            41:     my (undef,$token) = split(/=/,$ENV{'QUERY_STRING'});
        !            42:     &Apache::loncommon::get_unprocessed_cgi(
        !            43:                &Apache::lonnet::unescape($ENV{'imagerequest.'.$token}));
        !            44:     &Apache::lonnet::delenv('imagerequest\.'.$token);
        !            45:     my $image = Image::Magick->new;
        !            46:     my $current_figure = $image->Read('filename'=>$ENV{"form.BGIMG"});
        !            47:     #binmode(STDOUT);
        !            48:     for(my $i=0;$i<$ENV{"form.ICOUNT"};$i++) {
        !            49: 	my $subimage = Image::Magick->new;
        !            50: 	$subimage->Read('filename' => $ENV{"form.IMG$i"});
        !            51: 	$image->Composite('x' => $ENV{"form.X$i"},'y' => $ENV{"form.Y$i"},
        !            52: 			 'compose'=> 'Over', 'image' => $subimage);
        !            53: 	undef($subimage);
        !            54:     }
        !            55:     for(my $i=0;$i<$ENV{"form.COUNT"};$i++) {
        !            56: 	$image->Annotate('text' => $ENV{"form.LB$i"},'x' => $ENV{"form.X$i"},
        !            57: 			 'y' => $ENV{"form.Y$i"}, 'font' => 'Times-Bold',
        !            58: 			 'pointsize' => 18, 'antialias' => 'true');
        !            59:     }
        !            60:     $image->Set('magick'=>'png');
        !            61:     my @blobs=$image->ImageToBlob();
        !            62:     $r->print($blobs[0]);
        !            63:     return OK;
        !            64: }
        !            65: 
        !            66: 1;

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>