1Metadata-Version: 1.1 2Name: filetype 3Version: 1.0.7 4Summary: Infer file type and MIME type of any file/buffer. No external dependencies. 5Home-page: https://github.com/h2non/filetype.py 6Author: Tomas Aparicio 7Author-email: tomas@aparicio.me 8License: MIT 9Download-URL: https://github.com/h2non/filetype.py/tarball/master 10Description: filetype.py |Build Status| |PyPI| |Pyversions| |API| 11 ==================================================== 12 13 Small and dependency free `Python`_ package to infer file type and MIME 14 type checking the `magic numbers`_ signature of a file or buffer. 15 16 This is a Python port from `filetype`_ Go package. 17 18 Features 19 -------- 20 21 - Simple and friendly API 22 - Supports a `wide range`_ of file types 23 - Provides file extension and MIME type inference 24 - File discovery by extension or MIME type 25 - File discovery by kind (image, video, audio…) 26 - `Pluggable`_: add new custom type matchers 27 - `Fast`_, even processing large files 28 - Only first 261 bytes representing the max file header is required, so 29 you can just `pass a list of bytes`_ 30 - Dependency free (just Python code, no C extensions, no libmagic 31 bindings) 32 - Cross-platform file recognition 33 34 Installation 35 ------------ 36 37 :: 38 39 pip install filetype 40 41 API 42 --- 43 44 See `annotated API reference`_. 45 46 Examples 47 -------- 48 49 Simple file type checking 50 ^^^^^^^^^^^^^^^^^^^^^^^^^ 51 52 .. code-block:: python 53 54 import filetype 55 56 def main(): 57 kind = filetype.guess('tests/fixtures/sample.jpg') 58 if kind is None: 59 print('Cannot guess file type!') 60 return 61 62 print('File extension: %s' % kind.extension) 63 print('File MIME type: %s' % kind.mime) 64 65 if __name__ == '__main__': 66 main() 67 68 Supported types 69 --------------- 70 71 Image 72 ^^^^^ 73 74 - **jpg** - ``image/jpeg`` 75 - **jpx** - ``image/jpx`` 76 - **png** - ``image/png`` 77 - **gif** - ``image/gif`` 78 - **webp** - ``image/webp`` 79 - **cr2** - ``image/x-canon-cr2`` 80 - **tif** - ``image/tiff`` 81 - **bmp** - ``image/bmp`` 82 - **jxr** - ``image/vnd.ms-photo`` 83 - **psd** - ``image/vnd.adobe.photoshop`` 84 - **ico** - ``image/x-icon`` 85 - **heic** - ``image/heic`` 86 87 Video 88 ^^^^^ 89 90 - **mp4** - ``video/mp4`` 91 - **m4v** - ``video/x-m4v`` 92 - **mkv** - ``video/x-matroska`` 93 - **webm** - ``video/webm`` 94 - **mov** - ``video/quicktime`` 95 - **avi** - ``video/x-msvideo`` 96 - **wmv** - ``video/x-ms-wmv`` 97 - **mpg** - ``video/mpeg`` 98 - **flv** - ``video/x-flv`` 99 100 Audio 101 ^^^^^ 102 103 - **mid** - ``audio/midi`` 104 - **mp3** - ``audio/mpeg`` 105 - **m4a** - ``audio/m4a`` 106 - **ogg** - ``audio/ogg`` 107 - **flac** - ``audio/x-flac`` 108 - **wav** - ``audio/x-wav`` 109 - **amr** - ``audio/amr`` 110 111 Archive 112 ^^^^^^^ 113 114 - **epub** - ``application/epub+zip`` 115 - **zip** - ``application/zip`` 116 - **tar** - ``application/x-tar`` 117 - **rar** - ``application/x-rar-compressed`` 118 - **gz** - ``application/gzip`` 119 - **bz2** - ``application/x-bzip2`` 120 - **7z** - ``application/x-7z-compressed`` 121 - **xz** - ``application/x-xz`` 122 - **pdf** - ``application/pdf`` 123 - **exe** - ``application/x-msdownload`` 124 - **swf** - ``application/x-shockwave-flash`` 125 126 - **rtf** - ``application/rtf`` 127 - **eot** - ``application/octet-stream`` 128 - **ps** - ``application/postscript`` 129 - **sqlite** - ``application/x-sqlite3`` 130 - **nes** - ``application/x-nintendo-nes-rom`` 131 - **crx** - ``application/x-google-chrome-extension`` 132 - **cab** - ``application/vnd.ms-cab-compressed`` 133 - **deb** - ``application/x-deb`` 134 - **ar** - ``application/x-unix-archive`` 135 - **Z** - ``application/x-compress`` 136 - **lz** - ``application/x-lzip`` 137 138 Font 139 ^^^^ 140 141 - **woff** - ``application/font-woff`` 142 - **woff2** - ``application/font-woff`` 143 - **ttf** - ``application/font-sfnt`` 144 - **otf** - ``application/font-sfnt`` 145 146 .. _Python: http://python.org 147 .. _magic numbers: https://en.wikipedia.org/wiki/Magic_number_(programming)#Magic_numbers_in_files 148 .. _filetype: https://github.com/h2non/filetype 149 .. _wide range: #supported-types 150 .. _Pluggable: #add-additional-file-type-matchers 151 .. _Fast: #benchmarks 152 .. _pass a list of bytes: #file-header 153 .. _annotated API reference: https://h2non.github.io/filetype.py/ 154 155 .. |Build Status| image:: https://travis-ci.org/h2non/filetype.py.svg?branch=master 156 :target: https://travis-ci.org/h2non/filetype.py 157 .. |PyPI| image:: https://img.shields.io/pypi/v/filetype.svg?maxAge=2592000?style=flat-square 158 :target: https://pypi.python.org/pypi/filetype 159 .. |Pyversions| image:: https://img.shields.io/pypi/pyversions/filetype.svg?style=flat-square 160 :target: https://pypi.python.org/pypi/filetype 161 .. |API| image:: https://img.shields.io/badge/api-docs-green.svg 162 :target: https://h2non.github.io/filetype.py 163 164Keywords: file libmagic magic infer numbers magicnumbers discovery mime type kind 165Platform: any 166Classifier: Development Status :: 5 - Production/Stable 167Classifier: Environment :: Console 168Classifier: Environment :: Web Environment 169Classifier: Intended Audience :: Developers 170Classifier: Intended Audience :: System Administrators 171Classifier: License :: OSI Approved :: MIT License 172Classifier: Operating System :: OS Independent 173Classifier: Programming Language :: Python :: 3 174Classifier: Programming Language :: Python :: 3.5 175Classifier: Programming Language :: Python :: 3.6 176Classifier: Programming Language :: Python :: 3.7 177Classifier: Programming Language :: Python :: 3.8 178Classifier: Topic :: System 179Classifier: Topic :: System :: Filesystems 180Classifier: Topic :: Utilities 181