GD can do this (and more). Here's a quick 'n' dirty example that will create a 100x100 pixel PNG and spew it to STDOUT (so make sure you redirect to a file in your shell).
use strict;
use GD;
my $im = new GD::Image(100,100);
my @colors; # Preallocate colors, since PNG has a limited number of co
+lors
for (0..255) {
$colors[$_] = $im->colorAllocate(int(rand(256)),int(rand(256)),int(r
+and(256)));
}
for my $x (0..99) {
for my $y (0..99) {
$im->setPixel($x,$y,$colors[int(rand(255))]);
}
}
binmode STDOUT;
print $im->png;
"One word of warning: if you meet a bunch of Perl programmers on the bus or something, don't look them in the eye. They've been known to try to convert the young into Perl monks." - Frank Willison
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|