Index of every page on this site: llms.txt
All skills
Run it yourself

Edit images with precision — crop, resize, mirror, rotate, trim, and reframe. Use this skill whenever the user asks to crop, resize, trim, mirror, flip, rotate, reframe, or otherwise manipulate an image. Also use for creating square crops, portraits/headshots from full-body images, icon sizes, or any image transformation. Even if the request sounds simple, this skill prevents common pitfalls and ensures correct results on the first try.

Use this Skill: https://skilld.dev/gh/peterkrueck/claude-code-development-kit/image-edit

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

SKILL.md

≈114 tokens for metadata: the name and description. ≈1.1k when used: this file.

Description uses 5.7% of example budget

Before choosing a Skill, your Agent reads its name and description. All available Skills share that space.

  • A shorter description leaves more room for other Skills. This entry exceeds our 1% size suggestion.

In our Claude Code example, all Skill names and descriptions share 8,000 characters. This Skill uses ≈453 characters, or 5.7%.

The 1% threshold is a size suggestion. Longer descriptions can still fit.

Your model, settings, and other Skills decide how much text your Agent can read.

Example settings and source

The example uses a 200k-token context and default Claude Code settings. The count includes the name, description, separators, and when_to_use when present. Codex also counts local file paths.

Skit's source and limits: Codex 0.160.1, Claude Code 2.1.292.

Image Edit — Crop, Resize & Transform

Precision image manipulation using Python/Pillow. This skill exists because macOS sips has unreliable crop offset behavior and visual inspection alone leads to bad coordinates — images often have hundreds of pixels of invisible padding that throws off naive crops.

Setup

The scripts need Pillow and numpy. Create a temp venv on first use:

python3 -m venv /tmp/imgcrop && /tmp/imgcrop/bin/pip install Pillow numpy -q

This only needs to happen once per session. The venv at /tmp/imgcrop persists until reboot.

The Golden Rule: Measure Before You Cut

Never guess crop coordinates from visual inspection. Images routinely have large invisible regions — transparent padding, solid-color borders, or dead space — that make visual estimates wildly wrong.

Always run the analysis script first to get exact pixel coordinates of where the actual content lives.

Workflow

Step 1 — Visual inspection

Use the Read tool to look at the image. Understand what's in it and what the user wants to focus on.

Step 2 — Analyze content bounds

Run the bundled analysis script to find where content actually lives:

/tmp/imgcrop/bin/python3 .claude/skills/image-edit/scripts/analyze_bounds.py <image_path>

This outputs JSON with:

  • content_bounds — exact pixel coordinates of non-background content
  • padding — how much dead space exists on each side
  • suggested_square_crops — pre-calculated crop regions at different zoom levels:
    • tight_head (35%) — face/head closeup
    • upper_body (55%) — head through chest/arms
    • three_quarter (75%) — head through waist
    • full (100%) — entire subject

Use --threshold to adjust sensitivity (default 30).

Step 3 — Calculate crop coordinates

Use the analysis output to compute exact crop coordinates:

  • Headroom: Add 40-70px above the content top
  • Centering: Center horizontally on the content's center-x, not the image's center
  • Aspect ratio: For square crops, use max(width, height) as the side length
  • Clamping: Ensure the crop region doesn't extend beyond image dimensions

Step 4 — Apply operations

Use the bundled script. All operations are optional and composable — applied in order: crop -> mirror -> rotate -> resize.

/tmp/imgcrop/bin/python3 .claude/skills/image-edit/scripts/crop_image.py \
  <input_path> <output_path> \
  [--left L --top T --right R --bottom B] \
  [--mirror horizontal|vertical] \
  [--rotate DEGREES] \
  [--resize WxH]

Flags:

Flag Required Description
--left/--top/--right/--bottom No (but all four if any) Crop region in pixels. (0,0) is top-left.
--mirror No horizontal (or h) flips left-right. vertical (or v) flips top-bottom.
--rotate No Counter-clockwise degrees. 90/180/270 are pixel-perfect; other angles expand the canvas.
--resize No Final dimensions, e.g. 512x512. Applied after all other operations. Uses LANCZOS resampling.

Important: Always save to a NEW file. Never overwrite the original.

Step 5 — Verify

Read the output image with the Read tool to visually confirm the result. If it doesn't look right, adjust and re-run — the original is untouched.

Common Tasks

Square crop of a subject

  1. Analyze bounds to find content region
  2. Use the appropriate suggested crop (upper_body, three_quarter, etc.)
  3. Adjust for headroom and centering

Mirror an image

/tmp/imgcrop/bin/python3 .claude/skills/image-edit/scripts/crop_image.py \
  input.png output-mirrored.png --mirror horizontal

Resize to specific dimensions

  1. Crop first if needed (to set the right aspect ratio)
  2. Use --resize WxH to scale

Trim transparent/white padding

  1. Analyze bounds — the padding field tells you how much dead space exists
  2. Crop to content_bounds plus a small margin (10-20px)

Generate multiple sizes (e.g., app icons)

  1. Start with the highest-resolution crop
  2. Run multiple commands with different --resize values

Do NOT use macOS sips

The sips command-line tool has unreliable --cropOffset behavior. Use the Python scripts instead.

Source: SKILL.md on GitHub

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No alerts1mo4 checks · Risk SAFE
  • Gen Agent Trust Hub1mo

    This skill provides a set of Python scripts for precise image manipulation (cropping, resizing, rotating) using the Pillow and NumPy libraries. It sets up a temporary virtual environment to manage dependencies locally and includes tools for analyzing image boundaries to ensure accurate transformations. No security issues were detected.

  • Socket1mo

    No alerts

  • Snyk1mo

    Risk: LOW · No issues

  • ZeroLeaks7mo

    Score: 93/100 · 2 sections analyzed

Signed by skilld at ba85375. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 2 months ago.

Steadyupdated 8 months ago
user_invocable
true

README badge

README badge for peterkrueck/claude-code-development-kit/image-edit