post-process-logo
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChinesePost-process logo
徽标后处理
This skill transforms original logo images into standardised 256x256 PNG format suitable for vault protocol metadata. It automatically selects the most square variant from available logos and applies padding if needed to create a perfect square output.
该技能可将原始徽标图片转换为适用于vault协议元数据的标准化256x256 PNG格式。它会自动从可用徽标中选择最接近正方形的版本,并在需要时添加内边距以生成完美的正方形输出。
Required inputs
所需输入
Before starting, gather the following from the user:
- Input folder - Folder containing original logo files (e.g., )
eth_defi/data/vaults/original_logos/protocol-name/ - Output folder - Folder where processed logos should be saved (e.g., )
eth_defi/data/vaults/formatted_logos/ - Variant preference (optional) - Which variant(s) to process: ,
generic,light, ordarkall
If any required input is missing, ask the user before proceeding.
开始前,请向用户收集以下信息:
- 输入文件夹 - 包含原始徽标文件的文件夹(示例:)
eth_defi/data/vaults/original_logos/protocol-name/ - 输出文件夹 - 保存处理后徽标的文件夹(示例:)
eth_defi/data/vaults/formatted_logos/ - 版本偏好(可选)- 需要处理的版本:(通用)、
generic(浅色)、light(深色)或dark(全部)all
如果缺少任何必需的输入,请在继续前询问用户。
Prerequisites
前置条件
Ensure the following are available:
- Python dependencies installed:
poetry install --with dev
Python Pillow is installed for detecting image format, dimensions, and transparency.
确保满足以下条件:
- 已安装Python依赖:
poetry install --with dev
已安装Python Pillow库,用于检测图片格式、尺寸和透明度。
Logo vocabulary
徽标术语
There is no universal standard how artist name their logo files for dark and light variants. In our case, we always say
- : light (white) text on dark or transparent background
light - : dark (black) text on white or transparent background
dark
Following vocabulary is used:
- Brand mark: same as logo mark, the logo without the brand name text
- Word mark: the logo with the brand name text
对于深色和浅色版本的徽标文件,艺术家的命名没有通用标准。在我们的场景中,统一规定:
- :深色或透明背景上的浅色(白色)文字
light - :白色或透明背景上的深色(黑色)文字
dark
使用以下术语:
- Brand mark(品牌标志):与logo mark同义,指不含品牌名称文字的徽标
- Word mark(文字标志):包含品牌名称文字的徽标
Step 1: Inventory input logos
步骤1:清点输入徽标
List all image files in the input folder and classify them:
- Identify file formats: SVG, PNG, JPG, WEBP, etc.
- Classify by variant based on filename:
- - Generic/default theme
{slug}.generic.{ext} - - Light background theme (dark logo)
{slug}.light.{ext} - - Dark background theme (light logo)
{slug}.dark.{ext}
- Always prefer brand marks over word marks as source logo for post processing
- Check aspect ratio of each logo:
- Square aspect ratio: Width equals height (1:1 ratio). Allow 90% tolerance in the detection as there might be one-off pixel errors in the source material.
- Non-square: Width differs from height - will need padding to become square
- Check if logos have transparent backgrounds:
- Transparent background: PNG files with alpha channel transparency
- Assume SVGs are always transparent: SVG files the originals should never contain a solid background
- Report findings to user, noting aspect ratios for each variant
列出输入文件夹中的所有图片文件并进行分类:
- 识别文件格式:SVG、PNG、JPG、WEBP等
- 根据文件名按版本分类:
- - 通用/默认主题
{slug}.generic.{ext} - - 浅色背景主题(深色徽标)
{slug}.light.{ext} - - 深色背景主题(浅色徽标)
{slug}.dark.{ext}
- 后处理时,优先选择Brand mark而非Word mark作为源徽标
- 检查每个徽标的宽高比:
- 正方形宽高比:宽等于高(1:1比例)。检测时允许90%的容错率,因为源素材可能存在一次性像素错误
- 非正方形:宽高不等 - 需要添加内边距以变为正方形
- 检查徽标是否有透明背景:
- 透明背景:带有Alpha通道透明度的PNG文件
- 默认SVG始终为透明:原始SVG文件不应包含纯色背景
- 向用户报告清点结果,注明每个版本的宽高比
Step 2: Variant selection
步骤2:版本选择
Automatic selection priority
自动选择优先级
- Pick the most square variant: Calculate aspect ratio (min dimension / max dimension) for each variant and select the one closest to 1.0
- If multiple variants have the same squareness:
- Prefer transparent variants (PNG with alpha, SVG)
- If still tied, prefer generic > light > dark
- If user specified a variant preference: Use that variant regardless of squareness
- 选择最接近正方形的版本:计算每个版本的宽高比(最小尺寸/最大尺寸),选择最接近1.0的版本
- 如果多个版本的方正度相同:
- 优先选择透明版本(带Alpha通道的PNG、SVG)
- 如果仍有并列,优先级为:generic > light > dark
- 如果用户指定了版本偏好:无论方正度如何,都使用该版本
Step 3: Process logo
步骤3:处理徽标
Process the selected logo variant. The script will automatically add padding to non-square logos to make them square before scaling.
shell
export INPUT_IMAGE=/path/to/original/logo.png
export OUTPUT_IMAGE=/path/to/output/logo.generic.png
poetry run python scripts/logos/post-process-logo.pyThe script will:
- Convert SVG to PNG if needed
- Add transparent padding to make the logo square (if non-square)
- Remove background if not already transparent
- Recolour for dark background (invert colours if logo is too dark to be visible on dark backgrounds)
- Trim any excess padding and scale to 256x256
处理选定的徽标版本。脚本会在缩放前自动为非正方形徽标添加内边距,使其变为正方形。
shell
export INPUT_IMAGE=/path/to/original/logo.png
export OUTPUT_IMAGE=/path/to/output/logo.generic.png
poetry run python scripts/logos/post-process-logo.py脚本将执行以下操作:
- 如有需要,将SVG转换为PNG
- 添加透明内边距使徽标变为正方形(如果是非正方形)
- 如果背景不透明,则移除背景
- 针对深色背景重新着色(如果徽标在深色背景上过于暗淡无法看清,则反转颜色)
- 裁剪多余内边距并缩放到256x256
Step 4: Report results
步骤4:报告结果
Provide the user with:
- Processed files - List of all output files created
- File details - Dimensions, file size for each
- Any issues - Note any logos that couldn't be processed or had quality issues
向用户提供以下内容:
- 已处理文件 - 所有已创建的输出文件列表
- 文件详情 - 每个文件的尺寸、文件大小
- 问题说明 - 记录所有无法处理或存在质量问题的徽标
Output naming convention
输出命名规范
Output files should follow this naming pattern:
- - For light backgrounds
{protocol-slug}/light.png - - For dark backgrounds
{protocol-slug}/dark.png
输出文件应遵循以下命名模式:
- - 用于浅色背景
{protocol-slug}/light.png - - 用于深色背景
{protocol-slug}/dark.png
Troubleshooting
故障排除
SVG conversion issues
SVG转换问题
If SVG conversion fails:
- Check if the SVG file is valid XML
- Some complex SVGs may not render correctly
- Try opening in a browser to verify the SVG displays properly
如果SVG转换失败:
- 检查SVG文件是否为有效的XML
- 部分复杂SVG可能无法正确渲染
- 尝试在浏览器中打开以验证SVG是否正常显示
Background removal issues
背景移除问题
If the background isn't removed properly:
- The logo may have complex edges or gradients
- Try providing a higher resolution input
- For logos that already have transparency, the script will skip background removal
如果背景未正确移除:
- 徽标可能存在复杂边缘或渐变
- 尝试提供更高分辨率的输入
- 对于已具备透明度的徽标,脚本会跳过背景移除步骤