http://qs321.pair.com?node_id=111661
Category: CGI Programming
Author/Contact Info bladx - Andy
Description: This is based on a totally random programming idea from Vynce. All this does, is it is a CGI, that lets a user enter in some values for the name of the new generated png that will be created after filling the info. and the hex values for the color of the pixels. It then does the creating of the px png for you, and can be used for generating one color 1x1px png backgrounds as well, for those of you that may need something handy like this, (since I tend to do stuff like this as well.)

Overall, this is a very simple utility, but a fun one to use (or at least resourceful,) if you need to make some quick one color backgrounds ever.
#!/usr/bin/perl -w
use strict;
use warnings;
use CGI;
use GD;

my $query = new CGI;

print $query->header;
print $query->start_html("EasyPX Generator");
print "<H1>EasyPX Generator</H1>\n";
prompt($query);
go_for_it($query);
print $query->end_html;
 
sub prompt {
  my($query) = @_;

  print $query->startform;

  print "Enter Image File Name&nbsp;&nbsp;";
  print $query->textfield('name'),"<br>";

  print "Enter Width&nbsp;&nbsp;";
  print $query->textfield('width'),"<br>";
 
  print "Enter Height&nbsp;&nbsp;";
  print $query->textfield('height'),"<br>";
  
  print "Enter Red Hex Value&nbsp;&nbsp;";
  print $query->textfield('red_value'),"<br>";
  
  print "Enter Green Hex Value&nbsp;&nbsp;";
  print $query->textfield('green_value'),"<br>";

  print "Enter Blue Hex Value&nbsp;&nbsp;";
  print $query->textfield('blue_value'),"<br>";

  print "<p>",$query->reset;
  print $query->submit('Action','Submit');
  print $query->endform;
  print "<hr>\n";
}

sub go_for_it {
  my($query) = @_;
  my(@values,$key);

  print "<H2>Completed with the following values.</H2>";

  foreach $key ($query->param) {
    print "<STRONG>$key</STRONG> -> ";
    @values = $query->param($key);
    print join(", ",@values),"<BR>\n";

    if ($key =~ /name/i) {
      our $name = $query->param($key);
    } elsif ($key =~ /width/i) {
      our $width = $query->param($key);
    } elsif ($key =~ /height/i) {
      our $height = $query->param($key);
    } elsif ($key =~ /red/i) {
      our $red = $query->param($key);
      $red = oct "0x" . $red;
    } elsif ($key =~ /green/i) {
      our $green = $query->param($key);
      $green = oct "0x" . $green;
    } elsif ($key =~ /blue/i) {
      our $blue = $query->param($key);
      $blue = oct "0x" . $blue;
    }
  }

  my $im = new GD::Image(our $width,our $height);

  my $color = $im->colorAllocate(our $red,our $green,our $blue);
  $im->fill(1,1,$color);
  
  open IMAGE, ">" . our $name . ".png";
  print IMAGE $im->png();
  close IMAGE;
}