Skill: neckr0ik/image-handler (version 1.0.0)

--- name: image-handler description: Read, analyze, convert, and manipulate image files (PNG, JPG, GIF, WebP, TIFF, BMP, HEIC, SVG, ICO). Use when working with images: reading metadata, converting formats, resizing, rotating, compressing, or batch processing. Triggers on mentions of image files, file paths with image extensions, or requests to process/convert images. --- # Image Handler Analyze, convert, and manipulate image files. ## Supported Formats | Format | Extensions | Read | Convert | Metadata | |--------|------------|------|---------|----------| | PNG | .png | ✅ | ✅ | ✅ | | JPEG | .jpg, .jpeg | ✅ | ✅ | ✅ | | GIF | .gif | ✅ | ✅ | ✅ | | WebP | .webp | ✅ | ✅ | ✅ | | TIFF | .tiff, .tif | ✅ | ✅ | ✅ | | BMP | .bmp | ✅ | ✅ | ✅ | | HEIC | .heic, .heif | ✅ | ✅ | ✅ | | SVG | .svg | ✅ | ✅ | - | | ICO | .ico | ✅ | ✅ | ✅ | ## Quick Commands ### Metadata (sips - built-in macOS) ```bash # Get all properties sips -g all image.jpg # Get specific properties sips -g pixelWidth -g pixelHeight -g format -g dpiWidth -g dpiHeight image.jpg # JSON-like output (parseable) sips -g all image.jpg 2>&1 | tail +2 ``` ### Convert Formats ```bash # Convert to PNG sips -s format png input.jpg --out output.png # Convert to JPEG with quality sips -s format jpeg -s formatOptions 85 input.png --out output.jpg # Convert HEIC to JPEG sips -s format jpeg input.heic --out output.jpg # Batch convert (shell) for f in *.heic; do sips -s format jpeg "$f" --out "${f%.heic}.jpg"; done ``` ### Resize ```bash # Resize to max dimensions (maintains aspect ratio) sips --resampleWidth 1920 image.jpg --out resized.jpg sips --resampleHeight 1080 image.jpg --out resized.jpg # Resize to exact dimensions sips --resampleWidth 1920 --resampleHeight 1080 image.jpg --out resized.jpg # Scale by percentage sips --resampleWidth 50% image.jpg --out half.jpg ``` ### Rotate & Flip ```bash # Rotate 90 degrees clockwise sips --rotate 90 image.jpg --out rotated.jpg # Rotate 180 degrees sips --rotate 180 image.jpg --out rotated.jpg # Flip horizontal sips --flip horizontal image.jpg --out flipped.jpg # Flip vertical sips --flip vertical image.jpg --out flipped.jpg ``` ### Crop ```bash # Crop to specific pixels (x, y, width, height) sips --cropToHeightWidth 500 500 image.jpg --out cropped.jpg # Crop from center sips --cropToHeightWidth 500 500 --cropOffset 100 100 image.jpg --out cropped.jpg ``` ### Strip Metadata ```bash # Remove EXIF and all metadata sips --deleteProperty all image.jpg --out clean.jpg ``` ### ffmpeg (advanced operations) ```bash # WebP to PNG ffmpeg -i input.webp output.png # Extract frames from GIF ffmpeg -i animation.gif frame_%03d.png # Create GIF from images ffmpeg -framerate 10 -i frame_%03d.png output.gif # Resize with ffmpeg ffmpeg -i input.jpg -vf scale=1920:-1 output.jpg # Convert video to GIF ffmpeg -i video.mp4 -vf "fps=10,scale=480:-1" output.gif ``` ## Scripts ### image_info.sh Get comprehensive image metadata. ```bash ~/Dropbox/jarvis/skills/image-handler/scripts/image_info.sh <image> ``` ### convert_image.sh Convert between formats with options. ```bash ~/Dropbox/jarvis/skills/image-handler/scripts/convert_image.sh <input> <output> [quality] ``` ### batch_convert.sh Convert all images in a directory. ```bash ~/Dropbox/jarvis/skills/image-handler/scripts/batch_convert.sh <input_dir> <output_format> [output_dir] ``` ## Workflow 1. **Get info** — `sips -g all` for dimensions, format, metadata 2. **Convert if needed** — Change format for compatibility 3. **Resize/optimize** — Reduce file size for web/sharing 4. **Strip metadata** — Remove EXIF for privacy ## Notes - `sips` is built into macOS — no installation needed - `ffmpeg` handles WebP, animated GIFs, and video-to-image - For HEIC (iPhone photos), convert to JPEG for compatibility - SVG is text-based — use `cat` or text tools - For OCR on images, use the document-handler skill

path: scripts/batch_convert.sh
content: #!/bin/bash
# Batch convert all images in a directory

set -e

if [[ $# -lt 2 ]]; then
    echo "Usage: $0 <input_dir> <output_format> [output_dir]"
    echo "Examples:"
    echo "  $0 ./photos jpg"
    echo "  $0 ./heics jpg ./converted"
    echo "  $0 ./images png"
    exit 1
fi

INPUT_DIR="$1"
FORMAT="${2,,}"
OUTPUT_DIR="${3:-$INPUT_DIR/converted}"

if [[ ! -d "$INPUT_DIR" ]]; then
    echo "Error: Directory not found: $INPUT_DIR" >&2
    exit 1
fi

mkdir -p "$OUTPUT_DIR"

# Map format
case "$FORMAT" in
    jpg|jpeg)
        SIPS_FORMAT="jpeg"
        EXT="jpg"
        ;;
    png)
        SIPS_FORMAT="png"
        EXT="png"
        ;;
    gif)
        SIPS_FORMAT="gif"
        EXT="gif"
        ;;
    tiff|tif)
        SIPS_FORMAT="tiff"
        EXT="tiff"
        ;;
    webp|heic|heif)
        echo "WebP/HEIC batch conversion requires ffmpeg"
        echo "Run: for f in $INPUT_DIR/*; do ffmpeg -i \"\$f\" \"${OUTPUT_DIR}/\$(basename \"\${f%.*}\").${FORMAT}\"; done"
        exit 1
        ;;
    *)
        echo "Error: Unsupported format: $FORMAT" >&2
        exit 1
        ;;
esac

COUNT=0
for f in "$INPUT_DIR"/*.{jpg,jpeg,png,gif,tiff,tif,bmp,heic,heif,webp} 2>/dev/null; do
    [[ -f "$f" ]] || continue

    BASENAME=$(basename "${f%.*}")
    OUTPUT="$OUTPUT_DIR/${BASENAME}.${EXT}"

    sips -s format "$SIPS_FORMAT" "$f" --out "$OUTPUT" >/dev/null 2>&1
    echo "Converted: $f -> $OUTPUT"
    ((COUNT++))
done

echo ""
echo "Done! Converted $COUNT images to $OUTPUT_DIR"

path: scripts/convert_image.sh
content: #!/bin/bash
# Convert image between formats

set -e

if [[ $# -lt 2 ]]; then
    echo "Usage: $0 <input> <output> [quality=85]"
    echo "Examples:"
    echo "  $0 photo.heic photo.jpg"
    echo "  $0 image.png image.webp 90"
    exit 1
fi

INPUT="$1"
OUTPUT="$2"
QUALITY="${3:-85}"

if [[ ! -f "$INPUT" ]]; then
    echo "Error: Input file not found: $INPUT" >&2
    exit 1
fi

OUT_EXT="${OUTPUT##*.}"
OUT_EXT="${OUT_EXT,,}"

# Map extension to sips format
case "$OUT_EXT" in
    jpg|jpeg)
        FORMAT="jpeg"
        FORMAT_OPTS="-s formatOptions $QUALITY"
        ;;
    png)
        FORMAT="png"
        FORMAT_OPTS=""
        ;;
    gif)
        FORMAT="gif"
        FORMAT_OPTS=""
        ;;
    tiff|tif)
        FORMAT="tiff"
        FORMAT_OPTS=""
        ;;
    bmp)
        FORMAT="bmp"
        FORMAT_OPTS=""
        ;;
    webp|heic|heif)
        # sips doesn't support WebP/HEIC output, use ffmpeg
        ffmpeg -y -i "$INPUT" "$OUTPUT"
        echo "Converted: $INPUT -> $OUTPUT (via ffmpeg)"
        exit 0
        ;;
    *)
        echo "Error: Unsupported output format: $OUT_EXT" >&2
        exit 1
        ;;
esac

sips -s format "$FORMAT" $FORMAT_OPTS "$INPUT" --out "$OUTPUT" >/dev/null 2>&1

echo "Converted: $INPUT -> $OUTPUT"
ls -lh "$OUTPUT" | awk '{print "Output size:", $5}'

path: scripts/image_info.sh
content: #!/bin/bash
# Get comprehensive image metadata

set -e

if [[ $# -lt 1 ]]; then
    echo "Usage: $0 <image>"
    exit 1
fi

IMAGE="$1"

if [[ ! -f "$IMAGE" ]]; then
    echo "Error: Image not found: $IMAGE" >&2
    exit 1
fi

EXT="${IMAGE##*.}"
EXT="${EXT,,}"

echo "=== Image: $IMAGE ==="
echo ""

# Basic file info
echo "--- File ---"
ls -lh "$IMAGE" | awk '{print "Size:", $5}'
echo ""

# Image properties
echo "--- Properties ---"
sips -g all "$IMAGE" 2>&1 | tail +2 || echo "Could not read image properties"
echo ""

# For SVG, show first few lines
if [[ "$EXT" == "svg" ]]; then
    echo "--- SVG Content (first 20 lines) ---"
    head -20 "$IMAGE"
fi

Security scan verdicts — ClawScan: clean | static analysis: clean | VirusTotal: clean | SkillSpector: suspicious (MEDIUM)