Thanks for the reply. I think your approach is exactly what I need to do.
I have not yet worked on the code to send the image data to the browser for this particular project. However, I've tried to do this in the past using GD, got it to work once, deleted that code when it turned out I didn't need it, tried it again and couldn't get it to work.
What I've tried in the past went something like:
print STDOUT $query->header(-type=>'image/gif');
binmode STDOUT;
print STDOUT $image->gif();
Is there a better approach?