Agent Skills: Basic Image Editing

Image manipulation via a bundled script, resizing, rotation, flipping, cropping, padding, format conversion (JPEG/PNG/WebP/TIFF/HEIC), transparency operations (remove/replace/extract/blend), grayscale conversion, auto-cropping borders, and file size optimization.

UncategorizedID: garg-aayush/tutorials/basic-image-editing

Install this agent skill to your local

pnpm dlx add-skill https://github.com/garg-aayush/handbook/tree/HEAD/.claude/skills/basic-image-editing

Skill Files

Browse the full folder contents for basic-image-editing.

Download Skill

Loading file tree…

.claude/skills/basic-image-editing/SKILL.md

Skill Metadata

Name
basic-image-editing
Description
Image manipulation via a bundled script, resizing, rotation, flipping, cropping, padding, format conversion (JPEG/PNG/WebP/TIFF/HEIC), transparency operations (remove/replace/extract/blend), grayscale conversion, auto-cropping borders, and file size optimization.

Basic Image Editing

Image manipulation tool supporting transformations, format conversions, transparency operations, and optimization. Useful for resizing images, removing backgrounds, converting formats, reducing file sizes, and preparing images for web or applications.

Quick Start

uv run ${CLAUDE_SKILL_DIR}/scripts/image_edit.py INPUT -o OUTPUT [options]

Operations

Image Info

uv run ${CLAUDE_SKILL_DIR}/scripts/image_edit.py input.png --info

Displays: dimensions, format, file size, color mode, DPI.

Rotate

uv run ${CLAUDE_SKILL_DIR}/scripts/image_edit.py input.png -o output.png --rotate 90
uv run ${CLAUDE_SKILL_DIR}/scripts/image_edit.py input.png -o output.png --rotate 45

Flip

uv run ${CLAUDE_SKILL_DIR}/scripts/image_edit.py input.png -o output.png --flip horizontal
uv run ${CLAUDE_SKILL_DIR}/scripts/image_edit.py input.png -o output.png --flip vertical

Resize

# Exact dimensions
uv run ${CLAUDE_SKILL_DIR}/scripts/image_edit.py input.png -o output.png --width 800 --height 600

# Width only (maintains aspect ratio)
uv run ${CLAUDE_SKILL_DIR}/scripts/image_edit.py input.png -o output.png --width 800

# Height only (maintains aspect ratio)
uv run ${CLAUDE_SKILL_DIR}/scripts/image_edit.py input.png -o output.png --height 600

Format Conversion

Convert by specifying output extension:

uv run ${CLAUDE_SKILL_DIR}/scripts/image_edit.py input.png -o output.webp
uv run ${CLAUDE_SKILL_DIR}/scripts/image_edit.py input.heic -o output.jpg

Supported: JPEG, PNG, WebP, TIFF, HEIC/HEIF.

Grayscale

uv run ${CLAUDE_SKILL_DIR}/scripts/image_edit.py input.png -o output.png --grayscale

Converts to single-channel grayscale (mode 'L').

Transparency

# Remove alpha (white background)
uv run ${CLAUDE_SKILL_DIR}/scripts/image_edit.py input.png -o output.jpg --remove-transparency

# Replace with color
uv run ${CLAUDE_SKILL_DIR}/scripts/image_edit.py input.png -o output.png --replace-transparency red
uv run ${CLAUDE_SKILL_DIR}/scripts/image_edit.py input.png -o output.png --replace-transparency "#FF5500"

If image has no alpha channel, prints a note and continues.

Extract Alpha Mask

uv run ${CLAUDE_SKILL_DIR}/scripts/image_edit.py input.png -o mask.png --extract-mask

Extracts the alpha channel as a 1-channel grayscale mask. Requires RGBA image.

Alpha Blend (Apply Mask)

uv run ${CLAUDE_SKILL_DIR}/scripts/image_edit.py input.png -o output.png --mask mask.png

Applies a grayscale mask as the alpha channel, creating an RGBA composite. Mask is automatically resized to match image dimensions if needed.

Auto-Crop Transparency

uv run ${CLAUDE_SKILL_DIR}/scripts/image_edit.py input.png -o output.png --autocrop-transparency 0
uv run ${CLAUDE_SKILL_DIR}/scripts/image_edit.py input.png -o output.png --autocrop-transparency 5

Crops transparent borders from image. Threshold (0-100%) controls which pixels are considered transparent:

  • 0 = only fully transparent pixels (alpha=0)
  • 5 = pixels with alpha < 5% (≈12/255)
  • 100 = all pixels considered transparent

Padding

# All sides equal
uv run ${CLAUDE_SKILL_DIR}/scripts/image_edit.py input.png -o output.png --pad 20

# Vertical, horizontal
uv run ${CLAUDE_SKILL_DIR}/scripts/image_edit.py input.png -o output.png --pad 10,20

# Top, right, bottom, left
uv run ${CLAUDE_SKILL_DIR}/scripts/image_edit.py input.png -o output.png --pad 10,20,30,40

# With color
uv run ${CLAUDE_SKILL_DIR}/scripts/image_edit.py input.png -o output.png --pad 20 --pad-color blue

# Edge pixel replication
uv run ${CLAUDE_SKILL_DIR}/scripts/image_edit.py input.png -o output.png --pad 20 --pad-edge

Cropping

# All sides equal
uv run ${CLAUDE_SKILL_DIR}/scripts/image_edit.py input.png -o output.png --crop 50

# Top, right, bottom, left
uv run ${CLAUDE_SKILL_DIR}/scripts/image_edit.py input.png -o output.png --crop 10,20,30,40

File Size Reduction

uv run ${CLAUDE_SKILL_DIR}/scripts/image_edit.py input.png -o output.jpg --max-size 1
uv run ${CLAUDE_SKILL_DIR}/scripts/image_edit.py input.png -o output.webp --max-size 0.5

Uses binary search to find optimal quality/dimensions.

Color Formats

| Format | Examples | |--------|----------| | Named | red, blue, coral, darkslategray (140+ CSS colors) | | Hex | #RGB, #RRGGBB, #RRGGBBAA | | RGB | 255,128,0 or rgb(255,128,0) | | HSL | hsl(120,100%,50%) |

Combining Operations

Operations apply in order: rotate → flip → autocrop → crop → resize → pad → mask → grayscale → transparency.

uv run ${CLAUDE_SKILL_DIR}/scripts/image_edit.py input.png -o output.jpg \
    --rotate 90 \
    --autocrop-transparency 5 \
    --width 800 \
    --pad 20 --pad-color white

Important Notes

  • Output filename: Always use a different output filename than the input to avoid overwriting the original. A good practice is to append a descriptive suffix to the input filename (e.g., image.pngimage_rotated.png, photo.jpgphoto_resized.jpg).