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

Crop, trim, and adjust framing of images by removing transparent whitespace margins, trimming solid color borders, or extracting specific pixel bounding boxes. Use when the user asks to crop an image, trim blank space or transparent borders, remove excess margins, or inspect subject dimensions.

Use this Skill: https://skilld.dev/gh/domesticmouse/skills/crop-image

Nothing lands on disk. Nothing to clean up.

Fork this Skill

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

SKILL.md

≈77 tokens for metadata: the name and description. ≈1.2k when used: this file.

Description uses 3.9% 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 ≈308 characters, or 3.9%.

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.

Crop Image

Procedural runbook and tooling for inspecting image boundaries, trimming empty margins (transparent or solid color backgrounds), and executing precision crops.

Includes a zero-dependency Python 3 utility (crop.py) for bit-perfect PNG handling and automatic fallback to Pillow when installed.

Workflows

Choose the matching workflow based on your objective:

  1. Inspect Image & Subject Bounding Box
  2. Autocrop Transparent Blank Space
  3. Trim Solid Color Borders (White / Black / Custom)
  4. Crop by Explicit Bounding Box or Dimensions
  5. Validate Cropped Asset

1. Inspect Image & Subject Bounding Box

Before modifying an image, inspect its current dimensions, color channels, and where the actual subject pixels reside.

  1. Run the inspection command using crop.py:
    python3 .agents/skills/crop-image/scripts/crop.py <path/to/image> --inspect
  2. Review the diagnostic output:
    • Dimensions: Overall pixel width and height.
    • Detected Border/Corner Color: Color sampled from corners.
    • Alpha Subject Bounding Box: Coordinate extent [left, top, right, bottom] where alpha > 0.
    • Subject Margins: Number of blank pixels on left, right, top, and bottom edges. (Note: iOS Simulator captures taken via xcrun simctl io booted screenshot /abs/path/to/file.png—see /ios-simulator-screenshot—capture the exact device framebuffer with 0px outer margin, whereas macOS window captures include transparent shadow margins that need --autocrop.)
  3. Completion Criterion: Bounding box coordinates and margin sizes are printed to stdout without modifying the source image.

2. Autocrop Transparent Blank Space

Remove excess transparent padding around a subject, optionally preserving a small aesthetic margin (e.g. 8–16 px) so the graphic does not touch container boundaries.

  1. Run autocrop with desired padding (default is 0 for tight crop):
    # In-place overwrite with 12px padding around subject:
    python3 .agents/skills/crop-image/scripts/crop.py <path/to/image.png> --autocrop --padding 12 --in-place
    
    # Or output to a new file:
    python3 .agents/skills/crop-image/scripts/crop.py <input.png> -o <output.png> --autocrop --padding 12
  2. For semi-transparent edge artifacts, increase --alpha-thresh (e.g. --alpha-thresh 10).
  3. Completion Criterion: Target image exists on disk with reduced dimensions tightly bounding the subject.

3. Trim Solid Color Borders (White / Black / Custom)

Trim uniform solid background colors (e.g. white borders 255,255,255 or dark borders 0,0,0):

  1. Specify the RGB color to trim and tolerance (0–255):
    # Trim pure white border with tolerance 5 and 10px margin:
    python3 .agents/skills/crop-image/scripts/crop.py <path/to/image> -o <output> --autocrop --color 255,255,255 --tolerance 5 --padding 10
    
    # Trim pure black border:
    python3 .agents/skills/crop-image/scripts/crop.py <path/to/image> -o <output> --autocrop --color 0,0,0 --tolerance 5
  2. Completion Criterion: Script reports Success with adjusted dimensions matching the bounded subject.

4. Crop by Explicit Bounding Box or Dimensions

Extract a specific rectangle by pixel coordinates left,top,right,bottom (inclusive):

  1. Compute or select the target coordinates left,top,right,bottom:
    python3 .agents/skills/crop-image/scripts/crop.py <path/to/image> -o <output> --box 100,50,900,650
  2. If working on macOS and only cropping from the center or fixed width/height:
    sips --cropToHeightWidth <targetHeight> <targetWidth> <input> --out <output>
  3. Completion Criterion: Output image matches the exact target pixel dimensions (right - left + 1) × (bottom - top + 1).

5. Validate Cropped Asset

Always verify the cropped image before declaring completion:

  1. Query file metadata with sips (macOS) or crop.py --inspect:
    sips -g pixelWidth -g pixelHeight <path/to/cropped-image>
    python3 .agents/skills/crop-image/scripts/crop.py <path/to/cropped-image> --inspect
  2. Confirm:
    • pixelWidth and pixelHeight match expected cropped dimensions.
    • The file is readable and not corrupted.
    • For web/slides projects, run local build/linter (e.g. npm --prefix slides run build) to ensure layouts using the asset compile cleanly.
  3. Completion Criterion: Image metadata returns expected dimensions and project build exits with code 0.

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 alerts13d3 checks · Risk SAFE
  • Gen Agent Trust Hub13d

    This skill provides a local utility for inspecting and cropping images. It includes a custom Python script for PNG processing and leverages the native macOS 'sips' tool for basic image operations. All processing occurs locally on files provided by the user, and no malicious patterns, network activity, or suspicious dependencies were detected.

  • Socket13d

    No alerts

  • Snyk13d

    Risk: LOW · No issues

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

Last checked against GitHub yesterday.

Activeupdated 2 weeks ago
compatibility
Python 3.9+ (zero dependencies for PNG; optional Pillow for JPEG/WebP)

README badge

README badge for domesticmouse/skills/crop-image