Preparing product images is rarely one operation. You may need to fit every image into the same canvas, choose a background color, convert formats, rename the files, and download the set. Repeating those steps for each file is tedious.
I built a batch product image workflow for PNGDock to put those operations in one browser session. This post covers the implementation choices and the limits I had to make explicit. The workflow is free to try without an account. Its image processing and ZIP creation happen in the browser; the selected images are not uploaded for this workflow.
Start with limits, not the processing loop
The tool accepts PNG, JPEG, and WebP files. At present, it caps a batch at 20 files, 12 MB per file, 80 MB of source files in total, and 32 megapixels per image. It also caps the combined output size for a ZIP at 150 MB.
Those limits are part of the design. A compressed source file can decode into a much larger bitmap, and a browser may hold the decoded image, canvas, encoded output, and ZIP data at different points in the workflow. A file-size check alone cannot protect memory usage.
Each candidate file is checked before entering the queue. The tool verifies its extension and reported MIME type, tries to decode it, reads its dimensions, and rejects images above the pixel limit. Browser-side validation is still not a security boundary for a server, but here it keeps the local workflow from accepting inputs it is unlikely to handle well.
Decode and process one image at a time
The processing loop is sequential. For each file, it creates an ImageBitmap when the browser supports it, with an image-element fallback. It draws the decoded image into a target-size canvas, encodes the result, then releases the bitmap and clears the canvas dimensions.
The core fit calculation is small:
const scale = fit === "cover" ? Math.max(targetWidth / image.width, targetHeight / image.height) : Math.min(targetWidth / image.width, targetHeight / image.height); const drawWidth = image.width * scale; const drawHeight = image.height * scale; context.drawImage( image, (targetWidth - drawWidth) / 2, (targetHeight - drawHeight) / 2, drawWidth, drawHeight ); cover fills the canvas and crops the overflow. contain keeps the whole image visible and may leave empty space around it. The user can keep that space transparent or fill it with white or a chosen color. For JPEG output, a transparent choice becomes white because JPEG has no alpha channel.
One important distinction: a canvas background is not background removal. If the source photo contains a wall or a tabletop, choosing white does not cut the subject out. The page says this plainly, because the two operations are easy to confuse.
Encode according to the selected format
The browser's canvas.toBlob() handles the initial PNG, JPEG, or WebP encoding. A quality control applies to JPEG and WebP. PNG output gets an additional pass through an OxiPNG WebAssembly module, and the tool keeps the optimized file only if it is smaller than the initial PNG.
This still does not guarantee that every output will be smaller than its input. Dimensions, image content, format, and the source file's existing compression all matter. The interface shows source and result sizes so the user can compare them.
I also invalidate previous results when an export setting changes. Otherwise, a queue could silently contain files rendered with different dimensions or formats while presenting them as one batch.
Build the ZIP locally
Each successful result can be downloaded separately. For the whole set, the tool builds a ZIP in the browser. It writes ZIP local file headers, CRC-32 checksums, a central directory, and an end-of-central-directory record, then creates a Blob for download.
The ZIP entries use the already encoded image bytes. ZIP does not need to compress those bytes again, which is useful because PNG, JPEG, and WebP are already compressed formats.
Generated names are sanitized, length-limited, and made unique even when two source files would produce the same output name. A failed image stays visible in the queue and can be retried without discarding successful results. The user can also stop after the image currently being processed.
What browser-local actually means
The image bytes stay in the browser for this particular workflow. That does not mean the site makes zero network requests: it still loads the application code, and ordinary site analytics may send non-image events. It means this workflow does not send the selected image content to an image-processing server.
There are trade-offs. A large batch can still consume substantial memory, processing speed depends on the user's device, and a browser tab can be closed before export. The current limits and sequential loop are deliberate ways to keep those risks manageable, not claims that the browser can process arbitrarily large collections.
If you build similar tools, I would test the failure paths early: a corrupt file in the middle of a batch, two names that collide after sanitization, a PNG whose optimized version is larger, and a ZIP that crosses the output cap. The happy path is only half of the experience.
The live workflow and source repository are available if you want to inspect or try the implementation. I would be interested in hearing which browser-side failure cases or memory constraints you have run into with batch image tools.
Disclosure: This article was drafted with AI assistance and checked against the PNGDock project source. Please review the implementation details and wording before publishing.

![Cargo UAV Autonomy and Flight AI — Ch.06: Route Planning and Airspace Integration [EN]](https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F54s7rrr8fw0ipjpci49u.png)
![Cargo UAV Autonomy and Flight AI — Ch.05: Perception and Sensor Fusion for UAV [EN]](https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Faemm4fj7d911fwx0irut.png)