Ok, things have been going well with learning about how to use the nice GD module to create random images, etc. However, I have stumbled accross a problem I was having earlier, but didn't say anything much about until now. I have the following 2 files, and here they are in their basic code form:
File:
gd1.pl
#!/usr/bin/perl -w
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(ran
+d(256)));
}
for my $x (0..99) {
for my $y (0..99) {
$im->setPixel($x,$y,$colors[int(rand(255))]);
}
}
print "Content-Type: image/png\n\n";
print $im->png;
File:
gd2.pl
#!/usr/bin/perl -w
print "Content-type: text/html\n\n";
print<<HTML;
<html><head><title>testing more</title></head>
<body bgcolor=#ffffff>
<center>
HTML
print "Content-type: image/png\n\n";
print "<img src='gd1.pl' height=100 width=100>\n";
print<<HTML;
</center>
</body>
</html>
HTML
And I was trying to figure out how I can use regular HTML code to run this random png image creator program over the internet, so it would look like it was a regular png already on the server.
My guess is there is something really wrong with the gd2.pl file since I haven't tweaked the original gd1.pl actual program file all that much.
Thanks for any help or input I could get!
Andy Summers
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.