#!/usr/bin/perl $|++; use strict; use warnings; use diagnostics; use CGI; use CGI::Carp qw(fatalsToBrowser); use GD; my $font = gdGiantFont; my $letter_height = 15; my $letter_width = 10; my $query = new CGI; my $cmd = $query->param('cmd') || 'show'; my $text = $query->param('text') || ''; print $query->header('-type' => 'image/jpeg'); binmode STDOUT; my @letters = split(//,$text); my $img_height = ($cmd eq 'show')? $letter_height * scalar(@letters) : $letter_height + 2; my $img_width = ($cmd eq 'show')? $letter_width + 2 : $letter_width * scalar(@letters); my $img = new GD::Image($img_width,$img_height); my $bg_color = $img->colorAllocate(45,167,213); my $text_color = $img->colorAllocate(255,255,255); $img->fill($img_width,$img_height,$bg_color); if($cmd eq 'show'){ my $y_pos = 0; foreach my $letter(@letters){ $img->string($font,1,$y_pos,$letter,$text_color); $y_pos += $letter_height; } print $img->jpeg; }else{ my $x_pos = 0; foreach my $letter(@letters){ $img->string($font,$x_pos,1,$letter,$text_color); $x_pos += $letter_width; } my $rotated_img = $img->copyRotate90(); print $rotated_img->jpeg; }