编程

Avatar Generator

试用

Generate customizable avatars in six styles with multi-platform export for social media including WeChat, QQ, Twitter, and Discord.

它能做什么

Professional avatar generator with 6 styles, multi-platform export, and customizable options.

技能文档

Avatar Generator

Professional avatar generator with 6 styles, multi-platform export, and customizable options.

Features

  • 🎨 6 Avatar Styles: Letter, Geometric, Gradient, Abstract, Pattern, Badge
  • 📱 Multi-Platform: Auto-export for 9+ platforms
  • 🎯 Customizable: Colors, shapes, sizes, fonts
  • ⚡ Fast Generation: Local Pillow rendering
  • 🌍 Multi-Language: Chinese and English support

Supported Platforms

PlatformSizeShapePriority
WeChat640×640Square⭐⭐⭐⭐⭐
QQ100×100Square⭐⭐⭐⭐⭐
Xiaohongshu400×400Round⭐⭐⭐⭐
Weibo200×200Round⭐⭐⭐⭐
Twitter/X400×400Round⭐⭐⭐⭐
Discord128×128Round⭐⭐⭐
Reddit256×256Round⭐⭐⭐
Facebook170×170Round⭐⭐⭐
LinkedIn400×400Square⭐⭐⭐

Avatar Styles

1. Letter Avatar (Initial Letter)

  • Single letter or initials
  • Clean background
  • Professional look
  • Best for: Business, professional

2. Geometric Avatar

  • Abstract shapes
  • Modern design
  • Eye-catching
  • Best for: Tech, creative

3. Gradient Avatar

  • Smooth color transitions
  • Trendy look
  • Customizable
  • Best for: Social media

4. Abstract Avatar

  • Artistic patterns
  • Unique design
  • Stand out
  • Best for: Creative, personal

5. Pattern Avatar

  • Repeating elements
  • Structured design
  • Brand identity
  • Best for: Teams, companies

6. Badge Avatar

  • Circular frame
  • Official look
  • Identity badge
  • Best for: Certification, ID

Trigger Conditions

  • "Generate avatar" / "生成头像"
  • "Create WeChat avatar" / "做微信头像"
  • "Make social media avatar" / "生成社交头像"
  • "avatar-generator"

Python Code

from PIL import Image, ImageDraw, ImageFont
import os
import colorsys
import random

class AvatarGenerator:
    def __init__(self):
        self.platforms = {
            'wechat': {'size': (640, 640), 'shape': 'square'},
            'qq': {'size': (100, 100), 'shape': 'square'},
            'xiaohongshu': {'size': (400, 400), 'shape': 'round'},
            'weibo': {'size': (200, 200), 'shape': 'round'},
            'twitter': {'size': (400, 400), 'shape': 'round'},
            'discord': {'size': (128, 128), 'shape': 'round'},
            'reddit': {'size': (256, 256), 'shape': 'round'},
            'facebook': {'size': (170, 170), 'shape': 'round'},
            'linkedin': {'size': (400, 400), 'shape': 'square'},
        }
    
    def _load_font(self, size):
        """Load font with fallback"""
        paths = [
            '/System/Library/Fonts/PingFang.ttc',
            '/System/Library/Fonts/STHeiti Light.ttc',
            '/usr/share/fonts/truetype/noto/NotoSansCJK-Regular.ttc',
        ]
        for p in paths:
            if os.path.exists(p):
                try:
                    return ImageFont.truetype(p, size)
                except:
                    continue
        return ImageFont.load_default()
    
    def create_letter_avatar(self, letter, bg_color, text_color, size=(400, 400)):
        """Style 1: Letter avatar"""
        img = Image.new('RGB', size, bg_color)
        draw = ImageDraw.Draw(img)
        
        font = self._load_font(size[0] // 2)
        
        bbox = draw.textbbox((0, 0), letter, font=font)
        w, h = bbox[2] - bbox[0], bbox[3] - bbox[1]
        x, y = (size[0] - w) // 2, (size[1] - h) // 2
        
        draw.text((x, y), letter, font=font, fill=text_color)
        return img
    
    def create_geometric_avatar(self, colors, size=(400, 400)):
        """Style 2: Geometric avatar"""
        img = Image.new('RGB', size, colors[0])
        draw = ImageDraw.Draw(img)
        
        # Add geometric shapes
        center = size[0] // 2
        draw.ellipse([(50, 50), (size[0]-50, size[1]-50)], fill=colors[1])
        draw.regular_polygon((center, center, size[0]//3), 6, fill=colors[2])
        
        return img
    
    def create_gradient_avatar(self, color1, color2, size=(400, 400)):
        """Style 3: Gradient avatar"""
        import numpy as np
        
        img = np.zeros((size[1], size[0], 3), dtype=np.uint8)
        for y in range(size[1]):
            ratio = y / size[1]
            r = int(color1[0] * (1-ratio) + color2[0] * ratio)
            g = int(color1[1] * (1-ratio) + color2[1] * ratio)
            b = int(color1[2] * (1-ratio) + color2[2] * ratio)
            img[y, :] = [r, g, b]
        
        return Image.fromarray(img)
    
    def create_abstract_avatar(self, seed, colors, size=(400, 400)):
        """Style 4: Abstract avatar"""
        random.seed(seed)
        img = Image.new('RGB', size, colors[0])
        draw = ImageDraw.Draw(img)
        
        for _ in range(10):
            x, y = random.randint(0, size[0]), random.randint(0, size[1])
            r = random.randint(20, 100)
            color = random.choice(colors[1:])
            draw.ellipse([(x-r, y-r), (x+r, y+r)], fill=color)
        
        return img
    
    def create_pattern_avatar(self, pattern_type, colors, size=(400, 400)):
        """Style 5: Pattern avatar"""
        img = Image.new('RGB', size, colors[0])
        draw = ImageDraw.Draw(img)
        
        cell_size = 40
        for x in range(0, size[0], cell_size):
            for y in range(0, size[1], cell_size):
                if (x // cell_size + y // cell_size) % 2 == 0:
                    draw.rectangle([(x, y), (x+cell_size, y+cell_size)], fill=colors[1])
        
        return img
    
    def create_badge_avatar(self, text, bg_color, border_color, size=(400, 400)):
        """Style 6: Badge avatar"""
        img = Image.new('RGB', size, (255, 255, 255))
        draw = ImageDraw.Draw(img)
        
        # Draw circular badge
        margin = 20
        draw.ellipse([(margin, margin), (size[0]-margin, size[1]-margin)], 
                     fill=bg_color, outline=border_color, width=5)
        
        # Add text
        font = self._load_font(size[0] // 4)
        bbox = draw.textbbox((0, 0), text, font=font)
        w, h = bbox[2] - bbox[0], bbox[3] - bbox[1]
        x, y = (size[0] - w) // 2, (size[1] - h) // 2
        draw.text((x, y), text, font=font, fill='white')
        
        return img
    
    def make_round(self, img):
        """Make image circular"""
        size = img.size
        mask = Image.new('L', size, 0)
        draw = ImageDraw.Draw(mask)
        draw.ellipse([(0, 0), size], fill=255)
        
        result = Image.new('RGBA', size, (0, 0, 0, 0))
        result.paste(img, mask=mask)
        return result
    
    def export_multi_platform(self, img, output_dir, platforms=None):
        """Export for multiple platforms"""
        os.makedirs(output_dir, exist_ok=True)
        
        if platforms is None:
            platforms = list(self.platforms.keys())
        
        exported = []
        for platform in platforms:
            if platform in self.platforms:
                config = self.platforms[platform]
                resized = img.resize(config['size'], Image.LANCZOS)
                
                if config['shape'] == 'round':
                    resized = self.make_round(resized)
                
                path = os.path.join(output_dir, f'avatar_{platform}.png')
                resized.save(path)
                exported.append(path)
        
        return exported

# Example usage
gen = AvatarGenerator()

# Letter avatar
avatar1 = gen.create_letter_avatar('Z', (30, 60, 114), (255, 255, 255))

# Gradient avatar
avatar2 = gen.create_gradient_avatar((67, 142, 219), (30, 60, 114))

# Export to all platforms
gen.export_multi_platform(avatar1, 'output/')

Usage Examples

User: "Generate a WeChat avatar with blue background and white Z"
Agent: Create 640×640 letter avatar

User: "Make a gradient avatar for Xiaohongshu"
Agent: Create 400×400 round gradient avatar

User: "Create social media avatars"
Agent: Generate avatars for all platforms

Notes

  • All avatars generated locally with Pillow
  • No external API required
  • Cross-platform compatible
  • Supports Chinese and English text

相关技能

把自然语言描述转为结构化 JSON,并由 mcp-diagram-generator MCP 服务生成 Draw.io、Mermaid 或 Excalidraw 图表文件。

作者 nssa.io1.0k 次安装47 星标

在本地磁盘以分类纯 Markdown 文件保存需要长期留存的事实,与智能体内置记忆并存。

作者 Iván559 次安装18 星标

以 AI 机器人身份加入视频会议,提供语音、虚拟形象与屏幕共享四种模式。

作者 johnpatternai22 次安装8 星标

诊断生产力系统反复失效的根因,给出最小干预——容量测算、瓶颈定位、可靠的本地记录。

作者 Iván855 次安装69 星标

从 AdMapix API 拉取广告创意、应用、榜单和收入预估等数据,原样返回结构化 JSON。

作者 fly0pants4.3k 次安装296 星标

tobewin 的更多技能

浏览全部技能

用一份 JSON 描述就能生成标准可编辑的 PPTX,自带 11 种版式与 5 套配色。

作者 ToBeWin329 次安装3 星标

把 Word、PDF、Excel、PowerPoint、HTML、Markdown 与 TXT 文档翻译成另一种语言,同时保留原始排版。

作者 tobewin36 次安装1 星标

Professional Excel spreadsheet generator. Use when user needs to create data tables, reports, charts, financial models, or any structured data in Excel forma...

作者 ToBeWin82 次安装3 星标

中国新闻资讯聚合工具。Use when user wants to get latest news from Chinese sources. Supports multiple news sites (Sina, Sohu, NetEase, Tencent) via browser automation an...

作者 ToBeWin57 次安装3 星标

Data analysis tool for Excel, CSV, Word, PDF, TXT, Markdown files. Use when user needs to analyze, summarize, or compare data from multiple files. Supports f...

作者 ToBeWin68 次安装1 星标

Marketing plan generator with web research and Word output. Use when user needs to create marketing plans, promotional campaigns, social media strategies. Fe...

作者 ToBeWin31 次安装1 星标