I am reading images from minimum of 1x1
pixel to maximum of 1600x1600
pixels. I have written three PHP methods and are working perfectly.
// using FGC
function output_fgc($filename)
{
header("Content-Type: image/png");
echo file_get_contents($filename);
}
// using fopen
function output_fp($filename)
{
$handle = fopen($filename, 'rb');
header("Content-Type: image/png");
header("Content-Length: " . filesize($filename));
fpassthru($handle);
}
// using GD
function output_gd($filename)
{
$im = imagecreatefrompng($filename);
header('Content-Type: image/png');
imagepng($im);
imagedestroy($im);
}
It seems performance is same for all methods. Just want to know which uses more server resources? Are there any better methods than this? Thanks in advance.