← Image Tools

Image Tools: formats & verification

# Desynk Image Tools — implementation and verification

Main route: `/basic-tools/image`. Basic Tools has one new **Image** sidebar entry; its homepage contains all 14 cards. The old `/basic-tools/image-tools` route opens the same directory. Existing standalone Background Remover and Upscaler links remain usable. No separate site or processing backend was created.

| Tool route suffix | Implemented functionality | Verification |
| --- | --- | --- |
| `photo-editor` | Local canvas editor; crop/resize/rotate/flip/position; brightness, contrast, saturation, exposure approximation, temperature, grayscale, sepia, box blur, convolution sharpening, alpha opacity; text/font/size/color/alignment/letter spacing/rotation; shapes, lines, arrows, glyph stickers, border/frame and image overlays; selected-layer move/resize/order/delete; undo/redo/reset | Actual exported pixels tested for all ten filters, text, shapes, overlay/watermark and frames. Browser drag, undo/redo, fonts and mobile UI not verified |
| `compress` | Batch JPG/PNG/WebP re-encoding; three quality presets; optional maximum side; best-effort lossy target size; accurate input/output sizes; individual outputs and ZIP | Actual JPEG compression and PNG re-encoding tested; size reduction and target-result flag checked |
| `resize` | Pixel dimensions, percentage, aspect-lock, presets, fit/fill/stretch, live reduced preview and full-size export | Exact dimensions and transparent fit margins checked; also tested 1600×1200 → 800×600 |
| `crop` | Original-coordinate crop; touch/pointer move and corner resize; ratios/freeform/custom numeric bounds; zoom; crop-result preview | Exact crop dimensions and expected green pixels verified; browser gesture testing unavailable |
| `convert-to-jpg` | Batch conversion to real JPEG; quality and background flattening | Actual JPEG decoded; opaque white fill verified |
| `convert-from-jpg` | JPG → PNG/WebP | Actual PNG and WebP decoding and dimensions checked |
| `convert-to-png` | JPG/WebP/BMP/static GIF → PNG; AVIF when browser can decode it | PNG output, transparency, BMP and GIF still-frame inputs tested. AVIF not tested |
| `convert-from-png` | PNG → JPG/WebP; alpha or solid fill as appropriate | Actual encoding and WebP alpha checked |
| `webp-converter` | JPG/PNG → WebP; WebP → JPG/PNG; quality; batch | Actual WebP encode/decode tested. No lossless WebP control is claimed |
| `bulk-converter` | Shared sequential queue; up to 20 files / 100 MB; per-file success/failure; retry failed files; remove/clear; individual and ZIP downloads | Three actual JPEG/PNG/WebP inputs converted and ZIP reopened; all three entries decoded |
| `rotate-flip` | 90° left/right, 180°, arbitrary angle, horizontal/vertical mirror; decoder handles source orientation | Right-angle/custom-angle output dimensions checked. EXIF behavior not verified across browsers |
| `watermark` | Text/logo layers; position, size, alpha, rotation, color; repeated pattern; full export; retained watermark layers when replacing an image in the session | Actual tiled text and decoded image-overlay output tested |
| `background-remover` | Reuses existing BackgroundRemover component and real segmentation worker/model; same previews, alpha PNG export, color backdrops and existing limits | Previously engine-tested; integration compiles. No new segmentation or browser test in this release. Custom background-image preview remains unimplemented |
| `upscaler` | Reuses existing Real-ESRGAN component, model cache, native Photo 2×/4×, Anime/Fast, comparison and exports | Previously real-model WASM tested, including larger-image exports. No new WebGPU/browser test in this release |

Every suffix above is under `/basic-tools/image/`. Tool IDs are matched against a fixed registry, and unknown routes use notFound. The production build includes the dynamic tool route and the directory.

## Architecture, formats, privacy and limits

One native processing engine lives at `public/tools/image/engine.mjs`, used by the shipped image worker and all twelve non-AI workflows. It validates actual signatures, decodes with imageOrientation `from-image`, checks dimensions, applies real pixels/graphics, and encodes actual output blobs. Each preview is separately rendered at a reduced resolution; full export does not use the reduced preview. Ordinary resampling is never labelled AI. The two AI cards use the existing AI components without duplicating their implementations.

The preferred path uses a dedicated Web Worker with OffscreenCanvas. Browsers without that combination use local document canvas and a native decoder; heavy operations on that fallback can be less responsive. Workers are terminated for cancellation, reset and unmount. Blob URLs and decoded images are disposed. Batch processing is sequential. Native tool limits: 30 MB per file, 24 million pixels, at most 8192 pixels per side; 20 files / 100 MB per batch; at most 30 graphic layers. These are admission limits, not proof that every mobile device can allocate the largest accepted file. Existing AI limits remain separate.

Core outputs are PNG, JPG and WebP. WebP output is offered only after a browser encoding probe; unexpected encoder fallback is rejected by MIME type. BMP, static GIF and AVIF inputs depend on the actual decoder. BMP/GIF processing passed native-adapter file tests, which do not certify browser support. AVIF was not tested. Animated inputs become a single decoded still frame. There is no GIF animation encoder, AVIF encoder, SVG tracing, HEIC/HEIF, TIFF, PSD, RAW, ICO or CMYK/16-bit/color-managed workflow. SVG is rejected, not wrapped as raster-in-SVG.

PNG is re-encoded through the native canvas encoder; quality does not apply and a smaller file is not guaranteed. Lossy target sizes are best effort. Dimensions only decrease when the user selects resizing/cropping or an optional maximum side. JPEG flattens alpha on the chosen background. PNG/WebP preserve available transparency; converting from JPEG cannot recover lost transparency or detail. Metadata is discarded.

No image files are sent to a processing server. Standard tools do not require signup, credits, payment or an API. Existing AI workers continue to download their static model assets as previously documented. No additional hosting or paid API was introduced.

## Admin Studio

Admin Studio → **Image Tools** edits existing card titles, descriptions, icons, visibility, order within categories, and Available/New/Coming Soon badges. Coming Soon cards render as non-link unavailable cards. Hidden cards are absent from the homepage; these settings are presentation controls, not access security for routes. Admin and owner permissions and same-origin checks are required to save. Visitors and contributors cannot update settings. Tool IDs and destinations cannot be changed into arbitrary executable routes through this editor.

## Verification performed

`node tests/image-tools.cjs`: 36 real shipped-worker image-processing cases with native Canvas adapters in Node; resulting files are saved, decoded, and checked. Includes all 12 non-AI workflows, ten filters, compression, alpha, crop pixel values, text/graphics/logo changes, static GIF, BMP and a larger resize. A ZIP is generated, reopened and all three images decoded. Invalid format, dimensions, crop bounds and mismatched JPG source validation are checked. Records: `verification.json`.

`node tests/image-tools-admin.cjs`: fixed 14-tool registry, admin card persistence/order/metadata, visibility, badge data, role checks, same-origin checks, duplicate IDs and unsupported icon rejection using an in-memory store adapter.

`node tests/workspace-credits.cjs`: navigation and earlier workspace/credit-preview regression checks. TypeScript and production build checked.

No browser-control capability is available in this environment. File-picker/drop, actual download clicks, browser ZIP download, crop/layer pointer gestures, undo/redo UI, mobile layout, real Safari/Android/Chrome/Edge/Firefox rendering, WebGPU and the canvas fallback have not been tested end to end. Actual inference at maximum accepted limits is not certified. These limits remain explicit; no complete cross-browser or production-ready guarantee is claimed.

## Dependencies

New standard image processing/editor uses browser Canvas, image codecs, Web Workers and custom application code. No Fabric/Konva or new codec package was installed. ZIP exports reuse the already installed JSZip 3.10.1 (MIT). AI cards reuse the existing ONNX Runtime Web, segmentation model and Real-ESRGAN integrations with their retained notices. No extra backend deployment or compute cost was provisioned.

## Default-state error fix

Reproduced the reported “Cannot read properties of null (reading x)” error by calling cropBounds with crop:null, which is the initial UI state. The crop boundary normalizer now treats null as no crop, keeping the full image. UI settings have been extracted into a shared module imported by the regression tests. Every worker case now starts with the actual interface defaults; additional tests cover default resize export, reduced preview, and custom dimensions with no crop. Engine and worker asset URLs are versioned so a reloaded tab fetches the corrected modules. Browser UI verification remains unavailable.