in reply to Using GD on MS Windows

It looks like your example was probably designed to be used with CGI. The final print statement writes the image to STDOUT, which is the console. If you run your script and redirect to a file, then double click on the output from Windows Explorer you will find it is a valid png image. For example:
myscript.pl > dot.png
GD creates an image file, it does not display it.

Replies are listed 'Best First'.
Re^2: Using GD on MS Windows
by SparkyEE (Initiate) on Aug 29, 2006 at 15:45 UTC
    Thank you! and Ugh.. So I'd have to simultaneously draw the canvas using Tk and draw the image in GD. Are there any other options to display a graph and then save it using one module??

    Win32::Gui - no drawing function?
    Imager - doesn't spawn a desktop window (like GD)
    Magick - Do i really have to force users to install another application?
    GD - does not display
    Tk - does not save canvas?

      The following way should work with Tk (haven't tested it):

      use MIME::Base64; # ... your GD code from above my $imageData = $image->png; # save $imageData to file with binmde... well you know that... open( my $PNG, ">", $imageFilename ) or die ...; binmode( $PNG ); print $PNG $imageData; close( $PNG ) or die ...; # convert $image to tk photo my $imageData64 = MIME::Base64::encode_base64( $imageData ); my $photo = $mw->Photo( -format => 'png', -data => $imageData64, ); # do something with $photo...

      I used a similar way for a little slideshow I wrote...

      Best regards,
      perl -e "s>>*F>e=>y)\*martinF)stronat)=>print,print v8.8.8.32.11.32"

      GraphViz works well for me on Win32, and there's Tk::GraphViz, though I've never used it.

      --Solo

      --
      You said you wanted to be around when I made a mistake; well, this could be it, sweetheart.
      I don't think your reply, at Re^2: Using GD on MS Windows , follows either from your original post, nor from the excellent answer, above.

      Just what is it that you want to achieve?
      Guesses:

      • Create an image to be saved as a .png file?
      • Draw a graph, live and atop the windows desktop, from some (streaming?) input data?

      If the former, you have the answer above, and came close with your adaptation of the original sample code (which could be edited to specify a file write, rather than output to STDPUT which must then be redirected. If the latter, you may which to ppm -s for the various Graph:: modules.