G+_Joe C. Hecht Posted June 16, 2014 Share Posted June 16, 2014 makeimage.pl - An Perl code submission for TWiT's Coding 101 I would like to submit to the Coding 101 community 439 lines of well commented code, and would be very thankful for any critique that anyone may wish to share. http://www.code4sale.com/tjoe/twit-coding101/makeimage.htm While a bit lengthy, it is rather complete. makeimage.pl is a Perl script used to create a dynamic image (JPG, PNG, OR GIF) that says "Hello PersonsName". The script relies on the GD package (installed by default with the later versions of ActiveState perl). The script uses (by default) the font c:/Windows/Fonts/comic.ttf, or easily be tweaked to use any other reasonably valid TrueType font. If you are running on a Mac or Linux, adjustments will need to be made to point the font path to a reasonably valid TrueType font, and you need to ensure that the GD package is installed for your version of Perl. Enjoy :) http://www.code4sale.com/tjoe/twit-coding101/makeimage.htm Link to comment Share on other sites More sharing options...
G+_Darryl Medley Posted June 17, 2014 Share Posted June 17, 2014 Great example of a tutorial program. In terms of criticism, I'd say the comments do an excellent job of explaining the functionality of the program but could do a better job of explaining Perl syntax. I'm an experienced pro coder but I'm new to Perl and have only seen a little C++ so I wasn't sure what "GD::Image->new(" meant. Because of my experience my first guess turned out to be correct but I'm sure a newbie would be confused. I also had trouble spotting the main block of the program because I'm used to functions being first. The final thing I had to look up was the keyword "my" because I hadn't seen it before. But, other than these minor quibbles, I learned a lot from it. Thanks for making the effort to write it. Link to comment Share on other sites More sharing options...
G+_Joe C. Hecht Posted June 17, 2014 Author Share Posted June 17, 2014 Darryl Medley Great suggestions Darryl. I have modified the code to address all three concerns. Thanks! Link to comment Share on other sites More sharing options...
G+_Joe C. Hecht Posted June 17, 2014 Author Share Posted June 17, 2014 A quick note to say I have updated the code, adding some additional comments suggested by Darryl Medley and Lee Crocker , and also added SheBang lines for ActiveState Perl running on MacOSX and (one of my) versions of Linux. Finally, I added a section of code that attempts to find a suitable font to use in the event that the code is running on a non-Windows platform. I also updated the .zip file to supply code with sheBang's and line endings for Windows, Mac OSX, and Linux. Thanking everyone for the critiques. Enjoy! Link to comment Share on other sites More sharing options...
Recommended Posts