in reply to Re^2: Broken image link when calling CGI from img tag
in thread Broken image link when calling CGI from img tag

what techniques would I need to use so that the image is generated before the HTML is displayed?

Make sure that the code for the image generation is run before the code that displays the HTML (and that it's not run in the background).

Sorry, but without more knwoledge of the structure of your code it's impossible to give more concrete instructions.

Perl 6 - links to (nearly) everything that is Perl 6.
  • Comment on Re^3: Broken image link when calling CGI from img tag

Replies are listed 'Best First'.
Re^4: Broken image link when calling CGI from img tag
by lintunen (Novice) on Jul 26, 2010 at 08:12 UTC

    I was hoping there would be some generic guidelines on how to handle dynamic image generation and img tags but anyway, in short after the image is generated by an external process the script that generates the image contains the following code:

    if (-e $IMAGEFILE) { print $query->redirect($IMAGEFILE); exit; }

    And as mentioned previously, the perl script is called via an img tag.

      The general mechanism is to wait for the external program, and only then print the redirect.
      Perl 6 - links to (nearly) everything that is Perl 6.
        So will putting the correct logic in the Perl CGI script to wait will stop a broken link being shown in the img tag of the HTML document that calls the Perl script in the first place? As I posted previously, existence for the file is checked before calling the redirect.
      I was hoping there would be some generic guidelines on how to handle dynamic image generation and img tags but anyway

      Check the logs, check the raw http request (or check link directly without img tag). <P. Either you're not outputting the image correctly (correct headers, binmode ...), or permissions on the file are wrong, or the webserver is configured to not serve images from that directory ....