serich has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks,
I am trying to write a cgi script that runs on a windows (iis + ActiveState) box that will generate graphics from a PostScript font and other image files. I have seen many ways to do this from linux, however unfourtunate, linux is out of the question for this script. I have done many of searches, but most have been dead-ends.
So, What have other monks used for cgi-generated graphics in a windows environment? and/or Does anybody know where any how-to's on this could be found?

Btw, the implementation for this is to have a cgi script that generates custom gift certificates in a special font.

Thanks A Ton!
~Erich

edited: Fri Jun 13 16:53:25 2003 by jeffa - title change (was: Graphics On Windows)

  • Comment on CGI Graphics on Internet Information Server

Replies are listed 'Best First'.
Re: CGI Graphics on Internet Information Server
by linebacker (Scribe) on Jun 13, 2003 at 16:33 UTC
    You have several options.

    GD is what you are looking for.

    If you want to go Perl, then this link will do exactly (or very close) to what you are looking for:

    http://www.dopplegangers.com/perl-cgi/

    If you want to go the PHP route

    GD is PHP's drawing module. You can create PNG and JPG images with it. Imagine the possibilities: graphs, doodles, interactive games.

    http://php.weblogs.com/GD

    ßÖ§†

Re: CGI Graphics on Internet Information Server
by dws (Chancellor) on Jun 13, 2003 at 18:02 UTC
    In the event that some of the advice above does what you need, you might still face a few minor hurdles. Two of the biggest "why don't my dynamic graphics work!" problems on Win32 are forgetting to emit the correct content header (e.g., "image/gif", "image/jpg"), and forgetting to do
    binmode(STDOUT);
    before printing the graphic stream.

    Good luck.

Re: CGI Graphics on Internet Information Server
by blahblah (Friar) on Jun 13, 2003 at 16:15 UTC
    I used a small utility called "fly" to generate graphics on-the-fly (har har) in windows a long time ago. Generating a lot of graphics can bog the server, but I'm assuming thats not an issue for you. fly can not take postscript fonts, but you might be able to modify it. The fly homepage is:

    http://martin.gleeson.com/fly

    Not a perlish answer, but an answer nonetheless :)

    HTH
Re: CGI Graphics on Internet Information Server
by Willard B. Trophy (Hermit) on Jun 13, 2003 at 15:41 UTC
    You could try PDFlib, which allows you to generate PDF on the fly, using whichever fonts you want. It has good, if slightly weird, Perl support.

    PDFlib's licensing has recently changed. I think the standard, free version is now the "lite" version, and PDFlib itself costs $$$.

    --
    bowling trophy thieves, die!

Re: CGI Graphics on Internet Information Server
by chunlou (Curate) on Jun 13, 2003 at 19:50 UTC
    The following test script (say, trygd.pl) should work on Apache + ActiveState + Win32 (sorry, not really what you wanted, though):
    #! /usr/local/bin/perl -w use strict; use Apache::Request (); # Apache stuff use GD::Graph::pie; use constant TITLE => "Morning Commute Time: Pie Chart"; my $r = shift; # Apache stuff my $graph = new GD::Graph::pie( 300, 300 ); my @data = ( [ qw( Monday Tuesday Wednesday Thursday Friday ) ], [ 33, 24, 23, 19, 21 ], ); $graph->set( title => TITLE, '3d' => 2 ); my $gd_image = $graph->plot( \@data ); $r->content_type('image/jpg'); # Apache stuff $r->send_http_header; # Apache stuff binmode STDOUT; print $gd_image->jpeg; exit;
    You could just include the script in a HTML like:
    <html><body> <p>My Pie Chart</p> <img src=trygd.pl> </body></html>
    At least, you (or I) want to know you can stream binary directly to a browser from your Web server (as opposed to writing a graph to a temporary file).
Re: CGI Graphics on Internet Information Server
by serich (Sexton) on Jun 14, 2003 at 01:34 UTC
    First off, thanks to everybody for your great information. It really gave me a lot to think about, and some great starting points.

    PDFlib would have been perfect, but it has a stamp on it on the free version, and yea, it costs about 5x what my budget is.

    I tried out fly, and it works great, but I would have had to modify it to get it to work with a different font. But i'll be using it in some other graphic reports areas.

    GD would have worked great, but after a couple of hours of installing and tinkering it still didn't quite work.

    All of this lead me to PerlMagick, which did everything but use postscript fonts, with only a 5 minute install. (well, should have been if I had actually followed the instructions to reboot). I found a program to convert postscript to truetype (not the best, but at the size I need the fonts, it should work). With all that, it seems to be working fairly well.

    Thanks for all your responses!
    ~Erich
      what, even the Lite version watermarks? That sucks! It sounds like they only made it free while they were debugging the useful features, then they took it away. Boo!

      --
      bowling trophy thieves, die!

Re: CGI Graphics on Internet Information Server
by mattr (Curate) on Jun 16, 2003 at 13:33 UTC
    Have you tried to build your linux software of choice in cygwin environment on Windows?