Function getBase64ImageMIMEType

get the mime type of a base64 image

const img_uri = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAD..."
const img_mime = getBase64ImageMIMEType(img_uri) // == "image/png"
  • Parameters

    • str:
          | `data:image/gif;base64,${string}`
          | `data:image/jpeg;base64,${string}`
          | `data:image/jpg;base64,${string}`
          | `data:image/png;base64,${string}`
          | `data:image/svg+xml;base64,${string}`
          | `data:image/webp;base64,${string}`

    Returns
        | "image/gif"
        | "image/jpeg"
        | "image/jpg"
        | "image/png"
        | "image/svg+xml"
        | "image/webp"