[PHP]判斷圖片檔格式

要判斷圖片的格式,可以簡單的利用exif_imagetype()這個函式來判斷

/**
* $filename : 檔案路徑
*/
int exif_imagetype (string $filename)

//回傳值代表意義:
//1   IMAGETYPE_GIF
//2   IMAGETYPE_JPEG
//3   IMAGETYPE_PNG
//4   IMAGETYPE_SWF
//5   IMAGETYPE_PSD
//6   IMAGETYPE_BMP
//7   IMAGETYPE_TIFF_II (intel byte order)
//8   IMAGETYPE_TIFF_MM (motorola byte order)
//9   IMAGETYPE_JPC
//10  IMAGETYPE_JP2
//11  IMAGETYPE_JPX
//12  IMAGETYPE_JB2
//13  IMAGETYPE_SWC
//14  IMAGETYPE_IFF
//15  IMAGETYPE_WBMP
//16  IMAGETYPE_XBM
//17  IMAGETYPE_ICO