UNPKG

taglib-wasm

Version:

TagLib-Wasm is the universal tagging library for TypeScript/JavaScript platforms: Browsers, Node.js, Deno, Bun, Cloudflare Workers, and Electron apps

46 lines (45 loc) 1.25 kB
const MIME_TYPES = { "jpg": "image/jpeg", "jpeg": "image/jpeg", "png": "image/png", "gif": "image/gif", "webp": "image/webp", "bmp": "image/bmp" }; function detectMimeType(path, override) { if (override) return override; const ext = path.split(".").pop()?.toLowerCase(); return MIME_TYPES[ext ?? ""] ?? "image/jpeg"; } const PICTURE_TYPE_FILENAMES = { Other: "other", FileIcon: "file-icon", OtherFileIcon: "other-file-icon", FrontCover: "front-cover", BackCover: "back-cover", LeafletPage: "leaflet", Media: "media", LeadArtist: "lead-artist", Artist: "artist", Conductor: "conductor", Band: "band", Composer: "composer", Lyricist: "lyricist", RecordingLocation: "recording-location", DuringRecording: "during-recording", DuringPerformance: "during-performance", MovieScreenCapture: "screen-capture", ColouredFish: "fish", Illustration: "illustration", BandLogo: "band-logo", PublisherLogo: "publisher-logo" }; function generatePictureFilename(picture, index) { const typeName = PICTURE_TYPE_FILENAMES[picture.type] ?? "other"; const ext = picture.mimeType.split("/")[1] ?? "jpg"; return `${typeName}-${index + 1}.${ext}`; } export { detectMimeType, generatePictureFilename };