Random HTTP Images
This scripts is used to send out a random image to the browser.
#!/usr/bin/perl
#use strict;
my @images = (
"../lbbook/Images/Newlogo2.gif",
"../lbbook/Images/Freshers/lbbook.jpg",
"../lbbook/Images/Freshers/celtic1.gif",
#"../lbbook/Images/Freshers/madskulls.gif",
"../lbbook/Images/Freshers/cross.gif",
"../lbbook/Images/Freshers/design2.gif"
);
unshift @images,(glob("/home/morpheux/public_html/images/gif_one_linesers/*.gif"));
unshift @images,(glob("/home/morpheux/public_html/images/gif_one_linesers/*.jpg"));
my $file = $images[int rand ($#images+1)];
my $mime ;
if($file =~ /\.jpe?g$/){$mime="image/jpeg";}
elsif($file =~ /\.gif$/){$mime="image/gif";}
$|=1;
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
localtime(time);
my $sday = ("Mon","Tue","Wed","Thu","Fri","Sat","Sun")[$wday];
my $smon = ("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")[$mon];
my $syear = $year + 1900;
print "Expires: $sday, $mday $smon $syear $hour:$min:$sec GMT\n";
print "Date: $sday, $mday $smon $syear $hour:$min:$sec GMT\n";
print "Content-Type: $mime\n\n";
open (IN,"$file") || die"$!";
binmode(IN);
print STDOUT ;
close IN;
##################################
Create Transparent GIFs from text strings
#!/usr/bin/perl -w
use strict;
use Image::Magick;
my $string = shift @ARGV;
my $pointsize = shift @ARGV;
my $font = shift @ARGV;
open(IN,"nice_quotes");
while(my $line = ){
chomp $line;
if($line){
print "\n$line\n";
do_img($line,20);
}
}
close IN;
sub do_img{
my $string = shift ;
my $pointsize = shift ;
$string =~ s/\\t/ /g;
my $image=Image::Magick->new(magick=>'JPG');
$image->Set(size=>'1000x1000',antialias=>'true');
$image->ReadImage('xc:black');
$image->Annotate(text=>"$string",pen=>"white",pointsize=>"$pointsize",font=>"$pointsize");
$image->Trim;
$image->Set(magick=>'GIF');
$image->Set(colors=>250);
$image->Transparent(color=>"black");
$string =~ s/\s//g;
$string =~ s/[^a-zA-Z]//g;
$string =~ s/\?//g;
$string =~ s/\.//g;
my @string = split("",$string);
$string = join("", @string[0..8]);
print "Writting $string.gif\n";
my $x = $image->Write("$string.gif");
warn "$x" if "$x";
}
|