/hildegard:hildegard-photo-editfrom hildegard
Edits photos using Python scripts (Pillow, numpy) for straightening, cropping, color correction, denoising, and resizing with ImageMagick recipes. Use when retouching or animating photos.
Ships in hildegard. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
No shell or tools here (a chat, or tools turned off)? Then you are writing a plan: give the user the commands in order, with their file names, and the checks to run after. Never write tool-call markup or claim a result you did not get.
The scripts in this skill's scripts/ folder do the measuring for you, so you never judge a tilt, a colour cast or a crop by eye.
Install once (Pillow and numpy; nothing else, no OpenCV): python3 -m pip install pillow numpy
# needs: python3 -m pip install pillow numpy
python3 scripts/fix.py photo.jpg out.jpg --size 1600x900 --subject 0.5,0.45 --family h --max-bytes 400000
python3 scripts/measure.py out.jpg photo.jpg
python3 scripts/contact_sheet.py compare.png photo.jpg out.jpg # then LOOK at compare.png
--family h) or upright lines such as a door, pole or building corner (--family v). Leave --family out when unsure.fix.py. It straightens, crops, corrects colour, denoises and sharpens, in that order, and prints what it did.measure.py on the result and read each line. Then look at the before and after sheet.--angle DEG (the tilt, when fix.py said it
could not measure it), --wb none or --warmth +3 (the light should stay warm), --exposure +0.5 or -0.5 (stops), --subject (a better
box), --no-denoise (the picture is clean and detailed), --black none (a silhouette or night scene should stay black).out.jpg and say in a sentence what you changed and anything fix.py warned about. Never overwrite the original.fix.py exit codes: 0 written; 2 refused (the subject cannot fit that shape: pick another aspect or give a smaller box); 1 error.
straighten.py finds the tilt from the straight lines, turns the right way, and
cuts to the largest rectangle with no black wedges. If it refuses ("not clear enough"), leave the photo as shot and say so, or give
--angle only when a measurement (not a hunch) says what it is. A wrong turn makes a photo worse.--subject: two numbers are its centre, four are its box
(left, top, right, bottom), as fractions (0 to 1) of the picture. crop.py never cuts that box and refuses if it cannot fit.color.py brings the light to neutral from the brightest unclipped pixels and holds back
when those are strongly coloured (a red sign, a sunset sun). A warm evening photo should keep its warmth: if the report shows the
picture was already warm on purpose, use --wb none or --warmth +2.denoise_sharpen.py measures noise before and after and never lets sharpening add
more than 15 percent over the denoised picture. Halos along edges mean too much.--size WxH and --max-bytes N; check the printed size.references/slop.md here is its slop catalogue). A good photo edit is mostly invisible:
straight horizons, true colour, the eye going where it should. HDR glow, plastic skin, halos and crunchy saturation are photo slop.measure.py line | Means | Fix |
|---|---|---|
tilt +2.1 (counter-clockwise) | the horizon rises to the right by 2.1 degrees | straighten.py (or fix.py) |
| tilt unclear | no clear straight lines | leave it, or --angle from a real measurement |
| gray-world error over 0.2 | strong cast, or a scene that is one colour | color.py --wb auto; keep warm light with --wb none |
| mean luminance under 0.28 or over 0.65 | dark or bright | color.py --exposure auto |
| clipped highlights over 0.05 | blown | color.py lowers exposure (detail already lost stays lost) |
| clipped shadows over 0.08 | crushed | color.py opens the floor (--black none for silhouettes) |
| noise over 4 | grainy | denoise_sharpen.py |
Each is one file in scripts/, run with --help for every flag. They need Pillow and numpy
(python3 -m pip install pillow numpy), work on Windows, macOS and Linux, and print a plain message when a package is missing.
# needs: python3 -m pip install pillow numpy
python3 scripts/straighten.py in.jpg level.jpg [--family h|v] [--angle DEG] # prints "tilt found: -2.31 degrees ..."
python3 scripts/color.py level.jpg graded.jpg [--wb auto|gray|white|none] [--exposure auto|+0.5] [--warmth +3] # prints before and after
python3 scripts/denoise_sharpen.py graded.jpg clean.jpg [--max-noise-increase 15] # prints noise in, denoised, out
python3 scripts/crop.py clean.jpg final.jpg --aspect 4:5 --subject 0.6,0.4 # or --size 1080x1350; prints the crop box
python3 scripts/measure.py final.jpg [reference.jpg] # tilt, cast, light, clipping, noise, SSIM
straighten.py: an orientation-restricted Hough transform on the edge map. It prints the tilt, the lines it trusted and a confidence,
and refuses below the confidence floor. A tilt under 0.6 degrees is left alone. Perspective (a building shot from below) is not tilt:
when the horizontal and vertical lines disagree it refuses and asks you to name the family.color.py: white balance, exposure from the highlights (a dark picture goes up until its brightest 0.5 percent is just under white;
blown ones come down), an opened shadow floor, and a gentle contrast curve only on a flat picture. No synthetic gradient, ever.denoise_sharpen.py: light non-local-means denoise, stronger on colour noise, then an unsharp mask on luma only with a soft threshold
and a local limit against halos. It skips a clean photo.crop.py: the largest window of the shape, always holding the subject box with a margin, placed on a third (or the centre for a large
subject) the way the picture already leans. With no --subject it guesses from a saliency map and says so: name the subject when you can.measure.py: numbers with a plain reading beside each. A reading is a hint (a sunset is meant to be warm), not a verdict.Commands are ImageMagick 7 (magick). With ImageMagick 6 write convert. Use these when Python is not available; they need the same
care: measure, change one thing, look. Check a result with magick identify, and by looking at it.
# Orientation and straighten (ANGLE: degrees to turn clockwise; read it from a measurement or a line you can see, not a guess)
magick in.jpg -auto-orient step1.jpg
ANGLE=2.1; W=$(magick step1.jpg -format %w info:); H=$(magick step1.jpg -format %h info:)
PCT=$(awk -v a=$ANGLE -v w=$W -v h=$H 'BEGIN{t=a*3.14159265/180; m=(w>h?w:h)/(w>h?h:w); printf "%.2f", 100/(cos(t)+m*sin(t))-0.5}')
magick step1.jpg -background black -rotate $ANGLE +repage -gravity center -crop ${PCT}%x${PCT}% +repage straight.jpg # no black corners
# Crop to 4:5 around the subject's centre (CX,CY in pixels, read off the picture): the window is as tall as the picture, then slid sideways
W=$(magick straight.jpg -format %w info:); H=$(magick straight.jpg -format %h info:); CX=1500
CW=$(awk -v h=$H 'BEGIN{printf "%d", h*0.8}'); X=$(awk -v c=$CX -v w=$CW -v W=$W 'BEGIN{x=c-w/2; if(x<0)x=0; if(x>W-w)x=W-w; printf "%d", x}')
magick straight.jpg -crop ${CW}x${H}+${X}+0 +repage cropped.jpg # check the subject is whole: look at it
# White balance from the picture: scale each channel so the means match (gray-world)
read R G B < <(magick in.jpg -format "%[fx:mean.r] %[fx:mean.g] %[fx:mean.b]" info:)
magick in.jpg -channel R -evaluate multiply $(awk -v a=$R -v b=$G -v c=$B 'BEGIN{m=(a+b+c)/3; print m/a}') \
+channel -channel B -evaluate multiply $(awk -v a=$R -v b=$G -v c=$B 'BEGIN{m=(a+b+c)/3; print m/c}') +channel wb.jpg
# Exposure: pull the mean toward 0.45 (only when the picture is clearly dark or bright), never past clipping
G=$(magick wb.jpg -colorspace Gray -format "%[fx:log(mean)/log(0.45)]" info:); magick wb.jpg -gamma $G exposed.jpg
magick in.jpg -color-matrix "1.04 0 0 0 1 0 0 0 0.95" warmer.jpg # nudge warmer (R up, B down) only for light that should be warm
magick in.jpg -level 3%,98%,1.05 leveled.jpg # black point, white point, midtones
# Light denoise then sharpen (do not sharpen a noisy picture: halos and grit)
magick in.jpg -wavelet-denoise 2% -unsharp 0x0.75+0.5+0.02 sharp.jpg
Neutral greys (concrete, paper, a white shirt in shade) should read neutral unless the light is meant to be warm. Do not auto-level a night
scene or a misty one: its low contrast is the point. Turn saturation down more often than up: magick in.jpg -modulate 100,88,100 out.jpg.
magick identify -verbose in.jpg | grep -E "Geometry|Colorspace|Quality|Orientation|icc:description"
python3 scripts/measure.py in.jpg # needs: python3 -m pip install pillow numpy
Note size, orientation and colour profile. Decide what the photo is of and what the edit is for (web, print, a start frame) before
touching it. Look at every result: from this skill's
folder (install the packages once with python3 -m pip install pillow numpy av; a photo needs only Pillow and numpy)
echo '{"path": "out.jpg", "sheet": "look.jpg"}' > spec.json && python3 scripts/review_media.py spec.json. It prints each check (size,
highlights, shadows, contrast, colour) as pass, warn or fail. For before and after side by side, python3 scripts/contact_sheet.py compare.png in.jpg out.jpg.
magick in.jpg \( +clone -region 24x24+1310+842 -blur 0x3 \) -composite fixed.jpg
# For the web: sRGB, 2048 px long side, sharpened for the screen, GPS removed (a Pillow or scripts/ output has no metadata).
magick in.jpg -colorspace sRGB -resize "2048x2048>" -unsharp 0x0.75+0.6+0.02 -quality 88 \
-define jpeg:sampling-factor=4:2:0 web.jpg
exiftool -gps:all= -overwrite_original web.jpg # if exiftool is installed
# For print: full size, light sharpening, TIFF or maximum-quality JPEG.
magick in.jpg -unsharp 0x1+0.5+0.02 -quality 95 print.jpg
Keep enough pixels: 1080 px on the short side for the web, 3000+ for print. Crop to strengthen the subject (on a third, or centred for symmetry), not to fill a format by habit.
Background removal runs locally with rembg's own command (the BiRefNet model downloads once):
python3 -m pip install "rembg[cpu,cli]" # once; "rembg[gpu,cli]" with an NVIDIA card
rembg i -m birefnet-general -dc mug.jpg mug.png # -dc pulls the counter's colour out of the edge pixels
The hildegard skill's cutout script does the same with --decontaminate, when that skill is with you. No
Python: GIMP's Paths tool and Layer, Transparency, Add Alpha Channel, by hand.
magick mug.png -trim +repage mug-trim.png
# 2000x2000 on pure white, the object at most 1600 px and centred, a soft shadow made from its own alpha
magick mug-trim.png -resize 1600x1600 \( +clone -background black -shadow 40x18+0+24 \) +swap -background none \
-layers merge +repage -gravity center -background white -extent 2000x2000 -flatten mug-white.jpg
# check the edges: the cutout over black, white and magenta, the centre at 200 percent
for c in black white magenta; do magick mug.png -background $c -flatten -gravity center -crop 50%x50%+0+0 +repage -scale 200% edge-$c.png; done
Look at each edge-*.png. A pale rim shows on black and a dark rim on white; either is a halo (run again with -dc,
or shrink the matte a pixel with magick mug.png -channel A -morphology Erode Disk:1 +channel mug.png). Magenta shows
any of the counter's colour left in a soft edge. A hole that should be see-through (a mug handle, the gap under an arm)
must show the backdrop colour in all three sheets, never the counter. Then put the original and mug-white.jpg side
by side (python3 scripts/contact_sheet.py compare.png mug.jpg mug-white.jpg) and check the glaze colour matches; no
saturation boost, a product photo keeps its true colour and shape.
To change a photo with words (a new sky, another colour, an object removed) rather than by hand, use the image editor or model your user has. It draws a new image from the photo, so use the tools above when the pixels must stay exactly yours. A real person is changed only with their consent, and never so they appear to do what they didn't.
A photo can be the first frame of a video shot: the camera starts on exactly that image. This needs your user's video model (image-to-video):
fix.py): its crop, light and colour become the shot's.Only animate photos of people who agreed to it. Never make someone appear to do or say what they didn't.
Run measure.py and the review on the export (--final, or "final": true in the spec, for the delivery bar), look at it at 100% and at
phone size, and tell your user what you changed. If you couldn't fix something (motion blur, focus missed, a tilt the lines could not
show), say so.
measure.py's lines as printed; never claim you looked at an edge or a sheet you did not open.references/slop.md (opens in a new tab)scripts/color.py (opens in a new tab)scripts/contact_sheet.py (opens in a new tab)scripts/crop.py (opens in a new tab)scripts/denoise_sharpen.py (opens in a new tab)scripts/fix.py (opens in a new tab)scripts/measure.py (opens in a new tab)scripts/photolib.py (opens in a new tab)scripts/review_media.py (opens in a new tab)scripts/straighten.py (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
17 skills in this plugin
/hildegardUse for /hildegard, /art, /vus, /mus, /suno and any request to make, edit or write creative work; routes images, video, sound, music, 3D, games, web and every kind of writing./hildegard-3dUse when making a 3D model, sculpture, figurine, game asset, relief or lithophane in Blender, OpenSCAD or code, checked each round for views, watertightness and size./hildegard-artUse when making art, an image, illustration, key art, mood board or visual style with the user's image model; posters and covers with words go to hildegard-design.npx claudepluginhub students-of-local/hildegard --plugin hildegard