title: Content-Length for dynamically resized image PHP
body: <p>I've written an PHP page to dynamically resize an image stored as a BLOB in a MySQL database. I'm doing this on the fly without storing any temporary files. Is there any way to determine a Content-Length to send in the header?</p>
  
  <p>I have the image created with imagecopyresampled() and use imagepng() (or the like) to output the image data.</p>
  
  <pre><code>$origImage = imagecreatefromstring($image['data']);
  $newImage = imagecreatetruecolor($width, $height);
  
  // preserve alpha
  imagealphablending($newImage, false);
  imagesavealpha($newImage, true);
  
  $resizeSuccess = imagecopyresampled($newImage, $origImage, 0, 0, 0, 0, $width, $height, $image['width'], $image['height']);
  
  header('Content-Type: image/png');
  imagepng($newImage, null, $pngCompression, PNG_NO_FILTER);
  imagedestroy($newImage);
  </code></pre>