Files
dragonsstash/worker/src/archive/extract-image.ts
admin ab558e00f5 feat: add preview management, channel controls, invite polish, and recovery
- Auto-extract preview images from ZIP/RAR/7z archives during ingestion
- Upload custom preview images via package drawer
- Select preview from archive contents with on-demand extraction UI
- Manually add Telegram channels by t.me link, username, or invite link
- Invite code UX: bulk create, copy link, usage tracking, delete confirm
- Incomplete upload recovery: verify dest messages on worker startup
- Rebuild package DB by scanning destination channel with live progress

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-22 00:09:59 +01:00

34 lines
814 B
TypeScript

import path from "path";
const IMAGE_EXTENSIONS = new Set(["jpg", "jpeg", "png", "webp", "gif", "bmp"]);
/**
* Check if a file path within an archive is an image.
*/
export function isImageFile(filePath: string): boolean {
const ext = path.extname(filePath).toLowerCase().slice(1);
return IMAGE_EXTENSIONS.has(ext);
}
/**
* Get the MIME type for an image file extension.
*/
export function getImageMimeType(filePath: string): string {
const ext = path.extname(filePath).toLowerCase().slice(1);
switch (ext) {
case "jpg":
case "jpeg":
return "image/jpeg";
case "png":
return "image/png";
case "webp":
return "image/webp";
case "gif":
return "image/gif";
case "bmp":
return "image/bmp";
default:
return "application/octet-stream";
}
}