DEV Community

szp2005
szp2005

Posted on

Formatting 50 Product Cutouts for Amazon, Shopify, and Etsy in One Browser Pass (OffscreenCanvas Workers, Zero Re-Inference)

When sellers export product photos for multiple storefronts, background removal is only half the work. Each marketplace enforces different geometry and encoding rules that quietly break naive exports:

  • Amazon main images require pure #FFFFFF RGB (255, 255, 255), the product filling roughly 85% of the frame, >= 1,600 px on the longest side for zoom (2,000 x 2,000 square is standard), and JPEG output without stray props or detached cast shadows.
  • Shopify collection grids look uneven when tall bottles and wide bags are centered by bounding-box midpoint rather than resting on a shared bottom shelf line (2,048 x 2,048 WebP/PNG with a 10% bottom baseline margin fixes the "jumping row" effect).
  • Etsy listing thumbnails flatten transparent PNG alpha channels to solid black in several views and crop first-slot thumbnails to 4:3 (2,667 x 2,000 or 2,000 x 2,000 opaque JPEG avoids both traps).

Running neural segmentation three separate times just to export Amazon, Shopify, and Etsy variants wastes 3x the compute and crashes mobile tabs. Here is how we decoupled alpha inference from marketplace composition in remove.ac/batch.

1. Run alpha inference once and cache compact matte intermediates

On first visit, the browser caches ~80 MB of quantized ONNX weights locally (single-image Studio handles up to 20 MB / 32 MP, and Batch handles up to 50 images per ZIP). When a user drops up to 50 photos into /batch?preset=amazon-main, the WASM worker runs segmentation once per image and retains the foreground cutout alongside connected-component alpha bounds.

2. Connected-component alpha bounds that ignore stray dust specks

A classic bug in "85% frame fill" auto-cropping is scanning raw alpha > 0 pixels. A single 2x2 semi-transparent dust speck near the bottom corner inflates the bounding box, shrinks the actual product to 55% of the canvas, and detaches grounded contact shadows so the item looks like it is floating.

Before computing scale and shelf alignment, our composer filters out isolated micro-components below a minimum pixel-area threshold while preserving thin handle loops attached to the main subject. Grounded contact shadows are anchored to the denoised subject base rather than the raw alpha extrema.

3. Zero-reinference retemplating inside a dedicated OffscreenCanvas worker

Switching a finished 50-image batch from Amazon 2000x2000 pure white JPG to Shopify 2048x2048 shelf-aligned WebP or Etsy 2667x2000 4:3 opaque JPG never re-runs the neural network. A dedicated OffscreenCanvas worker composites each cached cutout onto the target aspect ratio, applies optional grounded floor shadow, encodes JPEG/WebP/PNG (with automatic lossless PNG fallback on engines like WebKit that omit OffscreenCanvas WebP encoding), and streams the output into a store-mode ZIP archive while revoking intermediate ImageBitmap buffers frame by frame.

Benchmarks and automated pipelines

We publish rolling 90-day real-device WebAssembly latency percentiles (2,200+ real browser runs across Chromium and WebKit) under CC BY 4.0 at remove.ac/benchmarks. For teams automating >50 SKUs, exploring studio design templates, or migrating scripts before the December 1, 2026 remove.bg shutdown, see the remove.bg alternative overview. POST https://remove.ac/v1.0/removebg accepts single-call streams up to 25 MB / 50 MP (pricing: https://remove.ac/pricing, API docs: https://remove.ac/api-info) with 10 free full-resolution welcome credits (valid 30 days) on verified accounts.

Top comments (0)