GitHub - h2non/filetype.py: Small, dependency-free, fast Python package to infer binary file types checking the magic numbers signature (original) (raw)

Small and dependency free Python package to infer file type and MIME type checking the magic numbers signature of a file or buffer.

This is a Python port from filetype Go package.

Features

Installation

pip install filetype

API

See annotated API reference.

Examples

Simple file type checking

import filetype

def main(): kind = filetype.guess('tests/fixtures/sample.jpg') if kind is None: print('Cannot guess file type!') return

print('File extension: %s' % kind.extension)
print('File MIME type: %s' % kind.mime)

if name == 'main': main()

Supported types

Image

Video

Audio

Archive

Document

Font

Application

About

Small, dependency-free, fast Python package to infer binary file types checking the magic numbers signature

Topics

Resources

Readme

License

MIT license

Activity

Stars

746 stars

Watchers

12 watching

Forks

118 forks