Skip to content

gooseworks-ai/goose-skills / skills/shared/remix-graphic-ad-from-reference

remix-graphic-ad-from-reference

Verified

Recreate a static graphic ad (Pinterest pin, IG/FB feed image, poster) from a reference image, swapping in a new brand's product and new copy while keeping the reference's layout, composition, and visual energy. ALWAYS generated with GPT Image 2 in edit-the-reference mode (fal-ai/gpt-image-1/edit-image, a billed FAL generation); the HTML/goose-graphics overlay is only an optional text-finishing step, never the generator. The static-graphics counterpart to the video remix-ad skill; this is what the app calls when a user picks a reference ad and wants it for their own product.

FileKindSize
SKILL.mdskill md18.9 KB
assets/overlay-template.htmlother4.8 KB
requirements.txtmanifest119 B
scripts/cutout_product.pyscript2.7 KB
skill.meta.jsonconfig445 B
tests/expected-output.mdmarkdown1020 B
tests/human-test.mdmarkdown897 B
tests/sample-input.mdmarkdown1019 B
tests/smoke-test.mdmarkdown1.0 KB
tests/verifier.mdmarkdown1.1 KB

scripts/cutout_product.py

View on GitHub
#!/usr/bin/env python3
"""Cut a product out to a transparent PNG for the HTML-overlay remix path.

Handles two common cases automatically:
  1. Renders that already ship palette/alpha transparency  -> just normalize to RGBA + autocrop.
  2. Product on a white/solid background                   -> edge-connected flood fill, which
     removes the background WITHOUT punching holes in interior white logos/text on the label.

Usage:
  python3 cutout_product.py SRC [OUT] [--thresh 42] [--preview sky]
"""
import sys, argparse
from PIL import Image, ImageDraw, ImageFilter
import numpy as np

PREVIEW_BG = {"sky": (150, 180, 228), "white": (255, 255, 255), "magenta": (255, 0, 255)}


def already_transparent(im_rgba):
    a = np.array(im_rgba)[:, :, 3]
    return (a < 10).mean() > 0.02  # >2% fully-transparent pixels => has a real alpha channel


def floodfill_bg(rgb, thresh):
    w, h = rgb.size
    SENT = (255, 0, 255)
    work = rgb.copy()
    seeds = [(x, 0) for x in range(0, w, 10)] + [(x, h - 1) for x in range(0, w, 10)]
    seeds += [(0, y) for y in range(0, h, 10)] + [(w - 1, y) for y in range(0, h, 10)]
    for sx, sy in seeds:
        r, g, b = work.getpixel((sx, sy))
        if min(r, g, b) > 175:  # only seed on light background pixels
            ImageDraw.floodfill(work, (sx, sy), SENT, thresh=thresh)
    arr = np.array(work)
    mask = np.all(arr == SENT, axis=-1)
    out = np.dstack([np.array(rgb), np.where(mask, 0, 255).astype("uint8")])
    return Image.fromarray(out, "RGBA")


def main():
    ap = argparse.ArgumentParser()
    ap.add_argument("src")
    ap.add_argument("out", nargs="?", default="product-cutout.png")
    ap.add_argument("--thresh", type=int, default=42, help="flood-fill tolerance for white-bg case")
    ap.add_argument("--preview", choices=list(PREVIEW_BG), help="also write <out>.preview.png on a bg")
    args = ap.parse_args()

    src_rgba = Image.open(args.src).convert("RGBA")
    if already_transparent(src_rgba):
        rgba = src_rgba
    else:
        rgba = floodfill_bg(Image.open(args.src).convert("RGB"), args.thresh)

    # feather edge to kill halo, then autocrop to content
    alpha = rgba.split()[3].filter(ImageFilter.GaussianBlur(0.8))
    rgba.putalpha(alpha)
    bbox = rgba.getbbox()
    if bbox:
        rgba = rgba.crop(bbox)
    rgba.save(args.out)
    frac = round((np.array(rgba)[:, :, 3] < 10).mean(), 3)
    print(f"saved {args.out} size={rgba.size} transparent_frac={frac}")

    if args.preview:
        bg = Image.new("RGBA", rgba.size, PREVIEW_BG[args.preview] + (255,))
        bg.alpha_composite(rgba)
        p = args.out + ".preview.png"
        bg.convert("RGB").save(p)
        print(f"preview {p}")


if __name__ == "__main__":
    main()
reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.Stars: 322kUpdated Claude CodeCodexVerifiedInstall
dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependenciesStars: 322kUpdated Claude CodeCodexVerifiedInstall
executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is availableStars: 322kUpdated Claude CodeCodexVerifiedInstall