github-image-hosting
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseImage Upload for GitHub
面向GitHub的图片上传指南
Upload an image to img402.dev's free tier and embed the returned URL in GitHub markdown.
将图片上传至img402.dev的免费套餐,并将返回的URL嵌入GitHub Markdown中。
Quick reference
快速参考
bash
undefinedbash
undefinedUpload (multipart)
上传(多部分形式)
curl -s -X POST https://img402.dev/api/free -F image=@/tmp/screenshot.png
curl -s -X POST https://img402.dev/api/free -F image=@/tmp/screenshot.png
Response
响应结果
undefinedundefinedWorkflow
操作流程
- Get image: Use an existing file, or capture a screenshot:
bash
screencapture -x /tmp/screenshot.png # macOS — full screen screencapture -xw /tmp/screenshot.png # macOS — frontmost window - Verify size: Must be under 1MB. If larger, resize:
bash
sips -Z 1600 /tmp/screenshot.png # macOS — scale longest edge to 1600px - Upload:
bash
curl -s -X POST https://img402.dev/api/free -F image=@/tmp/screenshot.png - Embed the returned in GitHub markdown:
urlmarkdown
- 获取图片:使用现有文件,或截取屏幕截图:
bash
screencapture -x /tmp/screenshot.png # macOS — 全屏截图 screencapture -xw /tmp/screenshot.png # macOS — 截取当前最前端窗口 - 验证大小:图片必须小于1MB。若过大,请调整尺寸:
bash
sips -Z 1600 /tmp/screenshot.png # macOS — 将最长边缩放至1600像素 - 上传图片:
bash
curl -s -X POST https://img402.dev/api/free -F image=@/tmp/screenshot.png - 嵌入至GitHub:将返回的嵌入GitHub Markdown中:
urlmarkdown
GitHub integration
GitHub集成
Use CLI to embed images in PRs and issues:
ghbash
undefined使用 CLI将图片嵌入PR和Issue中:
ghbash
undefinedAdd to PR description
添加至PR描述
gh pr edit --body "$(gh pr view --json body -q .body)
"gh pr edit --body "$(gh pr view --json body -q .body)
"Add as PR comment
添加为PR评论
gh pr comment --body "
"
"gh pr comment --body "
"
"Add to issue
添加至Issue
gh issue comment 123 --body "
"
"undefinedgh issue comment 123 --body "
"
"undefinedConstraints
限制条件
- Max size: 1MB
- Retention: 7 days — suitable for PR reviews, not permanent docs
- Formats: PNG, JPEG, GIF, WebP
- Rate limit: 1,000 free uploads/day (global)
- No auth required
- 最大尺寸:1MB
- 保留时长:7天——适用于PR评审,不适用于永久文档
- 支持格式:PNG、JPEG、GIF、WebP
- 速率限制:每日1000次免费上传(全局)
- 无需认证
Tips
提示
- Prefer PNG for UI screenshots (sharp text). Use JPEG for photos.
- If a screenshot is too large, reduce dimensions with before uploading.
sips -Z 1600 - When adding to a PR body or comment, use or
gh pr commentwith the image markdown.gh pr edit
- UI截图优先使用PNG格式(文字清晰)。照片类图片使用JPEG格式。
- 若截图过大,可先使用调整尺寸后再上传。
sips -Z 1600 - 向PR正文或评论添加图片时,使用或
gh pr comment命令搭配图片Markdown代码。gh pr edit
Paid tier
付费套餐
For permanent images (1 year, 5MB max), use the paid endpoint at $0.01 USDC via x402. See https://img402.dev/blog/paying-x402-apis for details.
若需要永久存储图片(保留1年,最大5MB),可使用付费端点,费用为0.01 USDC,通过x402支付。详情请查看https://img402.dev/blog/paying-x402-apis。