function img_get_mime_type($file)
{
$mime_types = array("gif" => "image/gif", "png" => "image/png", "jpeg" => "image/jpg", "jpg" => "image/jpg",);
$file_exp = explode('.', $file);
$extension = strtolower(end($file_exp));
if (array_key_exists($extension, $mime_types)) {
return $mime_types[$extension];
}
return "application/force-download";
}
$mime = img_get_mime_type($image);
header('Content-type: ' . $mime);
fpassthru(fopen($image, 'rb'));