FileType effect
A small, free-to-open Python development package used primarily to obtain file types.
FileType Supported versions:
Python2/python3
FileType Installation:
Pip Install filetype
FileType Functional Features
? Simple and Friendly API
Support wide range file types
? provide file extension and MIME type judgment
? file MIME type extension new
? Through files (image, video, audio ...) ) Simple analysis
? Pluggable: Add a match for a new custom type
Fast, even when dealing with large files
? Only the top 261 bytes are required to represent the maximum file header, so you can pass a single byte
? dependent on freedom (just Python code, no extensions for C, no libmagic bindings)
? cross-platform file recognition
code example:
ImportfiletypedefMain (): Kind= Filetype.guess ('tests/fixtures/sample.jpg') ifKind isNone:Print('cannot guess file type!') return Print('File Extension:%s'%kind.extension)Print('File MIME Type:%s'%kind.mime)if __name__=='__main__': Main ()
Type of support
Image
? Jpg–image/jpeg
? Png–image/png
? Gif–image/gif
? Webp–image/webp
? Cr2–image/x-canon-cr2
? Tif–image/tiff
? Bmp–image/bmp
? Jxr–image/vnd.ms-photo
? Psd–image/vnd.adobe.photoshop
? Ico–image/x-icon
Video
? Mp4–video/mp4
? m4v–video/x-m4v
? Mkv–video/x-matroska
? Webm–video/webm
? Mov–video/quicktime
? Avi–video/x-msvideo
? Wmv–video/x-ms-wmv
? Mpg–video/mpeg
? flv–video/x-flv
Audio
? Mid–audio/midi
? Mp3–audio/mpeg
? m4a–audio/m4a
? Ogg–audio/ogg
? Flac–audio/x-flac
? Wav–audio/x-wav
? Amr–audio/amr
Data base
? Epub–application/epub+zip
? Zip–application/zip
? Tar–application/x-tar
? Rar–application/x-rar-compressed
? Gz–application/gzip
? Bz2–application/x-bzip2
? 7z–application/x-7z-compressed
? Xz–application/x-xz
? Pdf–application/pdf
? Exe–application/x-msdownload
? Swf–application/x-shockwave-flash
? Rtf–application/rtf
? Eot–application/octet-stream
? Ps–application/postscript
? Sqlite–application/x-sqlite3
? Nes–application/x-nintendo-nes-rom
? Crx–application/x-google-chrome-extension
? Cab–application/vnd.ms-cab-compressed
? Deb–application/x-deb
? Ar–application/x-unix-archive
? Z–application/x-compress
? Lz–application/x-lzip
Font
? Woff–application/font-woff
? Woff2–application/font-woff
? Ttf–application/font-sfnt
? Otf–application/font-sfnt
Python library uses filetype to accurately determine file types