How to Batch Compress & Convert Nested Image Folders to WebP in the Browser (No 20-File Upload Limits)
If you've ever needed to compress a multi-folder project—like a public/assets/ directory for a web app, a sprite folder for an indie game, or a 10-episode comic archive—you've probably hit the same frustrating wall with
If you've ever needed to compress a multi-folder project—like a public/assets/ directory for a web app, a sprite folder for an indie game, or a 10-episode comic archive—you've probably hit the same frustrating wall with cloud image compressors:
- The 20-File & 5MB Paywall: Most online tools (like TinyPNG or iLoveIMG) cap free batches at 20 files and 5MB per image.
-
Flattened Directory Structures: Even if you drop images from nested folders (
Episode_01/,Episode_02/,ui/icons/), cloud tools dump everything into a single flat.zip, forcing you to manually re-sort hundreds of files. - Privacy & Upload Wait Times: Uploading 500MB of raw PNGs to a remote server just to convert them to WebP or JPEG wastes bandwidth and exposes private assets.
To solve this cleanly without any backend server costs, I built a 100% client-side Batch Folder Image Compressor & Resizer as part of CreaPocket.
👉 Try it live here (Free, No Sign-up): CreaPocket Batch Folder Image Compressor
🛠️ How It Works Under the Hood (100% In-Browser)
Modern browsers already have everything needed to process hundreds of high-resolution images locally using your device's own RAM and CPU:
1. Recursive Folder Traversal (webkitGetAsEntry & webkitdirectory)
Instead of only accepting flat file lists, we can traverse entire directory trees dropped onto the page and preserve every file's relative path (folder/subfolder/image.png):
async function traverseFileTree(item, path = "") {
if (item.isFile) {
return new Promise((resolve) => {
item.file((file) => {
file.relativePath = path + file.name;
resolve([file]);
});
});
} else if (item.isDirectory) {
const dirReader = item.createReader();
const entries = await new Promise((resolve) => dirReader.readEntries(resolve));
const files = await Promise.all(
entries.map((entry) => traverseFileTree(entry, path + item.name + "/"))
);
return files.flat();
}
return [];
}
2. Avoiding the HTML5 Canvas "PNG Bloat Trap" (Smart Size Guard)
One common gotcha with canvas.toBlob(callback, 'image/png', quality) is that browser PNG encoders are strictly lossless and ignore the quality parameter. Re-encoding an already optimized PNG on a <canvas> can actually make the file 10–30% larger!
To prevent negative compression:
-
Smart Size Guard: Whenever dimensions aren't downscaled and the output format matches the input, we compare
compressedBlob.sizeagainstoriginalFile.size. If the re-encoded blob is larger, we automatically fall back to keeping the original file untouched. - One-Click WebP / JPEG Conversion: Switching a folder of heavy PNGs to WebP (84% quality) or JPEG shrinks total folder size by 65% to 85% while keeping visual quality virtually indistinguishable.
📊 Real-World Compression Benchmark (100-Image Folder)
Here is what happens when you drop a nested folder of 100 high-res illustrations and UI assets (245 MB total raw PNGs) into the browser compressor:
| Output Format | Quality Setting | Output Folder Size | Space Saved | Transparency | Subfolders Kept? |
|---|---|---|---|---|---|
| Original PNG | Raw | 245.0 MB | 0% | Yes | Yes |
| WebP (Recommended) | 84% | 38.2 MB | -84.4% | Yes | Yes |
| JPEG | 84% | 44.6 MB | -81.8% | No | Yes |
| Downscaled 50% + WebP | 84% | 11.5 MB | -95.3% | Yes | Yes |
🚀 Two Live Utilities in CreaPocket
Both utilities run completely inside your browser with zero server uploads:
-
Batch Folder Image Compressor & Resizer
- Drop entire nested folders or individual images.
- Bulk convert between WebP, JPEG, and PNG with custom quality sliders.
- Resize by percentage (
75%,50%) or fit max width/height (1920px,1280px,800px) without enlarging smaller images. - Export a clean
.zipwith your exact original folder hierarchy intact.
-
Webtoon & Manga Vertical Image Slicer
- Built for digital comic creators publishing on WEBTOON Canvas (
800 × 1280 px) and Tapas (940 × 1280 px). - Automatically downscales oversized canvas widths and slices long vertical strips into sequentially numbered pages in seconds.
- Built for digital comic creators publishing on WEBTOON Canvas (
📖 Deep-Dive Guides
If you're interested in the specifics of image compression and comic formatting workflows, check out our full guides:
- How to Bulk Convert & Compress PNG Folders to WebP or JPEG (No 20-File Limit)
- How to Batch Compress an Entire Image Folder Without Losing Subfolder Structure
- How to Avoid Blurry WEBTOON Compression Artifacts
Feedback and feature requests are super welcome!
Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.