note 61027 deleted from ref.image by betz
| From: | betz@php.net | Date: | Sun, 05 Feb 2006 12:41:39 +0000 |
| Subject: | note 61027 deleted from ref.image by betz | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-103029@lists.php.net to get a copy of this message | ||
Note Submitter: jab
----
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);
}
?>