What is the right way to serve dynamically generated images using Apache and mod_perl?

0

Issue

I have an Apache2/mod_perl2 system up and running.

I’m using GD to create an image on the fly, and I’m then printing it like this:

$r->content_type('image/png');
binmode STDOUT;
print $im->png;

But is this the correct way to do things in mod_perl2?

(Ignore the fact that I’m generating an image on the fly and not caching it etc …)

Solution

Under mod_perl2, you should not print stuff directly to STDOUT. Instead, use

use Apache2::Const 'OK';

$r->content_type( 'image/png' );
$r->print( $im->png );

return OK;

Answered By – friedo

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave A Reply

Your email address will not be published.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More