{"id":28469108,"url":"https://github.com/star-plan/sharp-ico","last_synced_at":"2026-01-21T13:25:27.959Z","repository":{"id":293960706,"uuid":"985619963","full_name":"star-plan/sharp-ico","owner":"star-plan","description":"SharpIco is a lightweight, pure C# icon generator that converts a single high-res PNG into a fully compliant multi-resolution Windows .ico file (from 16x16 to 256x256). No ImageMagick. No Node. No Python. Just .NET. SharpIco 是一个纯 C# 实现的轻量级图标生成工具，可将一张高分辨率 PNG 图片一键生成标准的 Windows .ico 图标文件，内含多种尺寸（16x16 到 256x256）。内置图标结构分析功能，轻松验证 .ico 文件中包含的图层与尺寸","archived":false,"fork":false,"pushed_at":"2025-12-21T12:28:21.000Z","size":1468,"stargazers_count":120,"open_issues_count":1,"forks_count":20,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-01-19T22:57:40.098Z","etag":null,"topics":["aot","csharp","dotnet","ico","image","tool"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/star-plan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-05-18T06:50:00.000Z","updated_at":"2026-01-16T05:28:54.000Z","dependencies_parsed_at":null,"dependency_job_id":"9b934e90-0ce0-4f87-aeca-8304591c12d6","html_url":"https://github.com/star-plan/sharp-ico","commit_stats":null,"previous_names":["star-plan/sharp-ico"],"tags_count":19,"template":false,"template_full_name":null,"purl":"pkg:github/star-plan/sharp-ico","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/star-plan%2Fsharp-ico","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/star-plan%2Fsharp-ico/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/star-plan%2Fsharp-ico/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/star-plan%2Fsharp-ico/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/star-plan","download_url":"https://codeload.github.com/star-plan/sharp-ico/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/star-plan%2Fsharp-ico/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28633757,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-21T04:47:28.174Z","status":"ssl_error","status_checked_at":"2026-01-21T04:47:22.943Z","response_time":86,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aot","csharp","dotnet","ico","image","tool"],"created_at":"2025-06-07T08:30:28.518Z","updated_at":"2026-01-21T13:25:27.953Z","avatar_url":"https://github.com/star-plan.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SharpIco\n\n\u003cimg src=\"docs/images/logo.png\" alt=\"SharpIco Logo\" width=\"200\" height=\"200\" /\u003e\n\n![License](https://img.shields.io/badge/license-MIT-blue)\n![.NET](https://img.shields.io/badge/.NET-9.0-purple)\n\nSharpIco是一个纯 C# AOT 实现的轻量级图标生成工具，用于生成和检查ICO图标文件。可将一张高分辨率 PNG 图片一键生成标准的 Windows .ico 图标文件，内含多种尺寸（16x16 到 512x512），还可以自定义尺寸。\n\n通过SharpIco，您可以轻松将PNG图像转换为包含多种尺寸的ICO图标，完全摆脱命令行依赖，无需 ImageMagick、Node.js 或 Python，适合在 .NET 项目中内嵌、分发或集成自动打包流程中使用。\n\n除了图标生成，SharpIco 还内置图标结构分析功能，助你轻松验证 .ico 文件中包含的图层与尺寸。\n\n🚀 跨平台、零依赖、极速生成，一切尽在 SharpIco！\n\n\n## ✨ 功能特点\n\n- 🖼️ 将PNG图像转换为多尺寸ICO图标\n- 🔍 支持生成包含自定义尺寸的ICO图标（最高支持1024×1024）\n- 🧐 检查ICO文件的内部结构和信息\n- 📏 准确识别并显示超大尺寸图标（如512×512、1024×1024）的实际尺寸\n\n## 🤝 相关项目\n\n- [SharpIcoWeb](https://github.com/ZyPLJ/SharpIcoWeb) - 基于 SharpIco 的 Web 版本，提供更直观的图形界面操作。\n\n\n## 📦 安装\n\n### 使用 Scoop 安装 (Windows)\n\n```bash\n# 添加自定义 bucket\nscoop bucket add sharp-ico https://github.com/star-plan/sharp-ico\n\n# 安装 SharpIco\nscoop install sharp-ico\n```\n\n### 作为 .NET Global Tool 安装\n\n```bash\ndotnet tool install --global SharpIco\n```\n\n### 从源码构建\n\n```bash\ngit clone https://github.com/star-plan/sharp-ico.git\ncd SharpIco\ndotnet build -c Release\n```\n\n## 🚀 使用方法\n\n### 生成ICO图标\n\n```bash\nsharpico generate -i input.png -o output.ico\n```\n\n可选参数:\n- `-s, --sizes`: 指定图标尺寸，支持逗号、分号或空格分隔；默认为 16,32,48,64,128,256,512\n  \n\n示例:\n```bash\n# 逗号分隔\nsharpico generate -i input.png -o output.ico -s 16,32,64,128\n# 空格分隔（等价）\nsharpico generate -i input.png -o output.ico -s 16 32 64 128\n# 分号分隔（PowerShell 中需使用引号）\nsharpico generate -i input.png -o output.ico -s \"16;32;64;128\"\n```\n\n提示：在 Windows PowerShell 中，分号为命令分隔符。如果使用分号作为尺寸分隔符，请将整组数值用引号括起来，如 `-s \"16;32;64;128\"`。\n\n### 检查ICO文件结构\n\n```bash\nsharpico inspect icon.ico\n```\n\n## 📋 参数说明\n\n### 生成命令(generate)\n\n| 参数 | 缩写 | 说明 | 是否必需 |\n| --- | --- | --- | --- |\n| `--input` | `-i` | 输入PNG图像文件路径 | 是 |\n| `--output` | `-o` | 输出ICO文件路径 | 是 |\n| `--sizes` | `-s` | 图标尺寸列表，以逗号分隔 | 否，默认为16,32,48,64,128,256,512,1024 |\n\n### 检查命令(inspect)\n\n| 参数 | 说明 | 是否必需 |\n| --- | --- | --- |\n| `ico-file` | 要检查的ICO文件路径 | 是 |\n\n## 📝 示例输出\n\n### 生成ICO图标\n\n```\n正在将 logo.png 转换为 logo.ico...\n生成尺寸: 16, 32, 48, 64, 128, 256, 512, 1024\nICO 文件已生成: logo.ico\n```\n\n### 检查ICO文件\n\n```\n正在检查ICO文件: logo.ico\n图标数量: 8\n- 第1张图像: 16x16, 32bpp, 大小: 840字节, 偏移: 150\n- 第2张图像: 32x32, 32bpp, 大小: 1939字节, 偏移: 990\n- 第3张图像: 48x48, 32bpp, 大小: 3375字节, 偏移: 2929\n- 第4张图像: 64x64, 32bpp, 大小: 4951字节, 偏移: 6304\n- 第5张图像: 128x128, 32bpp, 大小: 13782字节, 偏移: 11255\n- 第6张图像: 256x256, 32bpp, 大小: 37823字节, 偏移: 25037\n- 第7张图像: 512x512, 32bpp, 大小: 114655字节, 偏移: 62860\n  注意: 文件头中指定的尺寸为256x256，但实际图像尺寸为512x512\n- 第8张图像: 1024x1024, 32bpp, 大小: 248965字节, 偏移: 177515\n  注意: 文件头中指定的尺寸为256x256，但实际图像尺寸为1024x1024\n```\n\n## 🔍 关于ICO格式的说明\n\nICO文件格式在表示图像尺寸时有一个限制：宽度和高度字段各只有一个字节，值范围是0-255。当这些字段为0时，按照规范表示256像素。对于大于256的尺寸（如512×512或1024×1024），在文件头中仍然会显示为0（即256），但实际图像数据可以包含更大尺寸的图像。\n\nSharpIco的inspect命令会解析每个图像的实际数据，以获取其真实尺寸。这使得工具能够准确显示ICO文件中图像的实际分辨率，即使它们超过了ICO头部表示的范围限制。当头部信息与实际图像尺寸不一致时，SharpIco会显示相应的提示信息。\n\n\n## 🛠️ 技术实现\n\nSharpIco使用以下技术：\n\n- .NET 9.0\n- [SixLabors.ImageSharp](https://github.com/SixLabors/ImageSharp) - 用于图像处理\n- [System.CommandLine](https://github.com/dotnet/command-line-api) - 用于命令行参数解析\n\n## 📄 许可证\n\nMIT License\n\n## 开发者指南\n\n### 构建项目\n\n```bash\ndotnet build\n```\n\n### 发布模式\n\nSharpIco 支持两种发布模式：\n\n#### AOT 发布 (原生性能，无需 .NET 运行时)\n\n```bash\ndotnet publish -r win-x64 -c release /p:PublishAot=true /p:TrimMode=full /p:InvariantGlobalization=true /p:IlcGenerateStackTraceData=false /p:IlcOptimizationPreference=Size /p:IlcFoldIdenticalMethodBodies=true /p:JsonSerializerIsReflectionEnabledByDefault=true\n```\n\n支持的平台:\n\n- Windows: win-x64\n- macOS: osx-x64, osx-arm64\n- Linux: linux-x64, linux-arm64\n\n#### Framework Dependent 发布 (需要 .NET 运行时)\n\n```bash\n# 发布为 NuGet 包 (.NET Tool)\ndotnet pack\n\n# 安装本地打包的工具\ndotnet tool install --global --add-source ./SharpIco/nupkg SharpIco\n```\n\n### 创建 Scoop 安装包\n\n- 编译 AOT 版本并创建 zip 文件\n- 在 GitHub Releases 中发布 AOT 编译的 zip 包\n- 计算 zip 文件的 SHA256 哈希值\n- 更新 `bucket/sharp-ico.json` 中的版本号和哈希值\n\nsharp-ico.json 内容示例\n\n```json\n{\n    \"version\": \"1.0.0\",\n    \"description\": \"轻量级ICO图标生成和检查工具\",\n    \"homepage\": \"https://github.com/star-plan/sharp-ico\",\n    \"license\": \"MIT\",\n    \"architecture\": {\n        \"64bit\": {\n            \"url\": \"https://github.com/star-plan/sharp-ico/releases/download/v1.0.0/sharpico-win-x64.zip\",\n            \"hash\": \"SHA256哈希值，发布后填写\"\n        }\n    },\n    \"bin\": \"sharpico.exe\",\n    \"checkver\": \"github\",\n    \"autoupdate\": {\n        \"architecture\": {\n            \"64bit\": {\n                \"url\": \"https://github.com/star-plan/sharp-ico/releases/download/v$version/sharpico-win-x64.zip\"\n            }\n        }\n    }\n}\n```\n\n使用此方法，您的用户可以通过以下简单步骤安装您的工具：\n\n```bash\nscoop bucket add sharp-ico https://github.com/star-plan/sharp-ico\nscoop install sharp-ico\n```\n\n当您发布新版本时，用户只需运行 `scoop update sharp-ico` 即可获取最新版本。\n\n\n### 两种发布流程\n\n#### AOT 发布流程 (Scoop/独立应用)\n\n1. 编译 AOT 版本:\n```bash\ndotnet publish -r win-x64 -c release /p:PublishAot=true /p:TrimMode=full /p:InvariantGlobalization=true /p:IlcGenerateStackTraceData=false /p:IlcOptimizationPreference=Size /p:IlcFoldIdenticalMethodBodies=true /p:JsonSerializerIsReflectionEnabledByDefault=true\n```\n\n2. 打包生成的文件:\n```bash\n# 进入发布目录\ncd SharpIco/bin/release/net9.0/win-x64/publish/\n# 创建 zip 包\npowershell Compress-Archive -Path * -DestinationPath sharpico-win-x64.zip\n```\n\n3. 将生成的 zip 文件上传到 GitHub Releases\n\n#### .NET Tool 发布流程\n\n1. 打包为 NuGet 包:\n```bash\ndotnet pack\n```\n\n2. 生成的包将位于 `./SharpIco/nupkg` 目录中\n\n3. 发布到 NuGet:\n```bash\ndotnet nuget push ./SharpIco/nupkg/SharpIco.1.0.0.nupkg --api-key 您的API密钥 --source https://api.nuget.org/v3/index.json\n```\n\n### 本地测试\n\n#### 测试 .NET Tool\n\n```bash\n# 安装本地打包的工具\ndotnet tool install --global --add-source ./SharpIco/nupkg SharpIco\n\n# 卸载工具\ndotnet tool uninstall --global SharpIco\n```\n\n#### 测试 AOT 发布版本\n\n直接运行生成的可执行文件:\n```bash\n./SharpIco/bin/release/net9.0/win-x64/publish/sharpico.exe\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstar-plan%2Fsharp-ico","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstar-plan%2Fsharp-ico","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstar-plan%2Fsharp-ico/lists"}