imagepng Very Slow
<p>I have a .php file that's supposed to load an image for display in an img tag<br/>(i.e., <code>&lt;img src="the_file.php?which=0"/&gt;</code>).  It looks like this:</p>

<pre><code>&lt;?php
    ob_clean();

    header("Content-type: image/png");

    include_once("util.php");

    //Do a simple calculation to get $name from (int)$_GET["which"];

    $im = imagecreatefrompng("protected_directory/".$name.".png");

    imagepng($im,NULL,0,NULL);

    imagedestroy($im);

    ob_end_flush();
?&gt;
</code></pre>

<p>It works correctly, but the image loads substantially slower than just loading it directly<br/>(i.e. <code>&lt;img src="protected_directory/the_name.png"/&gt;</code>, where "the_name" was calculated the same way as in the PHP file, but I can't just do this because the protected_directory isn't world readable).</p>

<p>My question is, why is this suddenly so much slower?  It's not a large image, but nor is it terribly small.</p>
