Diff for /loncom/homework/imageresponse.pm between versions 1.18 and 1.19

version 1.18, 2002/05/03 20:44:46 version 1.19, 2002/07/23 14:41:06
Line 244  sub end_text { Line 244  sub end_text {
   
 sub start_image {  sub start_image {
   my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;    my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
   if ($target eq 'web') { &Apache::lonxml::startredirection; }    if ($target eq 'web' || $target eq 'tex') { &Apache::lonxml::startredirection; }
   return '';    return '';
 }  }
   
 sub end_image {  sub end_image {
   my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;    my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;            
     my $currentstring = '';
   if ($target eq 'web') {    if ($target eq 'web') {
     my $name = $Apache::imageresponse::curname;      my $name = $Apache::imageresponse::curname;
     my $image = &Apache::lonxml::endredirection;      my $image = &Apache::lonxml::endredirection;
Line 260  sub end_image { Line 261  sub end_image {
     } else {      } else {
       $Apache::response::foilgroup{"$name.image"} = $image;        $Apache::response::foilgroup{"$name.image"} = $image;
     }      }
   }    } elsif ($target eq 'tex') {
   return '';      my $src = &Apache::lonxml::endredirection;
       $src=&Apache::lonnet::filelocation($Apache::lonxml::pwd[-1],$src);
       my $width_param = '';
       my $height_param = '';
       my $scaling = .3;
       my $image = Image::Magick->new;
       my $current_figure = $image->Read($src);
       $width_param = $image->Get('width') * $scaling;;
       $height_param = $image->Get('height') * $scaling;;
       undef $image;
       my $epssrc = $src;
       $epssrc =~ s/(\.gif|\.jpg)$/\.eps/i;
       if (not -e $epssrc) {
    my $localfile = $epssrc;
    $localfile =~ s/.*(\/res)/$1/;
    my $file;
    my $path;
    if ($localfile =~ m!(.*)/([^/]*)$!) {
       $file = $2;
       $path = $1.'/'; 
    }
    my $signal_eps = 0;
    my @content_directory = &Apache::lonnet::dirlist($path);
    for (my $iy=0;$iy<=$#content_directory;$iy++) {
       my @tempo_array = split(/&/,$content_directory[$iy]);
       $content_directory[$iy] = $tempo_array[0];
       if ($file eq $tempo_array[0]) {
    $signal_eps = 1;
    last;
       }
    }
    if ($signal_eps) {
       my $eps_file = &Apache::lonnet::getfile($localfile);
    } else {
       $localfile = $src;
       $localfile =~ s/.*(\/res)/$1/;
       my $as = &Apache::lonnet::getfile($src);      
    }
       }
       my $file;
       my $path;
       if ($src =~ m!(.*)/([^/]*)$!) {
    $file = $2;
    $path = $1.'/'; 
       }
       my $newsrc = $src;
       $newsrc =~ s/(\.gif|\.jpg)$/\.eps/i;
       $file=~s/(\.gif|\.jpg)$/\.eps/i;
       #do we have any specified size of the picture?
       my $TeXwidth = &Apache::lonxml::get_param('TeXwidth',$parstack,$safeeval); 
       my $TeXheight = &Apache::lonxml::get_param('TeXheight',$parstack,$safeeval); 
       my $width = &Apache::lonxml::get_param('width',$parstack,$safeeval);
       if ($TeXwidth ne '') { 
    $width_param = $TeXwidth; 
       } elsif ($TeXheight ne '') { 
    $width_param = $TeXheight/$height_param*$width_param;
       } elsif ($width ne '') {
    $width_param = $width*$scaling;      
       }
       #where can we find the picture?
       if (-e $newsrc) {
    if ($path) {
       $currentstring .= '\vskip 0 mm \noindent\graphicspath{{'.$path.'}}\fbox{\includegraphics[width='.$width_param.' mm]{'.$file.'}} ';
    }
       } else {
    my $temp_file;
    my $filename = "/home/httpd/prtspool/$ENV{'user.name'}_$ENV{'user.domain'}_printout.dat";
    $temp_file = Apache::File->new('>>'.$filename); 
    print $temp_file "$src\n";
    $currentstring .= '\vskip 0 mm \graphicspath{{/home/httpd/prtspool/}}\fbox{\includegraphics[width='.$width_param.' mm]{'.$file.'}} ';
       }
    } 
     return $currentstring;
 }  }
   
 sub start_rectangle {  sub start_rectangle {

Removed from v.1.18  
changed lines
  Added in v.1.19


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