ok , When i try to execute this routine , retrieves GD Error :
Function foo ()
{
$file_name = 'image1.jpg';
$type = 'image/jpeg';
drupal_set_header('Content-Type:'.$type);
drupal_set_header('Content-Length: ' . filesize($file_name));
readfile($file_name);
}
Error :
The image http://192.168.1.190/parsegard/trackback/check/perm?pic=sites/default/files/imagecache/large/content_types/food_nutrition/2470/image1.jpg becuase it contains errors.
You should make absolutely sure there is no other output on the page, not even leading or trailing spaces. This is the most common cause of this kind of error. Also turn off error outputting, log errors to a file instead. PHP errors can easily cause binary output to be corrupted too.
Locating the source of the unwanted output would be the optimal solution, but if you absolutely can't and just want it to work you could use output control as a workaround. Call ob_start()
at the absolute beginning of your script (no preceding whitespace or other PHP code allowed), and ob_end_clean()
at the absolute end of your script. Then place a call to ob_clean()
at the beginning of your image outputting function, and a call to ob_flush()
at the end of the function.