Apache-Throttle
view release on metacpan or search on metacpan
Makefile.PL view on Meta::CPAN
# $Id: Makefile.PL,v 1.1.1.1 1998/09/11 07:49:57 don Exp $
use ExtUtils::MakeMaker;
eval "use Image::Magick ();";
if ($@) {
print <<"EndOfMSG";
*** Warning:
The throttleimg script that comes with Apache::Throttle requires
the Image::Magick module, which does not seem to be installed.
You can get it from http://www.cpan.org if you wish to use this
script. (It is optional, you don't need the script to run
Apache::Throttle, but it is recommended to have it just in case).
EndOfMSG
sleep 3;
}
eval "use Time::HiRes ();";
if ($@) {
Apache::Throttle is a package designed to allow Apache webservers to
negotiate content based on the speed of the connection.
It's primary purpose is to transparently send smaller (lower
resolution/quality) images to users with slow internet connections,
but it can also be used for many other purposes.
Prerequisites:
* Apache w/ mod_perl
* IPC::Shareable
* Time::HiRes and Image::Magick are also recommended.
Quick Start:
1) "perl Makefile.PL"
2) "make"
3) "make install"
4) add the following lines to one of your Apache config files:
PerlTransHandler Apache::Throttle
PerlFixUpHandler Apache::Throttle::Log
5) "apachectl restart" (or send the main httpd process a -HUP signal)
6) "throttleimg <a gif or jpeg in your Apache htdocs root>"
throttleimg view on Meta::CPAN
#!/usr/bin/perl -w
#
# $Id: throttleimg,v 1.4 1998/09/14 16:15:01 don Exp $
use Image::Magick;
use Getopt::Long;
GetOptions( "help|h|?!" => \$help,
"quiet|q!" => \$quiet,
"time|t=f" => \$time,
"steps|s=i" => \$steps,
"same-size!" => \$same_size,
"same-quality!" => \$same_quality,
"same-colors!" => \$same_colors,
"undo|u" => \$undo,
throttleimg view on Meta::CPAN
print "Creating control file for $time seconds.\n" unless $quiet;
open (CONF, "> $file/.throttle") or die $!;
flock (CONF, 2);
print CONF "$time\n";
close CONF;
my $des = "0";
for my $i (0 .. $steps - 1) {
my $percent = $i / $steps;
my $image = new Image::Magick;
$image->Read("$file/Z-$file");
my ($width, $height) = $image->Get("width", "height");
my @changes = ();
if (!$same_size) {
my $new_width = $width * (.25 + .75 * $percent);
my $new_height = $height * (.25 + .75 * $percent);
$image->Scale(width => $new_width, height => $new_height);
push(@changes, "size=${new_width}x${new_height}");
}
( run in 1.519 second using v1.01-cache-2.11-cpan-beeb90c9504 )