#!C:/perl/bin/perl #!/usr/bin/perl BEGIN { unless( -t STDIN){ # if run on commandline, none of this require CGI::Carp; CGI::Carp::carpout(\*LOGGY) if open(LOGGY,'>>'.__FILE__.'.err.log'); CGI::Carp->import( 'fatalsToBrowser' ); } } use strict; use warnings; use GD; use constant PI => 3.141519; # close enough use GD::Text::Wrap; use GD::Text::Align; my $quote = [ grep { $_ } map { chomp; $_ } ]; $quote = $$quote[rand @$quote]; my $author = substr $quote, rindex($quote,'--'), length($quote) -rindex($quote, '--'), ''; #my $gd = GD::Image->new(800,600); my $gd = GD::Image->new(800,600); $gd->colorAllocate(255, 255, 255); my $black = $gd->colorAllocate(0, 0, 0); my $red = $gd->colorAllocate(255, 0, 0); my $blue = $gd->colorAllocate(0, 0, 255); #$gd->transparent($red); $gd->interlaced('true'); $quote = GD::Text::Wrap->new( $gd, width => 800, # has no effect (a bug) line_space => 4, color => $black, text => $quote, preserve_nl => 1, ); $quote->set_font(gdLargeFont); $quote->set(align => 'center', width => 12 * 30); $quote->draw(10,10); $author = GD::Text::Align->new($gd, valign => 'base', halign => 'right', text => $author, ); $author->set_font(gdLargeFont); # STUPID API, always have to pass x,y, otherwise its undef my($left, $top, $right, $bottom) = $quote->get_bounds(10,10); $author->draw( $right , $bottom + 20, PI, $blue); $gd->rectangle( $left -10, $top -10, $right +10, $bottom + 35 , $red); # resize the image (even if it don't affect file-size much for png's) my $gd2 = GD::Image->new( $right + 12, $bottom + 37 ); #$image->copy(sourceImage,dstX,dstY,srcX,srcY,width,height) object $gd2->copy( $gd, 0,0,0,0, $right + 12, $bottom + 37 ); print qq{Expires: Thu, 01 Jan 1970 00:00:00 GMT Date: Fri, 02 Jan 1970 00:00:00 GMT Content-Type: Image/Png\r\n\r\n}; binmode(STDOUT); print $gd2->png(); __END__ A good way to threaten somebody is to light a stick of dynamite. Then you call the guy and hold the burning fuse up to the phone. "Hear that?" you say. "That's dynamite, baby." -- Deep Thoughts by Jack Handey (SNL) Who ate my stick of butter?! -- butterman Once while walking through the mall a guy came up to me and said "Hey, how's it going?". So I grabbed his arm and twisted it up behind his head and said "Now whose asking the questions?" -- Deep Thoughts by Jack Handey (SNL) The memories of my family outings are still a source of strength to me. I remember we'd all pile into the car - I forget what kind it was - and drive and drive. I'm not sure where we'd go, but I think there were some trees there. The smell of something was strong in the air as we played whatever sport we played. I remember a bigger, older guy we called "Dad." We'd eat some stuff, or not, and then I think we went home. I guess some things never leave you. -- Deep Thoughts by Jack Handey (SNL) Marta says the interesting thing about fly-fishing is that it's two lives connected by a thin strand. Come on, Marta. Grow up. -- Deep Thoughts by Jack Handey (SNL)