ComfyUI Node

Image Compress

Compress images inside the graph, with the savings printed to the screen

By comfyuiattic-989·Created 5 months ago·Updated 5 months ago· 1
Image Compress
  • image
  • image
  • report
quality80
scale_percent100
formatJPEG

Image Compress does exactly what its name says - and the useful bit is when it does it. Most people never touch compression until the last node, when SaveImage writes a 9 MB PNG and Reddit is about to crush it anyway. This node compresses the tensor inside the workflow, before you save, and hands back both the compressed pixels and a plain-text report of exactly what you saved. If you've ever argued about "quality 80 vs 90" by eyeballing two files, this is the node that settles it with numbers.

It's a small, single-node pack from an anonymous author (comfyuiattic-989, MIT, ko-fi link in the README) that nobody on Reddit is talking about - a utility node you find by searching ComfyUI Manager, not by hype. Don't let the silence fool you; it's a clean, honest little tool.

How it works

Under the hood it's a round-trip through PIL. Each frame of the input tensor becomes a Pillow image (it normalizes L/RGB/RGBA modes so you don't hit a channel-shape surprise downstream), optionally gets resized with Lanczos, then gets encoded and decoded back into a tensor. That last step is the whole point: because it decodes the compressed bytes, JPEG artifacts are genuinely baked into the output tensor - what you see in the graph is what you'd get saving to disk, not an optimistic approximation.

The codec is set by the format input, and the two formats treat quality very differently. JPEG is lossy: quality maps directly to encode quality, so a low value degrades pixels. PNG is lossless, so quality maps to a deflate level - and here's the counterintuitive bit: for PNG, higher quality means less compression. The node maps quality 100 to deflate level 0 (store, no compression) and quality 1 to level 9 (max deflate). The pixels are identical either way; only file size changes. If you want PNG output that visibly differs from the input, scale_percent is your only lever.

Every run also prints the full report to the server console, and the report comes out as a second socket.

The inputs that matter

  • image - any IMAGE tensor. Batches are fine; each frame is processed and reported independently.
  • quality (1–100, default 80) - JPEG: encode quality, lower = more artifacts and a smaller file. PNG: deflate level, inverted as described above.
  • scale_percent (1–100, default 100) - resize before encoding. 50 = half the width and height. This is the only way to actually reduce a PNG tensor.
  • format - JPEG or PNG.

Two outputs: image (the compressed/rescaled tensor - wire it anywhere an IMAGE goes) and report (a STRING - wire it to a Show Text node to see it in-graph, or just read the console).

Installation

No model downloads and no heavy dependencies - Pillow, NumPy, and PyTorch all ship with ComfyUI. Restart ComfyUI after installing and it shows up under image/processing.

cd ComfyUI/custom_nodes
git clone https://github.com/comfyuiattic-989/comfyui-image-compress

Or use ComfyUI Manager: search for "Image Compress" / "ComfyUI-Image-Compress" and install it from there.

Where people get burned

Three gotchas, all of them avoidable if you know they exist.

First, the PNG-at-full-scale surprise. Pick PNG with scale_percent at 100 and your output tensor will be pixel-identical to the input - the node warns you about this inside the report. You haven't broken anything - that's what lossless means. Use scale_percent under 100 if you want to see a change.

Second, the inverted PNG slider. Coming from JPEG intuition, cranking PNG quality to 100 feels like "best quality" - and it is, in that you get a huge uncompressed file. Low quality numbers give you the smaller file.

Third, and this one bites even experienced users: re-encoding strips the embedded workflow metadata. ComfyUI's PNG saves carry the whole node graph inside the file, which is how you drag a shared image back onto the canvas and reconstruct everything. This node re-encodes by design, so anything that flows out of it is a fresh file with no workflow chunk - drag it back and nothing rebuilds, and CivitAI-style auto-linking won't find your models. Keep the original PNG as your master; use the compressed copy only for what it's for: shipping, previewing, or feeding a downstream step that wants a smaller tensor.

Honestly, the most practical use is brute-force and boring: shove a batch through at JPEG quality 80 with a small scale, and the memory footprint of whatever the next node chews on drops enormously. The report is a nice bonus, not the main event.

Categoryimage/processing

Inputs (4)

NameTypeDefaultDescription
imageIMAGE
qualityINT801–100JPEG: lossy encode quality (1=worst, 100=best). PNG: deflate level (100=no compression/smallest deflate, 1=max deflate). PNG pixels are always lossless — use scale_percent to visibly reduce the output.
scale_percentINT1001–100Resize the image to this percentage of its original dimensions before encoding. 100 = no resize. 50 = half width and height. Applies to both JPEG and PNG.
formatCOMBOJPEGJPEG is lossy (quality slider degrades pixels). PNG is lossless (quality only affects file size; use scale_percent to reduce pixel dimensions).

Outputs (2)

NameTypeDescription
imageIMAGE
reportSTRING