Image post-processing tools
After an image exists—newly generated or opened from your gallery—you can optionally refine it in your browser. These steps are separate from cloud generation; see Generative image generation for how images are first created.
Where to use it in the app
- Image Generator—post-processing panel next to generated results.
- GIF Generator—optional processing on frames after generation.
- Gallery—open any stored image and run the same tools before download or save.
What the tools do
These tools are not part of the Gemini API; they run locally to refine PNGs before download or saving back to the gallery.
Background removal
Produces a PNG with transparency. The tool samples colors along the image border, infers background-like colors, then builds a mask and writes it into the alpha channel. RGB is not recolored; optional feather only smooths transparency.
Pixel downsampler
Reduces the palette and aligns pixels for a pixel-art style, controlled by a target color count.
Background removal parameters
These map to the controls in the post-processing panel (defaults: mode Flood, tolerance 28, erode/dilate/feather 0).
- Mode — Flood (edges) spreads transparency inward from the frame only through pixels that match the inferred background. Best when the subject is fully surrounded by background that touches the edges. Dual (full) classifies every pixel by color alone, so holes in the middle can clear too; use when the background is uniform or the subject touches the border, knowing colors similar to the background may become transparent.
- Tolerance — How far (per RGB channel, compared to the closer of two border-derived color centers) a pixel may deviate and still count as background. Higher values remove more pixels (helpful for halos and off-white paper); lower values stay stricter (helpful for gradients or subjects near the background color). Range 0–255.
- Erode — Shrinks the opaque (foreground) region by repeated small steps. Use to trim a thin ring of wrongly opaque pixels (e.g. light fringes). Too much erode thins fine lines and anti-aliased edges.
- Dilate — Expands the opaque region. Use if the subject looks chipped or the key ate visible edge detail. Too much dilate pulls background back over the cutout.
- Feather — Number of light blur passes on the alpha channel only, softening the silhouette. Does not change RGB; on noisy edges it can look muddy, so fix the mask first, then add a small feather if you want a softer composite.
Processing order: build mask, apply erode passes, then dilate passes, then optional feather.
When both are enabled, the pipeline typically removes the background first, then runs the downsampler. The WASM bundle is loaded from /wasm/pixel-art-downsampler/ on the site. Processed results can be saved back to your gallery with metadata indicating they came from this client-side step.
The heavy lifting is implemented in C and compiled to WebAssembly for the browser; source files (for example background removal and pixel downsampler modules) live with the WASM build that ships under public/wasm/.