その場でURL画像のサムネイルを作成する機能があります!この関数には常にタイプ jpg の画像を渡しますが、「.jpg」拡張子の画像を渡すと問題が発生します。しかし、その MIME タイプを取得しようとすると、「application/octet-stream」であることがわかりました。このphp ページでは、この MIME タイプは次のいずれかを参照しています。
IMAGETYPE_JPC,IMAGETYPE_JPX,IMAGETYPE_JB2
この MIME タイプを処理するために関数を変更する必要があるのは??
お知らせ^^^^^^
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";
}
}