I have a function to make thumbnail of a url image on fly! I always pass to this functions images with type jpg, but the problem appears when I pass an image with ".jpg" extension. but when i try to get its mime type, i found that's "application/octet-stream" .. in this php page, this mime type refers to one of
IMAGETYPE_JPC,IMAGETYPE_JPX,IMAGETYPE_JB2
what I need to modify my function to handle this mime type ??
notice ^^^^^^
function thumb($path,$width,$height) // $path => image url
{
$file_dimensions = getimagesize($path);
$file_type = image_type_to_mime_type($file_dimensions[2]);
list($Cwidth, $Cheight) = getimagesize($path);
if ($file_type=='image/jpeg'||$file_type=='image/pjpeg'){
// Load
$thumb = imagecreatetruecolor($width, $height);
$source = imagecreatefromjpeg($path);
// Resize
imagecopyresized($thumb, $source, 0, 0, 0, 0, $width, $height, $Cwidth, $Cheight);
header('Content-Type: image/jpeg');
imagejpeg($thumb);
}
else if ($file_type=='application/octet-stream')
{
// ^^^^^ what I should write here
}
else
{
echo "Not supported type";
}
}