How to output a PNG with GD with same headers as pre-existing PNG file

From: Date: Thu, 15 Sep 2005 17:58:41 +0000
Subject: How to output a PNG with GD with same headers as pre-existing PNG file
Groups: php.general 
Request: Send a blank email to php-general+get-222480@lists.php.net to get a copy of this message
I am trying to get a PNG created with GD to output exactly as a pre-existing PNG file on the server I have an app that is being very finicky about how it is loading images :( Within Quicktime, If I point to the PNG file directly on the server, it works. this works: $image = isset($_GET['image'])? $_GET['image']:"yolanda.png"; $image = "./".$image; $imageInfo = getimagesize($image); $mime = $imageInfo['mime']; header("Content-type:".$mime); header ("Content-Length:".filesize($image)); header ("Cache-Control:".$cacheInfo); readfile($image); If I output a PNG with GD, it does not work within Quicktime for the PC. My guess is that Quicktime for PC is very finicky when it comes to headers :( [excerpt from php script]
$im    = imagecreatefrompng($image);
imagettftext($im, $fontSize, 0, 17, 20, $color, $font, $text); imageAlphaBlending($im, true); imageSaveAlpha($im, true);
//    Output handler
function output_handler($im) { header('Content-type: image/png'); header('Content-Length: ' . strlen($im)); header('Cache-Control:no-store, no-cache'); return $im; }
//    Image output
ob_start("output_handler"); imagepng($im); ob_end_flush(); anyone know a bullet proof way to output the headers to look like a pre-existing PNG file ? many thanks in advance g

« previous php.general (#222480) next »