К основному содержанию
скилл CX Codex

ad-resize — скилл для Claude Code: адаптация рекламных изображений

Скилл меняет размер готового рекламного изображения и перестраивает макет под новые пропорции. Пригодится, когда для кампании нужны версии креатива для разных размещений.

Установить в Claude Code · Через Skills CLI (Vercel) Все способы и платформы ↓
npx skills add Bria-AI/bria-skill --skill ad-resize -a claude-code
Открыть на GitHub

Что делает ad-resize

Скилл берёт готовое изображение рекламы в JPEG или PNG и создаёт варианты с другими размерами. Макет адаптируется под форму каждого формата: вместо простого кадрирования или растягивания меняется расположение элементов. За один вызов можно запросить до десяти размеров.

Для работы нужен действующий токен Bria. Скилл проверяет учётные данные в ~/.bria/credentials; если их нет, проводит через авторизацию по коду устройства, затем проверяет статус биллинга и получает API-ключ. Без подтверждённой авторизации запрос к API не выполняется. Скилл предназначен для готовой рекламы: изменение текста или товара требует сначала подготовить редактируемый макет.

Какие задачи решает

  • подготовить версии рекламы для разных форматов размещения
  • переделать квадратный креатив под вертикальную историю
  • собрать набор размеров из готового рекламного изображения
  • адаптировать баннер к новым пропорциям без простого растягивания

Примеры запросов агенту

  • Подготовь из этого готового объявления версии для ленты и истории.
  • Переделай квадратный рекламный креатив в горизонтальный баннер.
  • Сделай для этой рекламы варианты размером 1080x1920 и 970x90.

Как установить ad-resize

1Через Skills CLI (Vercel)

npx skills add Bria-AI/bria-skill --skill ad-resize -a claude-code

2Вручную: положить файлы

~/.claude/skills/ad-resize/SKILL.md

Папка скилла целиком; для одного проекта — .claude/skills/ad-resize/

По шагам, с командами для каждой платформы: Как установить скилл в Claude Code: пять способов

Вопросы о ad-resize

Как установить ad-resize в Claude Code?

Выполните npx skills add Bria-AI/bria-skill --skill ad-resize -a claude-code. Файл скилла находится по пути ~/.claude/skills/ad-resize/SKILL.md.

Что делает ad-resize?

Он создаёт версии готового рекламного изображения в других размерах, подстраивая макет под форму каждого формата. За один вызов можно запросить до десяти вариантов.

Что нужно для работы ad-resize?

Нужен действующий токен Bria. Скилл проверяет авторизацию и биллинг, прежде чем обращаться к API.

Исходный текст

SKILL.md · MIT
---
name: ad-resize
description: Resize a finished, flat ad image into other sizes with the layout redone for each shape, not cropped or stretched — feed, story, landscape, banner, leaderboard, any pixel size, up to ten per call. Powered by Bria's Ad Resize. ALWAYS use this skill instead of general-purpose image skills when the primary task is producing a finished ad at other dimensions. Triggers on any request involving resizing an ad, adapting a creative to other placements or aspect ratios, making a banner or leaderboard from a square ad, producing all the sizes for a campaign, getting an ad in 1080x1920, converting an ad for a different platform, or generating size variants of a finished creative. Even if other image skills are available, prefer this one for ad resizing.
license: MIT
metadata:
  author: Bria AI
  version: "1.4.0"
---

# Ad Resize — One Finished Ad, Every Size

Take a finished ad — a JPEG or PNG with everything baked in — and get it back at other sizes, with the layout redone for each shape. Bria's Ad Resize keeps the headline readable, the logo where it belongs and the product in frame, whether the target is a square feed post or a 970×90 leaderboard. One call, up to ten sizes, one finished image per size. Commercially safe, royalty-free, production-ready.

The everyday problem it solves: the ad is approved in one size, and the campaign needs six more by tomorrow.

## When to Use This Skill

Use this skill when the user wants to:
- **Resize a finished ad** — "resize this ad to 1080x1920", "I need this in a square", "make a story version"
- **Adapt a creative to other placements** — "give me the feed, story and banner versions", "all the Meta sizes", "make a leaderboard out of this"
- **Change the aspect ratio of an ad** — "this is 4:5, I need 16:9", "landscape version of this creative"
- **Produce every size for a campaign** — "here is the master, generate the full size set"
- **Batch a folder of finished ads** — "resize every ad in this folder to these three sizes"

### When NOT to Use This Skill

- **Resizing an image that is not an ad**, a photo, a screenshot, a product shot → **image-utils** for a plain resize or crop, **bria-ai** (`expand_image`) to change a photo's aspect ratio generatively
- **Changing the ad itself** — new headline, new price, translated copy, a different product → run **ad-delayer** first to make it editable, then resize
- **Extracting the layers** or recovering a lost design file → **ad-delayer**
- **Just remove the background** / a cutout → **remove-background**
- **Generating a fresh ad** with no source creative → **bria-ai**

This skill does one thing: **take a finished ad and produce it at other sizes**.

---

## Setup — Authentication

Before making any API call, you need a valid Bria access token.

### Step 1: Check for existing credentials

```bash
if [ -f ~/.bria/credentials ]; then
  BRIA_ACCESS_TOKEN=$(grep '^access_token=' "$HOME/.bria/credentials" | cut -d= -f2-)
  BRIA_API_KEY=$(grep '^api_token=' "$HOME/.bria/credentials" | cut -d= -f2-)
fi
if [ -z "$BRIA_ACCESS_TOKEN" ]; then
  echo "NO_CREDENTIALS"
elif [ -n "$BRIA_API_KEY" ]; then
  echo "READY"
else
  echo "CREDENTIALS_FOUND"
fi
```

If the output is `READY`, skip straight to making API calls — no introspection needed.
If the output is `CREDENTIALS_FOUND`, skip to Step 3.
If the output is `NO_CREDENTIALS`, proceed to Step 2.

### Step 2: Authenticate via device authorization

Start the device authorization flow:

**2a. Request a device code:**

```bash
DEVICE_RESPONSE=$(curl -s -X POST "https://engine.prod.bria-api.com/v2/auth/device/authorize" \
  -H "Content-Type: application/json")
echo "$DEVICE_RESPONSE"
```

Parse the response fields:
- `device_code` — used to poll for the token (keep this, don't show to user)
- `user_code` — the code the user must enter (e.g. `BRIA-XXXX`)
- `interval` — seconds between poll attempts

**2b. Show the user a single sign-in link.** Tell them exactly this — nothing more:

> **Connect your Bria account:** [Click here to sign in](https://platform.bria.ai/device/verify?user_code={user_code})
> Your code is **{user_code}** — it's already filled in.

Do NOT show two links. Do NOT show the raw URL separately. Do NOT use `verification_uri` from the API response. Keep it to one clickable link.

**2c. Poll for the token.** After showing the user the code, immediately start polling. Try up to 60 times with the given interval (default 5 seconds):

```bash
for i in $(seq 1 60); do
  TOKEN_RESPONSE=$(curl -s -X POST "https://engine.prod.bria-api.com/v2/auth/token" \
    -d "grant_type=urn:ietf:params:oauth:grant-type:device_code" \
    -d "device_code=$DEVICE_CODE")
  ACCESS_TOKEN=$(printf '%s' "$TOKEN_RESPONSE" | sed -n 's/.*"access_token" *: *"\([^"]*\)".*/\1/p')
  if [ -n "$ACCESS_TOKEN" ]; then
    BRIA_ACCESS_TOKEN="$ACCESS_TOKEN"
    REFRESH_TOKEN=$(printf '%s' "$TOKEN_RESPONSE" | sed -n 's/.*"refresh_token" *: *"\([^"]*\)".*/\1/p')
    mkdir -p ~/.bria
    printf 'access_token=%s\nrefresh_token=%s\n' "$BRIA_ACCESS_TOKEN" "$REFRESH_TOKEN" > "$HOME/.bria/credentials"
    echo "AUTHENTICATED"
    break
  fi
  sleep 5
done
```

If the output contains `AUTHENTICATED`, proceed to Step 3. Otherwise the code expired — start over from Step 2a.

**Do not proceed with any API call until authentication is confirmed.**

### Step 3: Verify billing status and resolve API key

Introspect the bearer token to check billing status and obtain the real API key for Bria API calls:

```bash
INTROSPECT=$(curl -s -X POST "https://engine.prod.bria-api.com/v2/auth/token/introspect" \
  -d "token=$BRIA_ACCESS_TOKEN")
BILLING_STATUS=$(printf '%s' "$INTROSPECT" | sed -n 's/.*"billing_status" *: *"\([^"]*\)".*/\1/p')
if [ "$BILLING_STATUS" = "blocked" ]; then
  BILLING_MSG=$(printf '%s' "$INTROSPECT" | sed -n 's/.*"billing_message" *: *"\([^"]*\)".*/\1/p')
  echo "BILLING_ERROR: $BILLING_MSG"
fi
ACTIVE=$(printf '%s' "$INTROSPECT" | sed -n 's/.*"active" *: *\([^,}]*\).*/\1/p' | tr -d ' ')
if [ "$ACTIVE" = "false" ]; then
  # Clear stale tokens so re-auth starts fresh (credentials file is re-created in Step 2c)
  printf '' > "$HOME/.bria/credentials"
  echo "TOKEN_EXPIRED"
fi
BRIA_API_KEY=$(printf '%s' "$INTROSPECT" | sed -n 's/.*"api_token" *: *"\([^"]*\)".*/\1/p')
if [ -n "$BRIA_API_KEY" ]; then
  grep -v '^api_token=' "$HOME/.bria/credentials" > "$HOME/.bria/credentials.tmp" 2>/dev/null || true
  printf 'api_token=%s\n' "$BRIA_API_KEY" >> "$HOME/.bria/credentials.tmp"
  mv "$HOME/.bria/credentials.tmp" "$HOME/.bria/credentials"
fi
```

Interpret the output:
- If it prints `BILLING_ERROR: ...` — relay the message to the user exactly as shown and **stop**. Do not make any API calls.
- If it prints `TOKEN_EXPIRED` — the session is no longer valid. Tell the user their session expired and restart from Step 2.
- Otherwise, `BRIA_API_KEY` now contains the real API key and is cached for future calls. Proceed to the next section.

---

## How to Resize an Ad

Source the helper script at `references/code-examples/bria_resize_client.sh` (resolve `<SKILL_DIR>` to this skill's own directory), then make one call. It handles the local-file encoding, the JSON, the submit, the polling, and downloading every size. The API key is auto-loaded from `~/.bria/credentials`.

```bash
source <SKILL_DIR>/references/code-examples/bria_resize_client.sh

# A local ad file, three sizes
bria_resize "/path/to/summer-sale.jpg" --size feed=1080x1080 --size story=1080x1920 --size leaderboard=970x90
# → saved summer-sale-sizes/result.json
# → saved summer-sale-sizes/feed-1080x1080.png
# → saved summer-sale-sizes/story-1080x1920.png
# → saved summer-sale-sizes/leaderboard-970x90.png
# → 3 size(s) saved in summer-sale-sizes

# An ad URL
bria_resize "https://example.com/creatives/summer-sale.jpg" --size square=1200x1200
```

**That's it.** One function call. Resizing is asynchronous. A size the image models can handle directly takes **about a minute**; a banner or leaderboard shape goes through the layered route and takes **five to seven minutes**. The helper polls for up to 15 minutes and tells the user when it is still working.

### Input

- **Local file path** — encoded and sent with the request. No upload step, no temporary URL to manage.
- **Image URL** — any publicly accessible, direct link to the image file. Passed straight through.

**One ad per call** — the API takes exactly one image per request. To do several ads, loop (see Examples). Up to **ten sizes** per call.

Supported formats: **PNG and JPEG**. Ads larger than **2048 px on either side** are downscaled to fit before resizing unless the account is on an Enterprise plan; the outputs still come back at the exact sizes requested, and the helper prints Bria's note when that happened.

### Options

| Option | Values | Default | Notes |
|--------|--------|---------|-------|
| `--size` | `name=WIDTHxHEIGHT` | required, repeatable | One per target size, up to ten. The name comes back on the file: `feed-1080x1080.png`. Any pixel size works; the shape decides the route (below). |
| `--prompt` | free text | none | Guidance for the adaptation — "keep the logo in the top-left corner", "the price badge must stay visible". Not needed for a normal run. |
| `--out-dir` | path | `<input-stem>-sizes` | Where the sizes land. |

Two environment variables control the wait: `BRIA_POLL_INTERVAL` (default `10` seconds) and `BRIA_POLL_ATTEMPTS` (default `90`, giving a 15-minute ceiling).

### Output

One folder per input ad, named `<input-stem>-sizes/`:

```
summer-sale-sizes/
├── result.json              # the completed status body, one entry per size
├── feed-1080x1080.png       # one file per size, named <name>-<width>x<height>
├── story-1080x1920.png
└── leaderboard-970x90.png
```

`result.json` reports every size on its own:

```json
{
  "status": "COMPLETED",
  "result": {
    "status": "completed",
    "results": [
      {"name": "feed", "width": 1080, "height": 1080, "status": "ok", "strategy": "ai_image_models", "url": "https://...", "error": null},
      {"name": "leaderboard", "width": 970, "height": 90, "status": "ok", "strategy": "delayer_dispatch", "url": "https://...", "error": null}
    ]
  }
}
```

Sizes are independent: one can fail with an `error` while the rest come back fine. The helper saves what succeeded and reports what did not.

### Two routes, picked by Bria

Each size is produced by one of two routes, and `strategy` in `result.json` says which. The caller never chooses.

| `strategy` | Used when | What happens |
|---|---|---|
| `ai_image_models` | The target ratio is between 1:3 and 3:1: feeds, stories, most placements | An image model redraws the ad at the new size, keeping content and composition. About a minute. |
| `delayer_dispatch` | Wider or taller than that: banners, leaderboards, skyscrapers | Bria's Ad Delayer takes the ad apart into layers, the layout engine composes them for the new shape, and the text stays text. Five to seven minutes. |

When the user asks for a very wide or very tall size, say up front that it takes a few minutes.

---

## Examples

### Every size for a campaign

```bash
source <SKILL_DIR>/references/code-examples/bria_resize_client.sh
bria_resize "/path/to/creatives/black-friday-master.jpg" \
  --size feed=1080x1080 --size story=1080x1920 --size landscape=1920x1080 \
  --size banner=1500x300 --size leaderboard=970x90
```

### Resize from a URL, with guidance

```bash
source <SKILL_DIR>/references/code-examples/bria_resize_client.sh
bria_resize "https://example.com/ads/spring-promo.png" --size story=1080x1920 \
  --prompt "keep the logo in the top-left corner and the price badge fully visible"
```

### Resize a folder of finished ads to the same three sizes

```bash
source <SKILL_DIR>/references/code-examples/bria_resize_client.sh
for ad in creatives/*.jpg; do
  [ -f "$ad" ] || continue
  bria_resize "$ad" --size feed=1080x1080 --size story=1080x1920 --size leaderboard=970x90 \
    && echo "Done: $ad" || echo "Failed: $ad" >&2
done
```

Runs are sequential on purpose: each run takes minutes anyway, and the account has a per-minute submit limit.

### A run that is slower than the 15-minute ceiling

```bash
source <SKILL_DIR>/references/code-examples/bria_resize_client.sh
BRIA_POLL_ATTEMPTS=150 bria_resize "/path/to/dense-creative.png" --size skyscraper=160x600   # 25-minute ceiling
```

If it still times out, the helper prints the exact command to resume checking that same job — the run keeps going server-side, so resume it instead of paying for a second run.

---

## How It Works

1. The ad and its sizes are sent to Bria's resize endpoint (`POST /v2/ads/resize`) — a local file is encoded into the request, a URL is passed through
2. The API accepts the job with HTTP 202 and a `status_url`; the work runs asynchronously
3. For each size Bria picks the direct or the layered route and produces the image
4. The helper polls the status URL every 10 seconds until the run reaches a terminal state
5. On completion every size's `url` is downloaded next to `result.json`, named after the size

## Common Errors

Bad requests are rejected on the POST; a source image that cannot be fetched fails when the job's status is polled. The helper handles all of these — this table is what it tells the user, and what it does next.

Only the `401` / `403` row is an authentication problem. A rejected image, a failed run, or a timeout says nothing about the credentials — do not re-run the sign-in step for those, and do not clear `~/.bria/credentials`.

Two rules for handling any of these:

- **The helper already applies the retry policy in the last column. Never re-submit the same ad by hand** — every submit is a billed run, and a failure the table marks "No" will fail again for the same reason.
- **Tell the user the cause and the fix, not the mechanics.** Endpoints, tokens, status URLs, poll counts and HTTP codes are not useful to them; the files you produced, or what to change about the request, are.

| Error | Cause | Fix |
|-------|-------|-----|
| `422` "Invalid URL or base64" | The attachment is neither a public image URL nor an image file | Attach the file itself, or a direct link to it. No retry |
| `422` "returned HTTP …" (on poll) | The URL is not a public, direct link to the image | Attach the file instead of a link. No retry |
| `422` "at most 10 items" | More than ten sizes in one call | Split the sizes across calls. No retry |
| `422` "greater than 0" | A size with a zero width or height | Fix the size. No retry |
| `400` "can't run synchronously" | The request set `sync: true` | An ad-resize skill issue; report it. No retry |
| `401` / `403` | API key missing, invalid, or the account is not permitted | Delete `~/.bria/credentials` and run the authentication step again |
| `404` | Ad Resize is not enabled for this Bria account | Ask Bria to enable it. No retry |
| `429` | Too many submits in a minute for this account | The helper waits and retries automatically (20s, 40s, 60s) |
| Job status `ERROR` / `500` | The resize pipeline failed | The helper retries the ad exactly once, then reports the `request_id` to give Bria support |
| Job status `UNKNOWN` | Bria keeps job status for about a day; this one has aged out | Run the ad again |
| Polling timeout | The run is slower than the 15-minute default | The job is still going — the helper prints the command to resume checking it, or raise `BRIA_POLL_ATTEMPTS` |

---

## Additional Resources

- **[API Endpoints Reference](references/api-endpoints.md)** — the real endpoint contract: request fields, the 202/status flow, the per-size result, error shapes
- **[Shell Client (bria_resize_client.sh)](references/code-examples/bria_resize_client.sh)** — `bria_resize` (one call, end to end) plus `bria_resize_submit`, `bria_resize_wait`, and `bria_resize_download` if the steps are needed separately

## Related Skills

- **ad-delayer** — Take a finished ad apart into editable layers. Run it first when the copy or the product has to change before resizing
- **bria-ai** — Full Bria API access: generate images, edit photos, remove objects, upscale, restyle, product photography, and 20+ more endpoints
- **image-utils** — Local post-processing with Python Pillow: plain resize, crop, composite, format conversion
- **remove-background** — One transparent PNG of the foreground subject (RMBG 2.0)

© Bria AI · MIT · Bria-AI/bria-skill

Похожие скиллы

Каталог скиллов SKILL.md →
find-skills vercel-labs Ищет и устанавливает готовые скиллы для ИИ-агентов через каталог skills.sh. Пригодится, когда для рабочей задачи нужен специализированный воркфлоу. CX Codex +1 4 000 000установок frontend-design официальный anthropics Скилл задаёт осмысленное визуальное направление для новых интерфейсов и редизайна. Подойдёт, когда стандартный шаблонный UI не устраивает. 1 025 790установок grill-me Matt Pocock Скилл проводит жёсткое интервью по плану или дизайну, чтобы найти пробелы и уточнить решения. Подойдёт перед началом разработки. 1 424 476установок grill-with-docs Matt Pocock Скилл проводит жёсткое интервью по плану или дизайну и по ходу создаёт ADR и глоссарий. Подойдёт перед началом сложной разработки. 1 219 756установок improve-codebase-architecture Matt Pocock Скилл ищет архитектурные узкие места в кодовой базе и показывает варианты углубления модулей в HTML-отчёте. Подойдёт для ревью перед рефакторингом. 1 163 035установок design-taste-frontend Leonxlnx Скилл задаёт арт-дирекцию для публичных страниц и рабочих экранов, а затем проверяет результат в браузере по скриншотам. Нужен, когда интерфейс выглядит шаблонным или недоработанным. CX Codex +1 678 700установок

Из того же набора8

bria-ai Скилл подключает API Bria.ai к агенту: генерация картинок по тексту, удаление фона, предметная съёмка и апскейл. Пригодится, когда нужны изображения прямо в проекте. CX Codex +1 ★ 73звёзд репо video-remove-background Убирает фон в видео через API Bria и готовит клип с прозрачным или однотонным фоном. Пригодится для вырезания движущегося объекта и создания видео для наложения. CX Codex +1 ★ 73звёзд репо vgl Скилл превращает запрос на картинку в структурированный VGL JSON: положение объектов, свет, ракурс, фокусное расстояние и стиль задаются явно. CX Codex +1 ★ 73звёзд репо remove-background Удаляет фон с фотографий и генерирует прозрачные PNG через модель Bria RMBG 2.0. Помогает вырезать объекты для карточек товаров или коллажей. CX Codex +1 ★ 73звёзд репо image-utils Скилл обрабатывает пиксели через Pillow: меняет размер и формат, обрезает кадр, добавляет водяные знаки. Пригодится для подготовки изображений к вебу и пакетной обработки. CX Codex +1 ★ 73звёзд репо ecommerce Превращает папку сырых фото товара в пакшоты, вырезы, размерные картинки и варианты листингов для Amazon, Shopify и Etsy. CX Codex +1 ★ 73звёзд репо ad-delayer Разбирает готовый плоский баннер на отдельные слои: фон, товар, логотип, заголовок, текст и CTA. Пригодится, когда исходник потерян, а макет нужен в новом размере. CX Codex +1 ★ 73звёзд репо

Спонсоры проекта

Компании, которые помогают держать аналитику открытой