note 61027 added to ref.image

From: Date: Tue, 24 Jan 2006 02:02:47 +0000
Subject: note 61027 added to ref.image
Groups: php.notes 
Request: Send a blank email to php-notes+get-102321@lists.php.net to get a copy of this message
If you are developing on/for a Windows platform, read this and you might save yourself some time. The output using 'imagejpeg' and 'imagepng' (other file formats might also be affected) produce LARGE file sizes even if you use 'imagetruecolortopalette' to reduce the number of colors. During tests, image files sizes were 3 to 4 times larger when generated on a Windows platform than on Linux. (PHP Version 4.4.0). Sample JPEG test result: Original image size: 11.68 KB Output image size on Linux platform: 8.06 KB Output image size on Windows platform: 27.51 KB I strongly recommend that you do NOT use these functions if your server run on a Windows platform and you want to generate multiple images "on-the-fly" for a web site. <?php /** * Test function to compare png file size * * @param $file absolute path to image file * @return void */ function test_png($file) { $image = imagecreatefrompng($file); imagetruecolortopalette($image, true, 256); header("Content-type: image/png"); imagepng($image); } /** * Test function to compare jpeg file size * * @param $file absolute path to image file * @return void */ function test_jpeg($file) { $image = imagecreatefromjpeg($file); imagetruecolortopalette($image, true, 256); header("Content-type: image/jpeg"); imagejpeg($image, "", 60); } ?> ---- Server IP: 85.116.0.130 Probable Submitter: 217.40.185.132 ---- Manual Page -- http://www.php.net/manual/en/ref.image.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+61027 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+61027&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+61027&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+61027&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+61027&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+61027&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+61027&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+61027&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+61027&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#102321) next »