#!/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; }

In reply to Easy Pixel PNG Generator by bladx

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.