跳转至
quickthumb
全部文档

播客宣传图

播客访谈宣传图

单集卡片:包含节目名、单集标题和嘉宾信息,右侧填满嘉宾照片。

安装 uv 并克隆代码仓库即可运行此示例:

git clone https://github.com/sjquant/quickthumb
cd quickthumb
uv run python examples/podcast_interview_promo.py

该脚本将写入 examples/podcast_interview_promo.png,并覆盖同名旧文件。

首次运行时需要联网下载节目名称所需的网络字体,之后将自动使用本地缓存。

构成方式

  • 人像照片作为背景。 .background(image=..., fit=FitMode.COVER) 用照片铺满整个画布。无需抠图,自然也没有需要修整的抠图边缘。
  • 渐变留出文字空间。 带有四个停靠点的 LinearGradient 在文案后方呈现纯黑,在面部上方完全透明。移动中间的停靠点可调整渐变消失的位置。
  • 节目名称使用网络字体。 font=SHOW_FONT_URL 指向 Google Fonts 上的 .ttf 文件。由于 URL 指向的文件本身已具有特定样式,因此 weight、bold 和 italic 对字体 URL 不生效。
  • 仅使用一种点缀色。 节目名称下方简短的红线是卡片上唯一的彩色元素;其余部分均为白色或灰色。

代码

"""
Podcast / interview promo example.

Demonstrates:
- Local editorial portrait assets used as full-bleed backgrounds
- Webfont loading from a URL for the show title
- Tonal gradients that preserve portrait detail behind high-contrast copy
"""

import os

from quickthumb import Canvas, FitMode, LinearGradient

FILE_DIR = os.path.dirname(__file__)
ASSETS_DIR = os.path.join(FILE_DIR, "..", "assets")
OUTPUT_PATH = os.path.join(FILE_DIR, "podcast_interview_promo.png")

os.environ["QUICKTHUMB_FONT_DIR"] = os.path.join(ASSETS_DIR, "fonts")
os.environ["QUICKTHUMB_DEFAULT_FONT"] = "Roboto"

GUEST_IMAGE_PATH = os.path.join(ASSETS_DIR, "images", "podcast-guest-editorial.png")
SHOW_FONT_URL = "https://fonts.gstatic.com/s/dmserifdisplay/v17/-nFnOHM81r4j6k0gjAW3mujVU2B2K_c.ttf"

(
    Canvas(1280, 720)
    .background(
        image=GUEST_IMAGE_PATH,
        fit=FitMode.COVER,
    )
    .background(
        gradient=LinearGradient(
            angle=0,
            stops=[
                ("#000000", 0.0),
                ("#000000F7", 0.48),
                ("#00000030", 0.72),
                ("#00000000", 1.0),
            ],
        )
    )
    .text(
        content="EPISODE 06",
        size=18,
        color="#A1A1A6",
        weight=800,
        letter_spacing=3,
        position=(64, 54),
    )
    .text(
        content="Signal to Noise",
        font=SHOW_FONT_URL,
        size=50,
        color="#F5F5F7",
        position=(62, 88),
    )
    .shape(
        shape="rectangle",
        position=(64, 158),
        width=96,
        height=6,
        color="#FF453A",
    )
    .text(
        content="HOW GREAT TEAMS\nBUILD BETTER\nFEEDBACK LOOPS",
        size=68,
        color="#F5F5F7",
        weight=700,
        line_height=0.98,
        position=(58, 188),
    )
    .text(
        content="Shipping faster — without breaking trust.",
        size=27,
        color="#A1A1A6",
        position=(64, 424),
        max_width=570,
        line_height=1.25,
    )
    .shape(
        shape="rectangle",
        position=(64, 536),
        width=420,
        height=1,
        color="#FFFFFF33",
    )
    .text(
        content="GUEST",
        size=15,
        color="#A1A1A6",
        weight=700,
        letter_spacing=3,
        position=(64, 558),
    )
    .text(
        content="Mina Park",
        font=SHOW_FONT_URL,
        size=38,
        color="#F5F5F7",
        position=(62, 582),
    )
    .text(
        content="AI Product Lead",
        size=19,
        color="#86868B",
        weight=500,
        position=(66, 630),
    )
    .render(OUTPUT_PATH)
)

print(f"✓ Podcast / interview promo created: {OUTPUT_PATH}")
print("  This example requires network access only for the display webfont.")

若想在同一版式中使用抠图后的人像而非满版照片,请参阅网络字体与背景移除。