Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

image-analysis

БесплатноБез исполняемых скриптовНе проверен

Turns an image into facts an agent can build from: file properties, a color palette with the area each color covers, the colors and sizes of individual…

TerminalSkillsот TerminalSkills★ 221 звезда на GitHub

Об этом скилле

Image Analysis

Overview

An image holds two kinds of information. Some of it can be measured from the pixels: dimensions, format, transparency, which colors cover how much area, where an element sits and how large it is. The rest has to be seen: how the layout is organized, what the hierarchy is, what the picture feels like. This skill gives the agent a script for the first kind, a way of looking for the second, and one rule that keeps them apart: every number in the answer comes from the pixels, never from an impression.

Instructions

1. Find out what the result is for

  • Building a UI from a screenshot or mockup: exact colors per role, element sizes and spacing, delivered as CSS variables or a Tailwind theme.
  • A palette from a photo or artwork: five to eight representative colors with their weight, plus the small accents.
  • Checking an asset: format, dimensions, transparency, orientation, color profile, animation.
  • Describing a reference: a written brief of layout and style backed by measured values.

Ask where the result goes (stylesheet, token file, design note) when the request does not say.

2. Measure

python3 -m venv .venv
.venv/bin/pip install pillow

Save as analyze.py:

#!/usr/bin/env python3
"""Facts about an image: file properties and a color palette with area shares.
analyze.py IMAGE [--colors 8] [--region X,Y,W,H] [--method auto|exact|quantize]"""
import argparse, collections, colorsys, io, json, os
from PIL import Image, ImageCms, ImageOps

p = argparse.ArgumentParser()
p.add_argument('image')
p.add_argument('--colors', type=int, default=8)
p.add_argument('--region', help='analyze only this rectangle: X,Y,W,H in pixels')
p.add_argument('--method', choices=['auto', 'exact', 'quantize'], default='auto')
args = p.parse_args()

im = Image.open(args.image)
facts = {'file': args.image, 'bytes': os.path.getsize(args.image), 'format': im.format, 'mode': im.mode,
         'frames': getattr(im, 'n_frames', 1), 'dpi': [round(float(v)) for v in im.info['dpi']] if 'dpi' in im.info else None,
         'exif_orientation': im.getexif().get(0x0112), 'color_profile': None}
if im.info.get('icc_profile'):
    facts['color_profile'] = ImageCms.getProfileDescription(ImageCms.ImageCmsProfile(io.BytesIO(im.info['icc_profile']))).strip()

im = ImageOps.exif_transpose(im).convert('RGBA')   # upright, first frame, one pixel layout for every format
facts['size'] = list(im.size)                      # as displayed, after applying the EXIF orientation
if args.region:
    x, y, w, h = (int(v) for v in args.region.split(','))
    im = im.crop((x, y, x + w, y + h))
    facts['region'] = [x, y, w, h]
alpha = im.getchannel('A').histogram()
visible = sum(alpha[1:])
facts['transparent_percent'] = round(100 * alpha[0] / (im.width * im.height), 2)
facts['partly_transparent_percent'] = round(100 * sum(alpha[1:255]) / (im.width * im.height), 2)

def describe(rgb, share):
    h, l, s = colorsys.rgb_to_hls(*(v / 255 for v in rgb))
    return {'hex': '#%02x%02x%02x' % tuple(rgb), 'rgb': list(rgb), 'share': round(share, 2),
            'hsl': [round(h * 360), round(s * 100), round(l * 100)]}

# Exact counts over visible pixels. Flat artwork (UI, logos, charts) has a few colors covering nearly everything.
counts = sorted(((n, c[:3]) for n, c in im.getcolors(im.width * im.height) if c[3] > 0), reverse=True)
facts['distinct_colors'] = len(counts)
top_cover = 100 * sum(n for n, _ in counts[:args.colors]) / max(visible, 1)
facts['top_colors_cover_percent'] = round(top_cover, 1)
method = args.method if args.method != 'auto' else ('exact' if top_cover >= 60 else 'quantize')
facts['method'] = method

def merged(counts, radius=3, limit=2000):
    """Fold near-identical colors (compression noise, anti-aliasing steps) into the most common neighbor."""
    kept = []
    for n, c in counts[:limit]:
        for k in kept:
            if max(abs(a - b) for a, b in zip(c, k[1])) <= radius:
                k[0] += n
                break
        else:
            kept.append([n, c])
    return sorted(kept, reverse=True)

groups = merged(counts)
facts['accents'] = []
if method == 'exact':
    ranked = [describe(c, 100 * n / visible) for n, c in groups]
    facts['palette'] = ranked[:args.colors]
    # Small but loud: saturated colors the area ranking dropped (buttons, links, badges).
    apart = lambda g: all(max(abs(a - b) for a, b in zip(g['rgb'], e['rgb'])) > 24 for e in facts['palette'])
    facts['accents'] = [g for g in ranked[args.colors:] if g['hsl'][1] >= 50 and 20 <= g['hsl'][2] <= 80
                        and g['share'] >= 0.05 and apart(g)][:4]
else:  # photographs and gradients: group similar pixels; each entry is the average of its group, not a pixel value
    small, mask = im.convert('RGB'), im.getchannel('A')
    small.thumbnail((400, 400), Image.Resampling.BOX)
    mask.thumbnail((400, 400), Image.Resampling.BOX)
    raw = small.tobytes()
    seen = b''.join(raw[3 * i:3 * i +
Полный SKILL.md на GitHub

Установить image-analysis в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

_scores.json

FAQ

Что делает скилл image-analysis?

Turns an image into facts an agent can build from: file properties, a color palette with the area each color covers, the colors and sizes of individual elements, and a structured description of layout and style. Use when someone asks to "extract the colors from this screenshot", "get a palette from this photo", "match my CSS to this mockup", "what colors and sizes does this design use", "describe this reference image", or "why does this image look wrong". Produces CSS variables, a Tailwind theme block or a written brief.

Как установить скилл image-analysis?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл image-analysis запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

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

Сравнить image-analysis с