# Crop Image

> Use this skill when an AI agent needs to crop images through the deployed Crop Image service. Trigger this for URL-based cropping (`POST /crop`) and file-upload cropping (`POST /crop/upload`), especially when returning production URLs and handling API-level errors.

- Skill: `dvcrn/crop-image` (Agent Skill)
- Install (CLI): `npx skillmds@latest add dvcrn/crop-image`
- Raw SKILL.md: https://api.skillmd.com/api/skills/dvcrn/crop-image/raw
- Safety review: pending (external: skill-scanner PASS, skillspector PASS)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: AI & ML
- Author: dvcrn (https://skillmd.com/u/dvcrn)
- Updated: 2026-09-08
- Page: https://skillmd.com/skills/dvcrn/crop-image

---


# Crop Image Skill

## Service Endpoints

- API Base URL: `https://api.imageclaw.net`
- Health: `https://api.imageclaw.net/health`
- Crop by URL: `https://api.imageclaw.net/crop`
- Crop by Upload: `https://api.imageclaw.net/crop/upload`
- Docs: `https://api.imageclaw.net/docs`

## Execute Crop by URL

1. Validate input fields:
- `url` must be a reachable image URL.
- `width` and `height` must be integers in `[1, 4096]`.

2. Call endpoint:

```bash
curl -sS -X POST "https://api.imageclaw.net/crop" \
  -H "content-type: application/json" \
  -d '{
    "url": "https://picsum.photos/800/600",
    "width": 256,
    "height": 256
  }'
```

3. Return response fields:
- `cropped_url`
- `original_size`
- `face_detected`

## Execute Crop by Upload

1. Prefer upload mode for user-provided local files.

2. Call endpoint:

```bash
curl -sS -X POST "https://api.imageclaw.net/crop/upload" \
  -F "file=@/absolute/path/to/photo.jpg" \
  -F "width=256" \
  -F "height=256"
```

3. Return response fields:
- `cropped_url`
- `original_size`
- `face_detected`

## Error Handling

- HTTP `400`: invalid image source or decode failure
- HTTP `422`: validation failure (invalid URL, invalid width/height)
- HTTP `500`: service or configuration failure

When failure occurs:
1. Return the original status code and `detail`.
2. Ask caller to change input for `400/422`.
3. Retry only for transient `500` or network timeout.

## Success Example

```json
{
  "cropped_url": "https://crop.imagebee.net/crops/1772761350_b8050bd6ec26.jpg",
  "original_size": [800, 600],
  "face_detected": false
}
```

## Failure Example

```json
{
  "detail": "Not an image: content-type is application/json"
}
```

