byteamagic

Detect MIME types and file formats from PostgreSQL bytea values

Overview

PackageVersionCategoryLicenseLanguage
pg_byteamagic0.2.4UTILBSD 2-ClauseC
IDExtensionBinLibLoadCreateTrustRelocSchema
4275byteamagicNoYesNoYesNoYes-

Extension name is byteamagic; package name is pg_byteamagic.

Version

TypeRepoVersionPG VerPackageDeps
EXTPIGSTY0.2.41817161514pg_byteamagic-
RPMPIGSTY0.2.41817161514pg_byteamagic_$v-
DEBPIGSTY0.2.41817161514postgresql-$v-pg-byteamagic-
OS / PGPG18PG17PG16PG15PG14
el8.x86_64
el8.aarch64
el9.x86_64
el9.aarch64
el10.x86_64
el10.aarch64
d12.x86_64
PIGSTY 0.2.4
PIGSTY 0.2.4
PIGSTY 0.2.4
PIGSTY 0.2.4
PIGSTY 0.2.4
d12.aarch64
PIGSTY 0.2.4
PIGSTY 0.2.4
PIGSTY 0.2.4
PIGSTY 0.2.4
PIGSTY 0.2.4
d13.x86_64
PIGSTY 0.2.4
PIGSTY 0.2.4
PIGSTY 0.2.4
PIGSTY 0.2.4
PIGSTY 0.2.4
d13.aarch64
PIGSTY 0.2.4
PIGSTY 0.2.4
PIGSTY 0.2.4
PIGSTY 0.2.4
PIGSTY 0.2.4
u22.x86_64
PIGSTY 0.2.4
PIGSTY 0.2.4
PIGSTY 0.2.4
PIGSTY 0.2.4
PIGSTY 0.2.4
u22.aarch64
PIGSTY 0.2.4
PIGSTY 0.2.4
PIGSTY 0.2.4
PIGSTY 0.2.4
PIGSTY 0.2.4
u24.x86_64
PIGSTY 0.2.4
PIGSTY 0.2.4
PIGSTY 0.2.4
PIGSTY 0.2.4
PIGSTY 0.2.4
u24.aarch64
PIGSTY 0.2.4
PIGSTY 0.2.4
PIGSTY 0.2.4
PIGSTY 0.2.4
PIGSTY 0.2.4

Build

You can build the RPM / DEB packages for pg_byteamagic using pig build:

pig build pkg pg_byteamagic         # build RPM / DEB packages

Install

You can install pg_byteamagic directly. First, make sure the PGDG and PIGSTY repositories are added and enabled:

pig repo add pgsql -u          # Add repo and update cache

Install the extension using pig or apt/yum/dnf:

pig install pg_byteamagic;          # Install for current active PG version
pig ext install -y pg_byteamagic -v 18  # PG 18
pig ext install -y pg_byteamagic -v 17  # PG 17
pig ext install -y pg_byteamagic -v 16  # PG 16
pig ext install -y pg_byteamagic -v 15  # PG 15
pig ext install -y pg_byteamagic -v 14  # PG 14
dnf install -y pg_byteamagic_18       # PG 18
dnf install -y pg_byteamagic_17       # PG 17
dnf install -y pg_byteamagic_16       # PG 16
dnf install -y pg_byteamagic_15       # PG 15
dnf install -y pg_byteamagic_14       # PG 14
apt install -y postgresql-18-pg-byteamagic   # PG 18
apt install -y postgresql-17-pg-byteamagic   # PG 17
apt install -y postgresql-16-pg-byteamagic   # PG 16
apt install -y postgresql-15-pg-byteamagic   # PG 15
apt install -y postgresql-14-pg-byteamagic   # PG 14

Create Extension:

CREATE EXTENSION byteamagic;

Usage

Sources: GitHub repo, byteamagic docs Extension name: byteamagic The CSV package row is pg_byteamagic; the upstream extension name is byteamagic.

byteamagic uses libmagic on bytea values to identify the MIME type and the file type text inside PostgreSQL.

CREATE EXTENSION byteamagic;
SELECT byteamagic_mime(data);
SELECT byteamagic_text(data);

Functions

  • byteamagic_mime(bytea) returns the MIME type as text and matches file --mime-type.
  • byteamagic_text(bytea) returns a human-readable file type description and matches file.

Notes

  • The extension needs PostgreSQL development headers and the libmagic development package.
  • It is intended for databases that store files or blobs in bytea and need in-database type detection.

Last Modified 2026-04-14: update extension catalog (29617e5)