note 89609 added to function.imagepng

From: Date: Mon, 16 Mar 2009 20:11:51 +0000
Subject: note 89609 added to function.imagepng
Groups: php.notes 
Request: Send a blank email to php-notes+get-152006@lists.php.net to get a copy of this message
To change the background of a 24-bit PNG for graceful degradation in IE6, the PNG file needs a bKGD chunk: <?php // insert a BKGD chunk into the PNG file for graceful image degradation in IE6 $bgColor = array(250, 250, 250); $pngData = bin2hex(file_get_contents($filename)); $idatMarker = '200049444154'; $bkgdMarker = '624b4744'; $bkgdChunk = '0006' . $bkgdMarker; foreach ($bgColor as $bit) { $bkgdChunkData .= '00' . dechex($bit); } $bkgdChunk .= $bkgdChunkData; $bkgdChunk .= dechex(crc32(pack('H*', $bkgdMarker . $bkgdChunkData))) . '0000'; $parsed = explode($idatMarker, $pngData, 2); // split file by first 'IDAT' chunk $pngData = pack('H*', $parsed[0] . $bkgdChunk . $idatMarker . $parsed[1]); file_put_contents($cachedFilename, $pngData); ?> ---- Server IP: 190.54.16.132 Probable Submitter: 200.120.29.205 ---- Manual Page -- http://www.php.net/manual/en/function.imagepng.php Edit -- https://master.php.net/note/edit/89609 Del: integrated -- https://master.php.net/note/delete/89609/integrated Del: useless -- https://master.php.net/note/delete/89609/useless Del: bad code -- https://master.php.net/note/delete/89609/bad+code Del: spam -- https://master.php.net/note/delete/89609/spam Del: non-english -- https://master.php.net/note/delete/89609/non-english Del: in docs -- https://master.php.net/note/delete/89609/in+docs Del: other reasons-- https://master.php.net/note/delete/89609 Reject -- https://master.php.net/note/reject/89609 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#152006) next »