function detectImageMime
detectImageMime(data: Uint8Array): string | null

Returns the MIME type of a JPEG, PNG, GIF or WebP image from its magic bytes, or null for anything else. These four are the only image types accepted anywhere. The type the browser declared is never trusted, since the file is later served with the type found here.

Parameters

Return Type

string | null

Usage

import { detectImageMime } from "api/lib/upload.ts";