Diff for /loncom/xml/londefdef.pm between versions 1.196 and 1.197

version 1.196, 2004/01/28 20:41:15 version 1.197, 2004/01/30 17:31:06
Line 2085  sub start_img { Line 2085  sub start_img {
     }      }
     $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=$src;      $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=$src;
     my $currentstring = '';      my $currentstring = '';
     my $width_param = '';  
     my $height_param = '';  
     my $scaling = .3;      my $scaling = .3;
     if ($target eq 'web') {      if ($target eq 'web') {
  if ($ENV{'browser.imagesuppress'} ne 'on') {   if ($ENV{'browser.imagesuppress'} ne 'on') {
Line 2100  sub start_img { Line 2098  sub start_img {
     }      }
     $currentstring.='[IMAGE: '.$alttag.']';      $currentstring.='[IMAGE: '.$alttag.']';
  }   }
  $src=&Apache::lonnet::filelocation($Apache::lonxml::pwd[-1],$src);  
  &image_replication($src);  
     } elsif ($target eq 'tex') {      } elsif ($target eq 'tex') {
  $src=&Apache::lonnet::filelocation($Apache::lonxml::pwd[-1],$src);   $src=&Apache::lonnet::filelocation($Apache::lonxml::pwd[-1],$src);
  &image_replication($src);  
  #if original gif/jpg/png file exist do following:   #if original gif/jpg/png file exist do following:
  if (-e $src) {   if (-e $src) {
     #defines the default size of image      #what is the image size?
     my $image = Image::Magick->new;      my $width_param=&image_size($src,$scaling,$parstack,$safeeval);
     my $current_figure = $image->Read($src);              my ($file,$path)=&file_path($src); 
     $width_param = $image->Get('width') * $scaling;;  
     $height_param = $image->Get('height') * $scaling;;  
     undef $image;  
     #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,  
    undef,1);  
     if ($TeXwidth ne '') {    
  if ($TeXwidth=~/(\d+)\s*\%/) {  
     $width_param = $1*$ENV{'form.textwidth'}/100;  
  } else {   
     $width_param = $TeXwidth;  
  }  
     } elsif ($TeXheight ne '') {  
  $width_param = $TeXheight/$height_param*$width_param;  
     } elsif ($width ne '') {  
  $width_param = $width*$scaling;        
     }  
     if ($width_param > $ENV{'form.textwidth'}) {$width_param =0.95*$ENV{'form.textwidth'}}  
     my $file;  
     my $path;  
     if ($src =~ m!(.*)/([^/]*)$!) {  
  $file = $2;   
  $path = $1.'/';   
     }   
     my $newsrc = $src;      my $newsrc = $src;
     $newsrc =~ s/\.(gif|jpg|png)$/.eps/i;      $newsrc =~ s/\.(gif|jpg|png)$/.eps/i;
     $file=~s/\.(gif|jpg|png)$/.eps/i;      $file=~s/\.(gif|jpg|png)$/.eps/i;
Line 3340  sub image_replication { Line 3309  sub image_replication {
     return '';      return '';
 }  }
   
   sub image_size {
       my ($src,$scaling,$parstack,$safeeval)=@_;
       #size of image from gif/jpg/jpeg/png 
       my $image = Image::Magick->new;
       my $current_figure = $image->Read($src);
       my $width_param = $image->Get('width') * $scaling;;
       my $height_param = $image->Get('height') * $scaling;;
       undef $image;
       #do we have any specified LaTeX size of the picture?
       my $TeXwidth = &Apache::lonxml::get_param('TeXwidth',$parstack,$safeeval);
       my $TeXheight = &Apache::lonxml::get_param('TeXheight',$parstack,$safeeval);
       #do we have any specified web size of the picture?
       my $width = &Apache::lonxml::get_param('width',$parstack,$safeeval,
      undef,1);
       if ($TeXwidth ne '') {  
    if ($TeXwidth=~/(\d+)\s*\%/) {
       $width_param = $1*$ENV{'form.textwidth'}/100;
    } else { 
       $width_param = $TeXwidth;
    }
       } elsif ($TeXheight ne '') {
    $width_param = $TeXheight/$height_param*$width_param;
       } elsif ($width ne '') {
    $width_param = $width*$scaling;      
       }
       if ($width_param > $ENV{'form.textwidth'}) {$width_param =0.95*$ENV{'form.textwidth'}}
       return $width_param;
   }
   
 sub eps_generation {  sub eps_generation {
     my ($src,$file,$width_param) = @_;           my ($src,$file,$width_param) = @_;     
     my $filename = "/home/httpd/prtspool/$ENV{'user.name'}_$ENV{'user.domain'}_printout.dat";      my $filename = "/home/httpd/prtspool/$ENV{'user.name'}_$ENV{'user.domain'}_printout.dat";
Line 3354  sub eps_generation { Line 3352  sub eps_generation {
     return ' \graphicspath{{/home/httpd/prtspool'.$newsrc.'}}\includegraphics[width='.$width_param.' mm]{'.$file.'} ';      return ' \graphicspath{{/home/httpd/prtspool'.$newsrc.'}}\includegraphics[width='.$width_param.' mm]{'.$file.'} ';
 }  }
   
   sub file_path {     
       my $src=shift;
       my ($file,$path); 
       if ($src =~ m!(.*)/([^/]*)$!) {
    $file = $2; 
    $path = $1.'/'; 
       } 
       return $file,$path;
   }
   
 sub recalc {  sub recalc {
     my $argument = shift;      my $argument = shift;
     if (not $argument=~/(mm|cm|in|pc|pt)/) {return $argument.' mm';}      if (not $argument=~/(mm|cm|in|pc|pt)/) {return $argument.' mm';}

Removed from v.1.196  
changed lines
  Added in v.1.197


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