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?
I have the image created with imagecopyresampled() and use imagepng() (or the like) to output the image data.
$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);
Instead of your
imagepngcall, try this:Also, the server should handle
Content-Lengthautomatically for you.