# ahupp/python-magic

A python wrapper for libmagic

Repository: https://github.com/ahupp/python-magic
Canonical: https://ross.abutalabs.com/products/python-magic
Language: Python
License: NOASSERTION
License Family: other
Last push: 2026-07-20T17:21:33+00:00

## Health v2 (maintenance only)
Score: 74/100 (v2, computed 2026-09-03T02:20:16.233290+00:00)
- activity 93, release rhythm 35, longevity 100
- inputs: {"age_days": 5999, "days_push": 44, "days_rel": null, "gap_med": null, "n_releases_24m": 0}
- flags: no_releases, no_license
- formula: round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10)

## Adoption (not part of the score)
Stars 2917, forks 304 (observed 2026-08-28T04:07:30.039157+00:00)

## What it is
python-magic is a Python wrapper around the libmagic C library, the same engine behind the Unix `file` command. It identifies file types and MIME types by inspecting file headers rather than extensions.

## Use cases
- detect the real file type of an uploaded file
- get the mime type of a file in python
- validate that uploads are actually pdfs or images
- identify file type from a byte buffer
- detect content type without relying on file extensions

## When to choose
- you need reliable, header-based file type or MIME detection in Python
- you want the same identification behavior as the Unix `file` command
- you are validating user-uploaded files by content

## When to avoid
- you cannot install native libmagic dependencies in your environment
- you only need simple extension-based checks
- you need pure-Python file type detection without C library bindings

## Facets
- artifact type: library
- maturity: stable
- function: file-system, developer-tools
- domain: files, developer-tools
- platform: python, windows, cross-platform
- tags: libmagic, file-type-detection, mime-type, wrapper, linux, macos

## Member repositories
- ahupp/python-magic (main) score 74

## Provenance
- Observed fields: from GitHub, fetched 2026-08-28T04:07:30.039157+00:00.
- Health v2: computed from the inputs above; adoption is never an input.
- Inferred fields (summary, facets, guidance): AI-extracted, prompt v1, taxonomy v1, on 2026-08-30T07:34:04.490856+00:00, confidence not recorded.
  - readme: https://github.com/ahupp/python-magic (fetched 2026-08-28T04:07:30.039157+00:00, sha da215a936a40)
  - registry_pypi: https://pypi.org/pypi/python-magic/json (fetched 2026-08-29T09:49:13.785140+00:00, sha 49c719c87818)
- Data as of 2026-08-30T08:39:29.467469+00:00.
