创建与编辑图形设计素材:图标、网站图标、图像及色彩系统。
| 任务 | 工具 | 理由 |
|---|---|---|
| AI 图像生成 | nano-banana-pro | 根据文本提示生成图像 |
| 图像缩放/转换 | sips | macOS 原生工具,速度快,无额外依赖 |
| 高级图像处理 | ImageMagick | 合成、特效、批量处理 |
| 图标与徽标 | SVG | 可缩放、文件小、可编辑 |
| 屏幕截图 | screencapture | macOS 原生工具 |
从单个 1024x1024 源图标生成所有所需尺寸。
#!/bin/bash
# generate-app-icons.sh <source-1024.png> <output-dir>
SOURCE="$1"
OUTDIR="${2:-.}"
mkdir -p "$OUTDIR"
SIZES=(16 20 29 32 40 48 58 60 64 76 80 87 120 128 152 167 180 256 512 1024)
for SIZE in "${SIZES[@]}"; do
sips -z $SIZE $SIZE "$SOURCE" --out "$OUTDIR/icon-${SIZE}x${SIZE}.png" 2>/dev/null
done
echo "已在 $OUTDIR 中生成 ${#SIZES[@]} 种图标尺寸"
# Android 自适应图标尺寸
declare -A ANDROID_SIZES=(
["mdpi"]=48 ["hdpi"]=72 ["xhdpi"]=96
["xxhdpi"]=144 ["xxxhdpi"]=192
)
for DENSITY in "${!ANDROID_SIZES[@]}"; do
SIZE=${ANDROID_SIZES[$DENSITY]}
mkdir -p "res/mipmap-$DENSITY"
sips -z $SIZE $SIZE "$SOURCE" --out "res/mipmap-$DENSITY/ic_launcher.png"
done
#!/bin/bash
# generate-favicons.sh <source.png> <output-dir>
SOURCE="$1"
OUTDIR="${2:-.}"
mkdir -p "$OUTDIR"
# 标准网页图标
sips -z 16 16 "$SOURCE" --out "$OUTDIR/favicon-16x16.png"
sips -z 32 32 "$SOURCE" --out "$OUTDIR/favicon-32x32.png"
sips -z 180 180 "$SOURCE" --out "$OUTDIR/apple-touch-icon.png"
sips -z 192 192 "$SOURCE" --out "$OUTDIR/android-chrome-192x192.png"
sips -z 512 512 "$SOURCE" --out "$OUTDIR/android-chrome-512x512.png"
# ICO 文件(需要 ImageMagick)
magick "$OUTDIR/favicon-16x16.png" "$OUTDIR/favicon-32x32.png" "$OUTDIR/favicon.ico"
echo "网站图标已在 $OUTDIR 中生成"
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
<link rel="manifest" href="/site.webmanifest">
{
"name": "我的应用",
"short_name": "应用",
"icons": [
{ "src": "/android-chrome-192x192.png", "sizes": "192x192", "type": "image/png" },
{ "src": "/android-chrome-512x512.png", "sizes": "512x512", "type": "image/png" }
],
"theme_color": "#ffffff",
"background_color": "#ffffff",
"display": "standalone"
}
根据主色调生成完整调色板:
// 基于 HSL 的调色板生成
function generatePalette(hue, saturation = 70) {
return {
50: `hsl(${hue}, ${saturation}%, 97%)`,
100: `hsl(${hue}, ${saturation}%, 94%)`,
200: `hsl(${hue}, ${saturation}%, 86%)`,
300: `hsl(${hue}, ${saturation}%, 74%)`,
400: `hsl(${hue}, ${saturation}%, 62%)`,
500: `hsl(${hue}, ${saturation}%, 50%)`, // 主色调
600: `hsl(${hue}, ${saturation}%, 42%)`,
700: `hsl(${hue}, ${saturation}%, 34%)`,
800: `hsl(${hue}, ${saturation}%, 26%)`,
900: `hsl(${hue}, ${saturation}%, 18%)`,
950: `hsl(${hue}, ${saturation}%, 10%)`,
};
}
# 调整尺寸
magick input.png -resize 800x600 output.png
# 转换格式
magick input.png output.webp
# 添加边框
magick input.png -border 10 -bordercolor "#333" output.png
# 圆角(带透明度)
magick input.png \( +clone -alpha extract -draw "roundrectangle 0,0,%[w],%[h],20,20" \) -alpha off -compose CopyOpacity -composite output.png
# 合成 / 叠加
magick base.png overlay.png -gravity center -composite output.png
# 批量调整所有 PNG 尺寸
magick mogrify -resize 50% *.png
# 创建纯色图像
magick -size 1200x630 xc:"#1a1a2e" output.png
# 在图像上添加文字
magick input.png -gravity south -pointsize 24 -fill white -annotate +0+20 "说明文字" output.png
# 调整尺寸(保持宽高比)
sips --resampleWidth 800 input.png --out output.png
# 精确调整尺寸
sips -z 600 800 input.png --out output.png
# 转换格式
sips -s format jpeg input.png --out output.jpg
# 获取图像信息
sips -g all input.png
# 旋转
sips --rotate 90 input.png --out output.png