跳到正文
Skillpedia
图片与图标48k · #4601

favicon

它能做什么

这个工具可以根据一张图片,自动为你的网站生成所需的各种图标(称为 favicon,即网站图标)。它还会更新网站代码,确保这些图标能正确显示。

适用场景

  • ✓上线新网站、需要配置图标时。
  • ✓更换网站主 logo 图片时。
  • ✓想确保网站在各种设备和浏览器上都显示良好时。

技能链接

https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/favicon/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/favicon/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“用我的图片 logo.png 为网站生成 favicon。”

每周 5 个新技能,1 分钟读完。

工作原理

工具会先检查图片是否有效。然后判断你使用的是哪种网站框架(比如 Rails、Next.js 等),以确定图标应放在哪里。最后生成所有所需尺寸的图标,并把相应的配置添加到你的网站中,使图标能正常工作。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Generate a complete set of favicons from the source image at $1 and update the project's HTML with the appropriate link tags.

When to Use

  • You need to generate a complete favicon set from a single source image.
  • The task includes placing the assets in the correct framework-specific static directory and updating HTML link tags.
  • You want one workflow that validates the source image, detects the project type, and writes the right favicon outputs.

Prerequisites

First, verify ImageMagick v7+ is installed by running:

which magick

If not found, stop and instruct the user to install it:

  • macOS: brew install imagemagick
  • Linux: sudo apt install imagemagick

Step 1: Validate Source Image

  1. Verify the source image exists at the provided path: $1
  2. Check the file extension is a supported format (PNG, JPG, JPEG, SVG, WEBP, GIF)
  3. If the file doesn't exist or isn't a valid image format, report the error and stop

Note whether the source is an SVG file - if so, it will also be copied as favicon.svg.

Step 2: Detect Project Type and Static Assets Directory

Detect the project type and determine where static assets should be placed. Check in this order:

Framework Detection Static Assets Directory
Rails config/routes.rb exists public/
Next.js next.config.* exists public/
Gatsby gatsby-config.* exists static/
SvelteKit svelte.config.* exists static/
Astro astro.config.* exists public/
Hugo hugo.toml or config.toml with Hugo markers static/
Jekyll _config.yml with Jekyll markers Root directory (same as index.html)
Vite vite.config.* exists public/
Create React App package.json has react-scripts dependency public/
Vue CLI vue.config.* exists public/
Angular angular.json exists src/assets/
Eleventy .eleventy.js or eleventy.config.* exists Check _site output or root
Static HTML index.html in root Same directory as index.html

Important: If existing favicon files are found (e.g., favicon.ico, apple-touch-icon.png), use their location as the target directory regardless of framework detection.

Report the detected project type and the static assets directory that will be used.

When in doubt, ask: If you are not 100% confident about where static assets should be placed (e.g., ambiguous project structure, multiple potential locations, unfamiliar framework), use AskUserQuestionTool to confirm the target directory before proceeding. It's better to ask than to put files in the wrong place.

Step 3: Determine App Name

Find the app name from these sources (in priority order):

  1. Existing site.webmanifest - Check the detected static assets directory for an existing manifest and extract the name field
  2. package.json - Extract the name field if it exists
  3. Rails config/application.rb - Extract the module name (e.g., module MyApp → "MyApp")
  4. Directory name - Use the current working directory name as fallback

Convert the name to title case if needed (e.g., "my-app" → "My App").

Step 4: Ensure Static Assets Directory Exists

Check if the detected static assets directory exists. If not, create it.

Step 5: Generate Favicon Files

Run these ImageMagick commands to generate all favicon files. Replace [STATIC_DIR] with the detected static assets directory from Step 2.

Important: The -background none flag must come BEFORE the input file to properly preserve transparency when rendering SVGs. Placing it after the input will result in a white background.

favicon.ico (multi-resolution: 16x16, 32x32, 48x48)

magick -background none "$1" \
  \( -clone 0 -resize 16x16 \) \
  \( -clone 0 -resize 32x32 \) \
  \( -clone 0 -resize 48x48 \) \
  -delete 0 -alpha on \
  [STATIC_DIR]/favicon.ico

favicon-96x96.png

magick -background none "$1" -resize 96x96 -alpha on [STATIC_DIR]/favicon-96x96.png

apple-touch-icon.png (180x180)

magick -background none "$1" -resize 180x180 -alpha on [STATIC_DIR]/apple-touch-icon.png

web-app-manifest-192x192.png

magick -background none "$1" -resize 192x192 -alpha on [STATIC_DIR]/web-app-manifest-192x192.png

web-app-manifest-512x512.png


…
常见问题

需要先安装什么吗?

需要。你的电脑上要安装 ImageMagick 程序。macOS 和 Linux 的安装说明在文档中都有提供。

什么是 favicon?

favicon 是那些出现在浏览器标签页、书签中,或者你把网站保存到手机主屏幕时显示的小图标。

如果我的网站使用其他框架怎么办?

工具会尝试自动识别你的网站类型(如 Rails、Next.js 等),并把图标放到正确的位置。如果无法确定,可能会询问你文件应该放在哪里。

详情

作者的原始描述

Generate favicons from a source image

repo: sickn33/agentic-awesome-skills

热度

GitHub 星标
48k
排名
#4601
许可证
MIT
更新时间
2026/10/15

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能