$npx skillfedfor your agent

python-magic-bin

File type identification using libmagic binary package

With conditionsPyPI UtilitiesReleased Oct 2017204.6K downloads / moMITPlatform wheel

Decision gist · record as of 2026-08-14

platform wheels — python_magic_bin-0.4.14-py2.py3-none-macosx_10_6_intel.whl · python_magic_bin-0.4.14-py2.py3-none-win32.whl · python_magic_bin-0.4.14-py2.py3-none-win_amd64.whl
v0.4.14 · released 2017-10-02

Yes, if you need reliable file-type detection and want to avoid installing libmagic separately on Windows or macOS. The package is stable with no known vulnerabilities. However, verify compatibility with your Python version; the fork's last release was 2017-10-02 and the project is dormant.AI-flagged interpretation of the facts on this page — verify before relying

Before you install

  • On Windows, you may need to manually provide libmagic DLLs (magic1.dll, regex2.dll, zlib1.dll) and the magic database file; 32-bit and 64-bit builds must match your Python installation.
  • Medium install friction due to platform-specific binary wheels; the package is dormant (last release 2017-10-02, last commit 2023-11-21) but carries no known vulnerabilities.

License · maintenance · safety

MIT (permissive) — MIT license is permissive; you may use, modify, and distribute this package freely in commercial and private projects with minimal restrictions.

last release 2017-10-02 (3238 days) · last repo commit 2023-11-21 · 33 stars

0 known vulnerabilities (OSV.dev, 2026-08-14) · 204,568 downloads/mo, #9,604 on PyPI

Verify before relying

pip install python-magic-bin

import magic
result = magic.from_file("testdata/test.pdf")
print(result)  # 'PDF document, version 1.2'

mime_type = magic.from_file("testdata/test.pdf", mime=True)
print(mime_type)  # 'application/pdf'
  • Whether the package's dormancy (no releases since 2017-10-02) affects compatibility with modern Python versions or libmagic APIs.
  • Current status of the upstream python-magic library and whether this fork remains the recommended binary-packaged alternative.
  • Actual adoption and usage patterns given the long time since last release.
Same gist for agents: .md · .json

What it is and what it does

python-magic-bin is a Python wrapper around libmagic, the file-type identification library that powers the Unix `file` command. It identifies files by examining their headers against a predefined database of file signatures, returning human-readable descriptions or MIME types. The package is a fork of python-magic that bundles pre-compiled libmagic binaries for Windows, macOS, and Linux, eliminating the need to install libmagic separately on those platforms.

You can use it two ways: the simple functional API (magic.from_file, magic.from_buffer) for quick file identification, or the Magic class for finer control over options like MIME mode, compression detection, and character encoding. The package has no runtime dependencies beyond the bundled libmagic binaries, making it straightforward to integrate into file-processing pipelines, content-type detection systems, or validation workflows.

Use it for

  • Detect file types in upload handlers to validate user-submitted files without relying on extensions.
  • Identify MIME types for web servers or APIs serving files with correct Content-Type headers.
  • Analyze compressed archives by detecting both the outer format and decompressed content type.
  • Validate binary file integrity by confirming expected file signatures before processing.
  • Build content-aware file routing or filtering systems that classify files by their actual type.

Worth the install?

AI-flagged interpretation of the facts on this page. Verify before relying on it.

With conditions

Yes, if you need reliable file-type detection and want to avoid installing libmagic separately on Windows or macOS.

The package is stable with no known vulnerabilities. However, verify compatibility with your Python version; the fork's last release was 2017-10-02 and the project is dormant.

Install

python-magic-bin on PyPI

Before you install

Medium install friction due to platform-specific binary wheels; the package is dormant (last release 2017-10-02, last commit 2023-11-21) but carries no known vulnerabilities.

On Windows, you may need to manually provide libmagic DLLs (magic1.dll, regex2.dll, zlib1.dll) and the magic database file; 32-bit and 64-bit builds must match your Python installation.

License in practice

MIT license is permissive; you may use, modify, and distribute this package freely in commercial and private projects with minimal restrictions.

Quickstart

pip install python-magic-bin

import magic
result = magic.from_file("testdata/test.pdf")
print(result)  # 'PDF document, version 1.2'

mime_type = magic.from_file("testdata/test.pdf", mime=True)
print(mime_type)  # 'application/pdf'

Verify before relying

  • Whether the package's dormancy (no releases since 2017-10-02) affects compatibility with modern Python versions or libmagic APIs.
  • Current status of the upstream python-magic library and whether this fork remains the recommended binary-packaged alternative.
  • Actual adoption and usage patterns given the long time since last release.

Package facts

LicenseMIT permissive
Python supportNot specified
Install frictionMedium. Platform-specific wheel
Runtime dependenciesNone
MaintenanceDormant 3,238 days since the last release
Last repo commit
First released
Downloads204,568 / month, #9,604 on PyPI 30-day window, as of 2026-08-14
Known vulnerabilitiesNone known OSV.dev, checked 2026-08-14
Classifiers
Intended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseProgramming Language :: PythonProgramming Language :: Python :: 2Programming Language :: Python :: 3

Evidence: python_magic_bin-0.4.14-py2.py3-none-macosx_10_6_intel.whl; python_magic_bin-0.4.14-py2.py3-none-win32.whl; python_magic_bin-0.4.14-py2.py3-none-win_amd64.whl

Tags

Capabilities
file type detection pythonmime type identificationlibmagic python wrapperfile magic number detectionbinary file type recognitionfile header analysismagic database file identification
Topics
file-identificationmime-type-detectionbinary-analysis
PyPI keywords
mimemagicfilebinary

Let your AI agent find packages like this

Example. Real query, live index.

You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.

wish › “mime type identification”

  • python-magic-binIdentifies file types by examining file headers using libmagic,…
  • python-magicIdentifies file types by reading file headers and checking them…
  • typecodeDetects file types and MIME types using libmagic and Pygments, with…

Give your agent the search over MCP, or paste the wish link into any chat.

More Utilities packages

idna Worth it
PyPI · Python Modules · released Jun 2026

Converts domain names between Unicode and ASCII-compatible encoding (Punycode) according to IDNA 2008 and Unicode Technical Standard 46, with security validation and broader script coverage than the standard library.

Install it if you work with internationalized domain names, need to validate domains, or use HTTP clients that depend on it transitively.

BSD-3-Clausepure Python · 3.9+
1.8Bdownloads / mo
charset-normalizer Worth it
PyPI · Utilities · released Aug 2026

Detects and normalizes text encoding from unknown or ambiguous sources, supporting all IANA character sets that Python's core library provides codecs for, with the ability to register custom codecs.

permissive licensepure Python · 3.7+
1.7Bdownloads / mo
setuptools Worth it
PyPI · Python Modules · released Aug 2026

Setuptools is a Python build backend and package management tool that handles building, distributing, and installing Python packages, including support for C/C++ extension modules.

MITpure Python · 3.10+
1.6Bdownloads / mo
pluggy Worth it
PyPI · Libraries · released May 2025

Pluggy provides a plugin system that lets you define hook specifications and register implementations to be called in sequence, enabling extensible Python applications without tight coupling.

Install it if you're building an extensible application or framework.

MITpure Python · 3.9+aging
1.3Bdownloads / mo
Pygments Worth it
PyPI · Utilities · released Mar 2026

Pygments is a syntax highlighter that colorizes source code and text in over 500 languages and formats, outputting to HTML, LaTeX, RTF, SVG, images, or ANSI terminal sequences.

Install it if you need to display or transform source code.

BSD-2-Clausepure Python · 3.9+
1.3Bdownloads / mo
six With conditions
PyPI · Libraries · released Dec 2024

Six provides utility functions to write Python code that runs on both Python 2.7 and Python 3.3+, smoothing over language differences between the two versions.

MITpure Python
1.2Bdownloads / mo

See also puremagic · pylibmagic · python-magic · libmagic · cigam · file-magic · magika · polyfile-weave · filetype · typecode-libmagic