Err, this doesn't actually work! For those of us forced to labour under a Microsoft cloud, you can't just print binary files out without turning
binmode on. Thus you need to change the print statement at the end to:
open IMAGE, ">" . $name . ".png";
binmode IMAGE;
print IMAGE $im->png();
close IMAGE;
You have also loaded CGI but then gone on to print out your own HTML. It seems a bit much having a dog, and barking yourself, if you ask me.
Also sin of sins, you are writing to the file system, with a user supplied filename and not doing any taint checking. I know you said this was a "simple utility", but you should not allow anyone to write to your filesystem, without being sure that they are writing what and where you want to allow them. See perlsec.
I think merlyn wrote a pixel factory on his column, which is similar in idea.
Your script is however, minor defects aside, quite useful.
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.