Image Converter — Scope & Feature Spec
Overview
AuctionSnap ships two image-conversion surfaces. Both run entirely client-side in the browser (HTML5 Canvas) — no server round-trip is required for the conversion itself. The simpler one uploads the result straight into the Media Library; the full one is a drag-and-drop batch converter supporting HEIC, DNG/RAW, and folder drops.
Primary Goal
Turn any incoming image format (HEIC from iPhones, DNG/RAW from cameras, WebP, PNG, GIF, BMP, SVG) into a clean JPG/PNG/WebP at a chosen quality and resolution — so auction images are uniform, small, and platform-ready before they enter the library.
Pages & Routes
- ImageFormatConverter —
/ImageFormatConverter — the full-featured batch converter (HEIC, DNG/RAW, folder drop, quality/resolution/EXIF controls, Media Library picker). This is the primary converter.
- ImageConverter —
/ImageConverter — the simple single-file "anything → JPEG" converter that saves the result into the Media Library.
Source Files (included in the ZIP)
Frontend — Pages
src/pages/ImageFormatConverter.jsx — full batch converter (the main one).
src/pages/ImageConverter.jsx — simple single-file converter page wrapper.
Frontend — Components
src/components/ImageConverter.jsx — the simple converter widget (canvas → JPEG → upload → MediaLibrary.create).
Frontend — Shared Libs
src/lib/dngConverter.js — DNG/RAW file-type detection (isDngOrRaw).
Backend Functions
base44/functions/uploadImage/entry.ts — uploads a base64 image to storage (used by the simple converter to persist the result).
Entities
base44/entities/MediaLibrary.jsonc — the simple converter saves its output as a MediaLibrary record.
Features
ImageFormatConverter (the main converter)
- Drag & drop — drop individual files or a whole folder (
webkitdirectory).
- Browse Files / Browse Folder / Media Library — three ways to add images.
- Supported inputs — JPG, PNG, WebP, HEIC, HEIF, DNG, RAW, CR2, CR3, NEF, ARW, ORF, RW2, PEF, SRW.
- HEIC handling — auto-decoded via
heic2any for an instant preview; re-encoded to the chosen target format on convert.
- DNG/RAW handling — decoded via
createImageBitmap + canvas when the browser supports it; otherwise shown with a 📷 placeholder and the raw file is still offered for download.
- HEVC/video detection — HEVC/MOV/MP4 files are detected and listed with a download link + a note to use HandBrake/FFmpeg (browser-based H.265→H.264 needs hardware support).
- Target format — JPG, PNG, or WebP.
- Quality presets — Low (60%), Medium (80%), High (92%), Max (100%).
- Resolution presets — Original (100%), 75%, 50%, 25%.
- EXIF control — Preserve or Strip EXIF metadata (privacy).
- Selection — click-to-toggle, select-all/deselect-all, auto-selects newly added files.
- Per-file tile — preview, format badge (HEIC / RAW ext), size in KB, remove button.
- Convert — processes all selected files through canvas at the chosen format/quality/resolution; JPG gets a white background fill for transparency.
- Results grid — shows each converted file with before/after size, dimensions, and a per-file download button.
- Download All — downloads every converted file.
- 100% client-side — no upload, no credits, no server call for the conversion itself.
ImageConverter (the simple converter)
- Single file — pick one image (JPEG, PNG, WebP, GIF, BMP, SVG).
- Quality slider — 10–100%.
- Canvas conversion — decodes the image, draws to canvas, exports as JPEG at the chosen quality.
- Upload + save — uploads the JPEG via the
uploadImage backend function and creates a MediaLibrary record (category collectibles, source upload).
- Result card — shows original → converted size and a link to the Library Manager to rename/organize.
Data Flow
ImageFormatConverter (batch):
drop/browse/folder/Media Library → addFiles (HEIC→heic2any, DNG→createImageBitmap)
→ select files → choose format/quality/resolution/EXIF
→ canvas.toBlob (client-side) → results grid → download (no upload)
ImageConverter (simple):
pick file → canvas → JPEG blob → uploadImage (backend) → MediaLibrary.create → Library Manager
Known Behaviors / Decisions
- All conversion is client-side canvas-based — no AI, no credits, no server processing.
- JPG output always gets a white background fill so transparent PNGs/WebPs don't turn black.
- HEIC preview is generated immediately on add (so the grid isn't blank); the final target-format re-encode happens on Convert.
- DNG/RAW decode depends on browser support; unsupported RAW files show a placeholder but are still downloadable.
- The simple converter saves into the Media Library; the batch converter does not save — it only downloads.
- EXIF stripping is a UI toggle; canvas re-encoding inherently drops most metadata, so "Strip EXIF" is the effective default behavior of the pipeline.
Dependencies
- Entities: MediaLibrary (simple converter only)
- Backend functions: uploadImage (simple converter only)
- Libs: dngConverter (
isDngOrRaw)
- Packages: heic2any (HEIC decode), react-query, lucide-react, shadcn/ui