version 1.15, 2007/05/27 16:31:54
|
version 1.16, 2007/05/27 21:21:26
|
Line 550 sub display_color_options {
|
Line 550 sub display_color_options {
|
$showfile = ''; |
$showfile = ''; |
} |
} |
} elsif ($imgfile =~ m-^/(adm/[^/]+)/([^/]+)$-) { |
} elsif ($imgfile =~ m-^/(adm/[^/]+)/([^/]+)$-) { |
|
$showfile = $imgfile; |
my $imgdir = $1; |
my $imgdir = $1; |
my $filename = $2; |
my $filename = $2; |
if (-e "/home/httpd/html/$imgdir/tn-".$filename) { |
if (-e "/home/httpd/html/$imgdir/tn-".$filename) { |
Line 559 sub display_color_options {
|
Line 560 sub display_color_options {
|
my $output = '/home/httpd/html/'.$imgdir.'/tn-'.$filename; |
my $output = '/home/httpd/html/'.$imgdir.'/tn-'.$filename; |
if (!-e $output) { |
if (!-e $output) { |
my ($width,$height) = &thumb_dimensions(); |
my ($width,$height) = &thumb_dimensions(); |
my $size = $width.'x'.$height; |
my ($fullwidth,$fullheight) = &check_dimensions($input); |
system("convert -sample $size $input $output"); |
if ($fullwidth ne '' && $fullheight ne '') { |
|
if ($fullwidth > $width && $fullheight > $height) { |
|
my $size = $width.'x'.$height; |
|
system("convert -sample $size $input $output"); |
|
$showfile = '/'.$imgdir.'/tn-'.$filename; |
|
} |
|
} |
} |
} |
$showfile = '/'.$imgdir.'/tn-'.$filename; |
|
} |
} |
} |
} |
if ($showfile) { |
if ($showfile) { |
$showfile = &Apache::loncommon::lonhttpdurl($showfile); |
$showfile = &Apache::loncommon::lonhttpdurl($showfile); |
$fullsize = &Apache::loncommon::lonhttpdurl($imgfile); |
$fullsize = &Apache::loncommon::lonhttpdurl($imgfile); |
Line 1237 sub thumb_dimensions {
|
Line 1243 sub thumb_dimensions {
|
return ('200','50'); |
return ('200','50'); |
} |
} |
|
|
|
sub check_dimensions { |
|
my ($inputfile) = @_; |
|
my ($fullwidth,$fullheight); |
|
if ($inputfile =~ m|^[/\w.\-]+$|) { |
|
if (open(PIPE,"identify $inputfile 2>&1 |")) { |
|
my $imageinfo = <PIPE>; |
|
if (!close(PIPE)) { |
|
&Apache::lonnet::logthis("Failed to close PIPE opened to retrieve image information for $inputfile"); |
|
} |
|
chomp($imageinfo); |
|
my ($fullsize) = |
|
($imageinfo =~ /^\Q$inputfile\E\s+\w+\s+(\d+x\d+)\s+/); |
|
if ($fullsize) { |
|
($fullwidth,$fullheight) = split(/x/,$fullsize); |
|
} |
|
} |
|
} |
|
return ($fullwidth,$fullheight); |
|
} |
|
|
sub check_configuser { |
sub check_configuser { |
my ($uhome,$dom,$confname,$servadm) = @_; |
my ($uhome,$dom,$confname,$servadm) = @_; |
my ($configuserok,%currroles); |
my ($configuserok,%currroles); |
Line 1369 $env{'user.name'}.':'.$env{'user.domain'
|
Line 1395 $env{'user.name'}.':'.$env{'user.domain'
|
if (($thumbwidth =~ /^\d+$/) && ($thumbheight =~ /^\d+$/)) { |
if (($thumbwidth =~ /^\d+$/) && ($thumbheight =~ /^\d+$/)) { |
my $inputfile = $filepath.'/'.$file; |
my $inputfile = $filepath.'/'.$file; |
my $outfile = $filepath.'/'.'tn-'.$file; |
my $outfile = $filepath.'/'.'tn-'.$file; |
my $thumbsize = $thumbwidth.'x'.$thumbheight; |
my ($fullwidth,$fullheight) = &check_dimensions($inputfile); |
system("convert -sample $thumbsize $inputfile $outfile"); |
if ($fullwidth ne '' && $fullheight ne '') { |
chmod(0660, $filepath.'/tn-'.$file); |
if ($fullwidth > $thumbwidth && $fullheight > $thumbheight) { |
if (-e $outfile) { |
my $thumbsize = $thumbwidth.'x'.$thumbheight; |
my $copyfile=$targetdir.'/tn-'.$file; |
system("convert -sample $thumbsize $inputfile $outfile"); |
if (copy($outfile,$copyfile)) { |
chmod(0660, $filepath.'/tn-'.$file); |
print $logfile "\nCopied source to ".$copyfile."\n"; |
if (-e $outfile) { |
&write_metadata($dom,$confname,$formname,$targetdir, |
my $copyfile=$targetdir.'/tn-'.$file; |
'tn-'.$file,$logfile); |
if (copy($outfile,$copyfile)) { |
} else { |
print $logfile "\nCopied source to ".$copyfile."\n"; |
print $logfile "\nUnable to write ".$copyfile.':'.$!."\n"; |
&write_metadata($dom,$confname,$formname, |
|
$targetdir,'tn-'.$file,$logfile); |
|
} else { |
|
print $logfile "\nUnable to write ".$copyfile. |
|
':'.$!."\n"; |
|
} |
|
} |
} |
} |
} |
} |
} |
} |