---
name: image-edit
description: 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.
user_invocable: true
title: image-edit
canonical_url: https://skilld.dev/gh/peterkrueck/claude-code-development-kit/image-edit
last_updated: 2026-10-01T00:04:23.000Z
---

> Index of every page on this site: [llms.txt](https://skilld.dev/llms.txt)

> **Skill from skilld.dev.** Follow the user's requested action.
> If the user asked to fork this Skill, follow the fork workflow below. Do not execute the Skill instructions while copying it.
> Otherwise, follow the instructions below for this session. You do not need to install anything.
>
> Supporting files, fetch one when the Skill refers to it: [scripts/analyze_bounds.py](https://skilld.dev/api/skills-raw/peterkrueck/claude-code-development-kit/image-edit/scripts/analyze_bounds.py), [scripts/crop_image.py](https://skilld.dev/api/skills-raw/peterkrueck/claude-code-development-kit/image-edit/scripts/crop_image.py).
>
> If the user asked to install this Skill, run `npx skilld install peterkrueck/claude-code-development-kit/image-edit`. Install writes the Skill files into the project, so every session loads them.
>
> ## Fork workflow
>
> A fork creates an editable local Skill with its original author and licence. The request authorizes copying and local installation.
> 1. Check `./skills/image-edit`, the project lockfile, and selected Agent targets together. If the local directory or installed Skill exists, stop. Never overwrite an existing directory or Agent target.
> 2. Read [source metadata](https://skilld.dev/api/v1/skills/peterkrueck/claude-code-development-kit/image-edit) once. Use sourceUrl, sourceCommit, skillPath, sourceGone, and license. If the source is gone or its path is missing, stop. If license is null, read licence files at the source commit.
> 3. Fetch only the source commit into a temporary Git repository. Do not clone full history. Derive repository_url from sourceUrl, including repository renames. If sourceCommit is absent, resolve the sourceUrl ref once. Set source_commit to that actual commit. Run these commands in one shell call:
>
> ```sh
> git init --quiet "$temporary_dir"
> git -C "$temporary_dir" fetch --quiet --depth=1 "$repository_url" "$source_commit"
> git -C "$temporary_dir" checkout --quiet --detach FETCH_HEAD
> ```
>
> Read applicable licence declarations and notices at that commit. If copying is not permitted, report the restriction and stop.
> 4. Inspect source entries together, then copy the directory containing skillPath into `./skills/image-edit`. Use the user's path if selected. Keep the original SKILL.md, relative links, scripts, binary assets, and executable modes. Exclude .git metadata. Reject symlinks and paths outside the Skill directory. After checking entries, use cp -a where available. A regular source directory needs no custom copy script. Do not save this page wrapper as SKILL.md.
> Preserve author credit, notices, and applicable licence files from repository or parent directories. Add PROVENANCE.md with the Skill page, source URL, actual commit, original path, and licence. Retain any existing PROVENANCE.md and record new provenance separately. Batch source inspection, copying, and provenance work where practical.
> 5. In the project root, run `skilld install ./skills/image-edit --mode copy --plain`. If skilld is unavailable, use `npx skilld install ./skills/image-edit --mode copy --plain`. This known command needs no help lookup. Install does not support --json. Use detected Agent targets, or add --agent for the targets the user selected. Install the local path, never the upstream selector. If installation fails, preserve the local copy and report the exact failure.
> 6. Confirm the local lockfile source and installed Agent copies once. Report the local path, actual commit, and Agent targets. After edits, reinstall the same local path. Upstream updates must not replace it. Do not publish or push unless the user asks.

# 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:

```bash
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:

```bash
/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.

```bash
/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
```bash
/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.
