Skip to content

占位图 API

返回指定宽高的合成占位图。默认 SVG;可用路径后缀或 format 输出 WebP / PNG。无 bg 时背景色随机;/seed/... 在相同 seed 下配色固定。

兼容 placehold.co宽x高 与路径配色写法,见下文。使用规范见 使用规范

在线试玩

HTTP API
https://cdn.devimg.cn/800/600
HTML / 代码
<img src="https://cdn.devimg.cn/800/600" alt="placeholder" width="800" height="600" />

需要画面稳定时使用 seed。详见使用规范。


GET /:width/:height

参数

参数位置必填说明
widthpath10–4000
heightpath10–4000
textquery显示文字,默认 宽×高;最长 50 字符。别名 t
bgquery背景色 hex,不含 #。别名 bc
fgquery文字色 hex,不含 #。别名 tc
formatquerysvg(默认)| webp | png
borderquery边框宽度 0–20;1 / true 视为 2px
borderColorquery边框色 hex
crossquery对角线标记 0 | 1
stylequerysolid(默认)| pattern
patternquerystyle=pattern 时指定纹理 id

示例

html
<img src="https://cdn.devimg.cn/800/600" alt="placeholder" />
<img src="https://cdn.devimg.cn/400/300?text=Hero&bg=6366f1&fg=ffffff" alt="hero" />
<img src="https://cdn.devimg.cn/800/600.webp" alt="webp" />
<img src="https://cdn.devimg.cn/800/600?format=webp" alt="webp query" />
<img src="https://cdn.devimg.cn/800/600?border=2&cross=1" alt="border" />
<img src="https://cdn.devimg.cn/800/600?style=pattern" alt="pattern" />

placehold 兼容

形式示例
宽x高/800x600
路径配色/800/600/eee/fff/800x600/eee/fff
显式 SVG/800/600.svg
栅格后缀/800x600.webp
html
<img src="https://cdn.devimg.cn/800x600?text=Banner" alt="banner" />
<img src="https://cdn.devimg.cn/800/600/409eff/ffffff?text=Banner" alt="banner" />

从 placehold 迁移见 从 placehold 迁移

响应

  • 默认 Content-Type: image/svg+xml
  • Cache-Control: public, max-age=3600

栅格输出(WebP / PNG)

方式示例Content-Type
WebP 后缀/800/600.webpimage/webp
PNG 后缀/800/600.pngimage/png
Query/800/600?format=webpimage/webp
  • 栅格化宽、高各自上限 1024;更大尺寸请使用 SVG
  • 栅格输出限流 60 次/分钟/IP

GET /seed/:seed/:width/:height

相同 seed 与尺寸始终返回相同配色。支持与上一节相同的 query 与 .webp / .png 后缀。

html
<img src="https://cdn.devimg.cn/seed/demo/800/600" alt="seed" />
<img src="https://cdn.devimg.cn/seed/demo/800/600.webp" alt="seed webp" />

响应头

  • Cache-Control: public, max-age=31536000, immutable

devimg · 图即 — 国内开发者占位图 CDN