version 1.267, 2005/04/07 06:56:27
|
version 1.271, 2005/05/17 23:27:25
|
Line 153 sub start_html {
|
Line 153 sub start_html {
|
my $currentstring = ''; |
my $currentstring = ''; |
my $options=$env{'course.'.$env{'request.course.id'}.'.tthoptions'}; |
my $options=$env{'course.'.$env{'request.course.id'}.'.tthoptions'}; |
&Apache::lontexconvert::init_tth(); |
&Apache::lontexconvert::init_tth(); |
if ($target eq 'web' || $target eq 'edit') { |
if ($target eq 'web' || $target eq 'edit' || $target eq 'webgrade' ) { |
$currentstring = &Apache::lonxml::xmlbegin(); |
$currentstring = &Apache::lonxml::xmlbegin(); |
} elsif ($target eq 'tex') { |
} elsif ($target eq 'tex') { |
$currentstring .= '\documentclass[letterpaper]{article}'; |
$currentstring .= '\documentclass[letterpaper]{article}'; |
Line 3766 sub image_replication {
|
Line 3766 sub image_replication {
|
} |
} |
return ''; |
return ''; |
} |
} |
|
# |
|
# Get correct sizing parameter for an image given |
|
# it's initial ht. and wid. This allows sizing of |
|
# images that are generated on-the-fly (e.g. gnuplot) |
|
# as well as serving as a utility for image_size. |
|
# |
|
# Parameter: |
|
# height_param |
|
# width_param - Initial picture dimensions. |
|
# scaling - A scale factor. |
|
# parstack, |
|
# safeeval, |
|
# depth, |
|
# cis - The usual xml stuff ??? |
|
# |
|
# Returns: |
|
# height, width - new dimensions. |
|
# |
|
sub resize_image { |
|
my ($height_param, $width_param, $scaling, |
|
$parstack, $safeeval, $depth, $cis) = @_; |
|
|
sub image_size { |
# First apply the scaling... |
my ($src,$scaling,$parstack,$safeeval,$depth,$cis)=@_; |
|
|
$height_param = $height_param * $scaling; |
|
$width_param = $width_param * $scaling; |
|
|
#size of image from gif/jpg/jpeg/png |
|
my $ressrc=&Apache::lonnet::filelocation($Apache::lonxml::pwd[-1],$src); |
|
if (-e $ressrc) { |
|
$src = $ressrc; |
|
} |
|
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; |
|
&Apache::lonxml::debug("Image magick says: $src : Height = $height_param width = $width_param"); |
|
undef($image); |
|
#do we have any specified LaTeX size of the picture? |
#do we have any specified LaTeX size of the picture? |
my $toget='TeXwidth'; |
my $toget='TeXwidth'; |
if ($cis) { |
if ($cis) { |
Line 3825 sub image_size {
|
Line 3837 sub image_size {
|
$height_param=$width_param/$old_width_param*$height_param; |
$height_param=$width_param/$old_width_param*$height_param; |
} |
} |
} |
} |
|
|
|
return ($height_param, $width_param); |
|
} |
|
|
|
sub image_size { |
|
my ($src,$scaling,$parstack,$safeeval,$depth,$cis)=@_; |
|
|
|
#size of image from gif/jpg/jpeg/png |
|
my $ressrc=&Apache::lonnet::filelocation($Apache::lonxml::pwd[-1],$src); |
|
if (-e $ressrc) { |
|
$src = $ressrc; |
|
} |
|
my $image = Image::Magick->new; |
|
my $current_figure = $image->Read($src); |
|
my $width_param = $image->Get('width'); |
|
my $height_param = $image->Get('height'); |
|
&Apache::lonxml::debug("Image magick says: $src : Height = $height_param width = $width_param"); |
|
undef($image); |
|
|
|
($height_param, $width_param) = &resize_image($height_param, $width_param, |
|
$scaling, $parstack, $safeeval, |
|
$depth, $cis); |
|
|
return ($height_param, $width_param); |
return ($height_param, $width_param); |
} |
} |
|
|
Line 3854 sub get_eps_image {
|
Line 3889 sub get_eps_image {
|
#if replication failed try to find ps file |
#if replication failed try to find ps file |
$src=~s/\.eps$/\.ps/; |
$src=~s/\.eps$/\.ps/; |
&Apache::lonxml::debug("Now looking for $src"); |
&Apache::lonxml::debug("Now looking for $src"); |
#if no ps file try to replicate it |
#if no ps file try to replicate it. |
if (not -e $src && |
my $didrepcopy = &Apache::lonnet::repcopy($src); |
&Apache::lonnet::repcopy($src) ne 'ok') { |
&Apache::lonxml::debug("repcopy of $src ... $didrepcopy"); |
|
if ( (not -e $src) || |
|
($didrepcopy ne 'ok')) { |
&Apache::lonxml::debug("Failed to find or replicate $src"); |
&Apache::lonxml::debug("Failed to find or replicate $src"); |
|
|
#if replication failed try to produce eps file dynamically |
#if replication failed try to produce eps file dynamically |