Skill: efficiency97/tweet-share-card (version 0.1.0)

--- name: tweet-share-card description: Turn an X/Twitter post link into a share image. Use when the user sends an X/Twitter URL and wants a polished share card image: detect the tweet URL, capture the tweet content area, place it onto a pink poster-style background, and send the final image back. --- Create a share image from an X/Twitter post. ## When to use - User sends an `x.com` / `twitter.com` post URL - User wants a tweet screenshot, share card, poster, or social-share image - User wants the final image sent back in chat ## Workflow 1. Extract the tweet URL from the user message. 2. Open the tweet in the dedicated visible Chrome profile/session already used for X login. 3. Capture the **tweet content area only**: - keep avatar/name/text/link preview - exclude right sidebar - exclude reply/action counts when possible - do not rewrite or re-typeset tweet text 4. Parse any user-requested color style (examples: `pink`, `blue-purple`, `purple-blue`, `peach`, `mint`). 5. Composite the captured tweet area onto a poster background using that style. 6. Save the final image under `workspace/tmp/`. 7. Send the final image back to the user. ## Rules - Prefer the user's logged-in **dedicated Chrome profile**, not their default browser profile. - Do **not** use headless/embed screenshots if they produce blank/incorrect tweet content. - The tweet content must be a real screenshot, not re-rendered fake text. - Default background style: clean pink poster style. - Support color presets when the user asks, including `pink`, `blue-purple`, `purple-blue`, `peach`, and `mint`. - Default output is a square share card with a peach background unless the user asks for another preset. - The white content card should adapt to content height instead of using a fixed internal height. - Preserve the tweet content area without cropping away core text. - Always inspect the result before sending if the capture path changed. ## Output Return the final image directly to the user with a short caption only if needed. ## Scripts - `python3 {Skills Directory}/tweet-share-card/scripts/capture_visible_tweet.py <tweet_url> <output_png>` - `python3 {Skills Directory}/tweet-share-card/scripts/compose_pink_card.py <tweet_capture_png> <output_png> [pink|blue-purple|purple-blue|peach|mint]`

path: README.md
content: # tweet-share-card

Turn an X/Twitter post link into a polished share image.

## What it does

- Detects an `x.com` / `twitter.com` post link
- Reads the tweet content
- Generates a square share card image
- Uses **peach** as the default background style
- Supports alternate presets like `blue-purple`, `purple-blue`, `pink`, and `mint`
- Can include tweet metrics such as replies, likes, and views

## Example prompts

- `https://x.com/... 生成推文分享卡片`
- `https://x.com/... 制作推文分享卡片，蓝紫渐变`
- `https://x.com/... make a tweet share card with mint background`

## Default behavior

- Default color: **peach**
- Square poster output
- White inner content card adapts to content height
- Preserves the main tweet content without arbitrary cropping of core text

## Status

This skill is already usable and focuses on a practical workflow:

1. detect tweet link
2. render a shareable card
3. send image back to the user

Future improvements can refine more layout templates and richer media handling.


path: scripts/capture_visible_tweet.py
content: #!/usr/bin/env python3
import subprocess
import sys
from pathlib import Path
from PIL import Image

if len(sys.argv) != 3:
    print('usage: capture_visible_tweet.py <tweet_url> <output_png>', file=sys.stderr)
    sys.exit(1)

url = sys.argv[1]
out = Path(sys.argv[2]).expanduser().resolve()
out.parent.mkdir(parents=True, exist_ok=True)

script = f'''
tell application "Google Chrome"
  activate
  if (count of windows) = 0 then make new window
  tell front window
    set URL of active tab to "{url}"
  end tell
  delay 2
  set b to bounds of front window
  set u to URL of active tab of front window
  return u & "\n" & ((item 1 of b as text) & "," & (item 2 of b as text) & "," & (item 3 of b as text) & "," & (item 4 of b as text))
end tell
'''
res = subprocess.check_output(['osascript', '-e', script]).decode().splitlines()
current_url = res[0].strip()
if 'x.com/' not in current_url and 'twitter.com/' not in current_url:
    raise SystemExit(f'Unexpected URL after navigation: {current_url}')
left, top, right, bottom = map(int, res[1].split(','))
raw = out.parent / (out.stem + '.window.png')
subprocess.check_call(['/usr/sbin/screencapture', '-x', '-R', f'{left},{top},{right-left},{bottom-top}', str(raw)])
img = Image.open(raw).convert('RGBA')
W, H = img.size
# Main tweet column crop for desktop X layout; conservative and left-column focused.
crop = img.crop((int(W * 0.07), int(H * 0.10), int(W * 0.62), int(H * 0.73)))
crop.save(out)
print(str(out))


path: scripts/compose_pink_card.py
content: #!/usr/bin/env python3
import sys
from pathlib import Path
from PIL import Image, ImageDraw, ImageFilter

PRESETS = {
    'pink': ((255, 228, 236), (255, 200, 220), (255, 242, 247)),
    'blue-purple': ((221, 229, 255), (167, 170, 255), (232, 221, 255)),
    'purple-blue': ((229, 220, 255), (151, 165, 255), (214, 235, 255)),
    'peach': ((255, 233, 220), (255, 198, 176), (255, 244, 235)),
    'mint': ((224, 248, 238), (173, 232, 214), (237, 252, 247)),
}

def make_bg(size, preset_name):
    c1, c2, c3 = PRESETS.get(preset_name, PRESETS['pink'])
    w, h = size
    bg = Image.new('RGBA', size, (*c1, 255))
    draw = ImageDraw.Draw(bg)
    for y in range(h):
        t = y / max(h - 1, 1)
        if t < 0.5:
            u = t / 0.5
            c = tuple(int(c1[i] * (1 - u) + c2[i] * u) for i in range(3))
        else:
            u = (t - 0.5) / 0.5
            c = tuple(int(c2[i] * (1 - u) + c3[i] * u) for i in range(3))
        draw.line((0, y, w, y), fill=(*c, 255))

    blobs = [
        ((-80, int(h * 0.58), int(w * 0.40), int(h * 1.05)), (*c2, 90), 90),
        ((int(w * 0.66), -40, int(w * 1.05), int(h * 0.34)), (*c3, 80), 100),
        ((int(w * 0.08), int(h * 0.08), int(w * 0.92), int(h * 0.92)), (255, 255, 255, 120), 130),
    ]
    for box, color, blur in blobs:
        ov = Image.new('RGBA', size, (0, 0, 0, 0))
        d = ImageDraw.Draw(ov)
        d.ellipse(box, fill=color)
        ov = ov.filter(ImageFilter.GaussianBlur(blur))
        bg = Image.alpha_composite(bg, ov)
    return bg

if len(sys.argv) not in (3, 4):
    print('usage: compose_pink_card.py <tweet_capture_png> <output_png> [preset]', file=sys.stderr)
    sys.exit(1)

src = Path(sys.argv[1]).expanduser().resolve()
out = Path(sys.argv[2]).expanduser().resolve()
preset = sys.argv[3].strip().lower() if len(sys.argv) == 4 else 'pink'
out.parent.mkdir(parents=True, exist_ok=True)

img = Image.open(src).convert('RGBA')
W = H = 1080
bg = make_bg((W, H), preset)
ratio = min(760 / img.size[0], 860 / img.size[1])
card = img.resize((int(img.size[0] * ratio), int(img.size[1] * ratio)), Image.LANCZOS)
card_mask = Image.new('L', card.size, 0)
ImageDraw.Draw(card_mask).rounded_rectangle((0, 0, card.size[0], card.size[1]), radius=24, fill=255)
x = (W - card.size[0]) // 2
y = (H - card.size[1]) // 2
bg.paste(card, (x, y), card_mask)
bg.save(out)
print(str(out))


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