🎁 Get the FREE AI Skills Starter Guide β€” Subscribe β†’
BytesAgainBytesAgain
πŸ¦€ ClawHub

Image Cropper

by @mingo-318

Crop objects from images using bounding box annotations in COCO, YOLO, VOC, or LabelMe formats with optional padding and batch processing.

Versionv1.0.0
Downloads544
Installs4
TERMINAL
clawhub install image-cropper

πŸ“– About This Skill

Image Cropper

Crop images based on bounding box annotations. Supports COCO, YOLO, VOC, and LabelMe formats. Use when user needs to extract objects from images based on annotation boxes.

Features

  • Multi-format Support: COCO, YOLO, VOC, LabelMe
  • Batch Processing: Crop entire datasets
  • Padding: Add padding around bounding boxes
  • Output Options: Individual files or sprite sheet
  • Handle Missing: Gracefully handle images without annotations
  • Usage

    # Crop YOLO annotations
    python scripts/cropper.py yolo images/ labels/ output/

    Crop COCO annotations

    python scripts/cropper.py coco annotations.json images/ output/

    Crop with padding

    python scripts/cropper.py yolo images/ labels/ output/ --padding 10

    Crop all objects to individual files

    python scripts/cropper.py yolo images/ labels/ output/ --objects

    Examples

    $ python scripts/cropper.py yolo ./images ./labels ./output

    Processing 100 images... βœ“ Cropped 250 objects from image_001.jpg βœ“ Cropped 180 objects from image_002.jpg ... Total: 500 cropped images

    Installation

    pip install pillow
    

    Options

  • --padding: Padding around box (pixels, default: 0)
  • --objects: Save each object as separate file
  • --min-size: Minimum box size to crop (pixels)
  • --format: Output format (jpg, png, default: jpg)
  • --quality: JPEG quality 1-100 (default: 95)
  • πŸ’‘ Examples

    $ python scripts/cropper.py yolo ./images ./labels ./output

    Processing 100 images... βœ“ Cropped 250 objects from image_001.jpg βœ“ Cropped 180 objects from image_002.jpg ... Total: 500 cropped images

    βš™οΈ Configuration

  • --padding: Padding around box (pixels, default: 0)
  • --objects: Save each object as separate file
  • --min-size: Minimum box size to crop (pixels)
  • --format: Output format (jpg, png, default: jpg)
  • --quality: JPEG quality 1-100 (default: 95)