@character-foundry/media
v0.1.3
Published
Image processing utilities for character cards
Readme
@character-foundry/media
Image format detection, dimensions, and thumbnail generation.
Installation
npm install @character-foundry/mediaFeatures
- Format detection - PNG, JPEG, WebP, GIF, AVIF
- Dimension extraction - Width/height without full decode
- Thumbnail generation - Resize images for previews
- Magic number detection - Reliable format identification
Quick Start
import {
detectImageFormat,
getImageDimensions,
generateThumbnail,
} from '@character-foundry/media';
// Detect format from bytes
const format = detectImageFormat(buffer);
// 'png' | 'jpeg' | 'webp' | 'gif' | 'avif' | null
// Get dimensions without full decode
const dims = getImageDimensions(buffer);
// { width: 512, height: 512 }
// Generate thumbnail
const thumb = await generateThumbnail(buffer, {
maxWidth: 128,
maxHeight: 128,
format: 'webp',
quality: 80,
});Documentation
See docs/media.md for full API documentation.
License
MIT
