auto-white-balance
Skill21 starsChanged 8 days agoMITView on GitHub
Use when the user wants to automatically correct the white balance of an image (or batch) — neutralise colour casts from indoor lighting, mixed light, underwater shots, scans, or uncalibrated cameras. Implements gray-world (default), white-patch (per-channel auto-level), and a combined mode via ImageMagick. Operates on JPEG/PNG/TIFF/WebP; for RAW use `darktable-cli` instead.
In this repository28 other files it gives its agents.
- ai-graphicsSkill
- auto-deskewSkill
- auto-toneSkill
- batch-set-copyrightSkill
- check-model-pricingSkill
- convert-to-avifSkill
- fast-resizeSkill
- fast-thumbnailSkill
- from-jxlSkill
- images-to-pdfSkill
- install-depsSkill
- new-projectSkill
- new-workflowSkill
- open-workspaceSkill
- optimize-jpegSkill
- optimize-pngSkill
- pdf-extract-embedded-imagesSkill
- pdf-to-imagesSkill
- read-metadataSkill
- scrub-metadataSkill
- set-metadataSkill
- svg-to-rasterSkill
- to-jxlSkill
- transcode-jpeg-to-jxl-losslessSkill
- upscale-imageSkill
- vectorizeSkill
- web-readySkill
- workspace-setupSkill
The file
We split this skill into the rules it gives an agent
3 rules. About 0 are common, 2 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 21
Do not use this skill when:
- Very specific: line 37
Verify ImageMagick 7+. magick -version | head -1.
- Distinctive: line 64
Run gray-world to a temp file, then:
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Auto White Balance
Neutralise colour casts without per-image manual correction. Three algorithms, one CLI.
- gray-world (default) — assume the average of the scene is neutral grey. Scale each RGB channel so its mean equals the global mean. Robust on most natural scenes.
- white-patch — assume the brightest pixels are white. Per-channel
-auto-levelstretches each channel to full range. Strong correction; fails on scenes lacking a true white reference. - combined — gray-world first, then a gentle white-patch pass at 50% strength. Good default for mixed-light indoor shots.
When to use
- Indoor photos under tungsten/fluorescent/LED with the wrong WB preset.
- Scanned prints / slides with age-related cast.
- Underwater or aquarium shots (heavy blue/green cast).
- Batch normalisation before publishing a gallery shot across multiple lighting conditions.
Do not use this skill when:
- Source is a RAW file (CR2/NEF/ARW/DNG/RAF) — use
darktable-cliwith--apply-custom-presetsand thetemperaturemodule set toas shot to reference. White-balancing a baked JPEG throws away headroom that's still in the RAW. - The cast is intentional (golden hour, sodium streetlamps for mood, blue-hour landscapes). Auto-WB will flatten it.
- The image is a deliberately monochromatic / toned edit.
Inputs
- Input — file or directory. Required.
- Mode —
gray-world(default) |white-patch|combined. - Recursive —
--recursivefor directory descent. - Output — default in-place suffix
_wbnext to the source.--output-dir <path>to write into a sibling folder.--overwriteto replace. - Strength —
0.0to1.0(default1.0). Blends the corrected image with the original via-compose blend -define compose:args=<pct>. Use0.5for a softer touch. - Preserve luminance — default
on. After channel scaling, rescale so the mean luminance matches the original (prevents brightness drift).--no-preserve-lumato disable.
Procedure
- Verify ImageMagick 7+.
magick -version | head -1. Fall back toconvert(IM6) ifmagickis missing — the syntax below works on both with the leading binary swapped. If neither, point atinstall-deps. - Enumerate inputs. Accept JPEG/JPG/PNG/TIFF/TIF/WebP. Skip and note RAW formats.
gray-world:
magick "$IN" \ -colorspace sRGB \ -channel R -evaluate multiply $(magick "$IN" -colorspace sRGB -format "%[fx:mean/mean.r]" info:) \ -channel G -evaluate multiply $(magick "$IN" -colorspace sRGB -format "%[fx:mean/mean.g]" info:) \ -channel B -evaluate multiply $(magick "$IN" -colorspace sRGB -format "%[fx:mean/mean.b]" info:) \ +channel "$OUT"Each
fx:mean/mean.<c>is the gain that drives that channel's mean to the global mean. Threeinfo:calls is wasteful for batch — cache via a singlemagick identify -format "%[fx:mean] %[fx:mean.r] %[fx:mean.g] %[fx:mean.b]" "$IN"and compute gains in shell.white-patch:
magick "$IN" -channel RGB -auto-level +channel "$OUT"Independent per-channel histogram stretch to
[0,1]. Aggressive; clips highlights if any channel already saturates.combined:
Run gray-world to a temp file, then:
magick "$TMP" \( +clone -channel RGB -auto-level +channel \) \ -compose blend -define compose:args=50 -composite "$OUT"Preserve luminance (when enabled): after step 3/4/5, measure luminance before and after and rescale:
L_IN=$(magick "$IN" -colorspace Gray -format "%[fx:mean]" info:) L_OUT=$(magick "$WB" -colorspace Gray -format "%[fx:mean]" info:) GAIN=$(awk "BEGIN{print $L_IN/$L_OUT}") magick "$WB" -evaluate multiply "$GAIN" "$OUT"Strength blend (when
<1.0):magick "$IN" "$WB" -compose blend -define compose:args=$(awk "BEGIN{print $STRENGTH*100}") -composite "$OUT"- For batch, parallelise with
xargs -P $(nproc)over the file list. Skip files that already end in_wbto avoid recursive re-processing.
Output
- Corrected images at the resolved paths.
- Summary:
- Files processed / skipped (RAW or non-image) / failed.
- Per-mode count when mixed.
- Average per-channel gain across the batch (sanity check — if R-gain ≈ G-gain ≈ B-gain ≈ 1.0, the batch had no cast and the run was a no-op).
Notes
- Gray-world fails on scenes dominated by one colour (snow, foliage, red brick wall). For those,
white-patchis more honest, or skip auto-WB entirely and use a colour picker on a known-neutral patch. - For batch mixed-lighting normalisation, run
combinedat--strength 0.7— strong enough to neutralise obvious casts, weak enough to preserve scene character. - Output colour profile: ImageMagick respects the input ICC profile. If the source has no profile, it's treated as sRGB. Use
-profile sRGB.iccexplicitly if the pipeline downstream is profile-strict. - This skill is the single-image / batch primitive. The orchestrator
apply-filtersmay call it as one step; this skill exists to do WB-only work without the rest of the pipeline.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

