跳到主内容
智客 ZICQ

技能库 智客分类:Agent 工作流 netlify-image-cdn

Netlify Image Cdn

通过Netlify Image CDN's /.netlify/images endpoint,实现变形,变大,裁剪,重塑,并按需优化图像. 在添加应答图像时使用,生成缩略图,转换格式(avif/webp/png),裁剪到宽比,调整图像质量,创建模糊的占位符,允许将远程图像域列表,服务用户上载的图像,或接通框架图像组件(Next.js,Astro,Nuxt,Angular,Gatsby)到Netlify. 触发任务如"优化图像","添加图像缩略图","调整苍蝇上图像大小","从外部域保存图像",或"添加模糊的占位符"等.

2410 安装量

官方网址:skills.sh

技能介绍

先看中文介绍;官方 description 原文单独保留,不改写 SKILL.md。

做什么

通过Netlify Image CDN的 /.netlify/ images 端点进行变换、大小调整、裁剪、重塑和优化图像

何时用

添加响应图像,生成缩略图,转换格式(avif/webp/png),裁剪到宽比,调整图像质量,创建模糊的占位符,允许将远程图像域列表,为用户上载图像服务,或布线框架图像组件(Next.js, Ast)

代理如何加载

按 Agent Skills 渐进披露:启动时只加载 name 与 description(约 100 token);任务匹配后才读入整份 SKILL.md 正文;scripts/、references/、assets/ 仅在需要时再读。 本文件正文结构:Netlify Image CDN、resize + crop to a 50px square, retain left side, convert to webp at q=80、Endpoint & query parameters、`fit` behavior、Format & content negotiation、Response codes。

文件分析

文件分析:除 SKILL.md 外,正文引用了 references/user-uploads.md,属于带资源的技能包,这些文件按需再读。

官方 description(原文)

Transform, resize, crop, reformat, and optimize images on demand via Netlify Image CDN's /.netlify/images endpoint. Use when adding responsive images, generating thumbnails, converting formats (avif/webp/png), cropping to aspect ratios, tuning image quality, creating blurred placeholders, allowlisting remote image domains, serving user-uploaded images, or wiring framework image components (Next.js, Astro, Nuxt, Angular, Gatsby) to Netlify. Triggers on tasks like "optimize images", "add image thumbnails", "resize images on the fly", "serve images from an external domain", or "add blur placeholders".

Netlify Image CDNresize + crop to a 50px square, retain left side, convert to webp at q=80Endpoint & query parameters`fit` behaviorFormat & content negotiationResponse codesRemote source imagesReusable transformations (redirects)Custom headers (caching)Framework integrationsLocal developmentCaching & deploys

来源分类:skills.sh agent-skill

SKILL.md 与 Agent 调用

官方规范 ↗
name
netlify-image-cdn
description
Transform, resize, crop, reformat, and optimize images on demand via Netlify Image CDN's /.netlify/images endpoint. Use when adding responsive images, generating thumbnails, converting formats (avif/webp/png), cropping to aspect ratios, tuning image quality, creating blurred placeholders, allowlisting remote image domains, serving user-uploaded images, or wiring framework image components (Next.js, Astro, Nuxt, Angular, Gatsby) to Netlify. Triggers on tasks like "optimize images", "add image thumbnails", "resize images on the fly", "serve images from an external domain", or "add blur placeholders".
  1. 发现技能客户端向 Agent 提供名称与描述目录。
  2. 匹配与调用用户指定或任务匹配后,载入 SKILL.md 指令。
  3. 按需加载按步骤读取参考文档、使用脚本与素材。
指令中引用的文件 · 1
  • references/user-uploads.md

以下路径提取自原文;文件是否齐全请以来源仓库中的完整目录为准。

具体调用语法与可用工具以目标 Agent 客户端为准。 查看调用机制说明 ↗

安装这个技能

Skills CLI ↗

先选择目标 Agent 和安装范围,保留技能包的附属文件,安装后检查客户端能否发现该技能。

该技能引用了附属文件,请从来源获取完整目录;仅复制 SKILL.md 可能缺少依赖。

交给 Agent 安装

复制安装指令给支持 Agent Skills 的代理,确认其中的目标目录与客户端匹配。

把 Agent Skill「netlify-image-cdn」安装到我的项目:SKILL.md 原文与官方 description 见 https://zicq.com/zh/skills/skl-5c298148f6e6a574-%E5%87%80%E5%8C%96%E5%9B%BE%E5%83%8F-Cdn.html
请存为 .cursor/skills/netlify-image-cdn/SKILL.md 或 .claude/skills/netlify-image-cdn/SKILL.md,frontmatter 的 name 与 description 保持原样,不要改写。
该技能还带 scripts/、references/、assets/ 等文件,请从 https://github.com/netlify/context-and-tools 取完整目录,不要只建一个 SKILL.md。

GitHub 完整包 ↗

终端安装 · Skills CLI

需要 Node.js 与 npx。先查看仓库技能列表,确认实际名称。

npx skills add 'https://github.com/netlify/context-and-tools' --list

npx skills add 'https://github.com/netlify/context-and-tools' --skill 'netlify-image-cdn'

CLI 会交互选择目标 Agent,默认安装到项目;用户级安装使用 -g。先通过查看命令核对仓库内容,再用 npx skills list 检查已安装技能。

阅读排版
--- name: netlify-image-cdn description: Transform, resize, crop, reformat, and optimize images on demand via Netlify Image CDN's /.netlify/images endpoint. Use when adding responsive images, generating thumbnails, converting formats (avif/webp/png), cropping to aspect ratios, tuning image quality, creating blurred placeholders, allowlisting remote image domains, serving user-uploaded images, or wiring framework image components (Next.js, Astro, Nuxt, Angular, Gatsby) to Netlify. Triggers on tasks like "optimize images", "add image thumbnails", "resize images on the fly", "serve images from an external domain", or "add blur placeholders". --- # Netlify Image CDN Transform images by requesting `/.netlify/images` with query parameters. No function or file authoring required — it's a built-in edge endpoint. ```bash # resize + crop to a 50px square, retain left side, convert to webp at q=80 curl -vs 'https://mysitename.netlify.app/.netlify/images?url=/owl.jpeg&fit=cover&w=50&h=50&position=left&fm=webp&q=80' ``` There is no legacy/deprecated form — the endpoint above is the only programmatic surface. Use framework image components where available (below) rather than hand-building URLs. ## Endpoint & query parameters `GET /.netlify/images?url=&...` | Param | Values | Notes | |---|---|---| | `url` | relative path or full remote URL | **REQUIRED**. Only required param. | | `w` | integer px | width | | `h` | integer px | height | | `fit` | `contain` (default), `cover`, `fill` | resize behavior | | `position` | `center` (default), `top`, `bottom`, `left`, `right` | only applies when `fit=cover` | | `fm` | `avif`, `jpg`, `png`, `webp`, `gif`, `blurhash` | output format; `webp`/`gif` can be animated | | `q` | integer `1`–`100` (default `75`) | only for `avif`, `jpg`, `gif`, `webp` | ### `fit` behavior | `fit=` | aspect ratio kept | crops excess | returns exact dimensions | |---|---|---|---| | `contain` | yes | no | no — one dimension may be smaller | | `cover` | no | yes | yes — scaled proportionally, then cropped | | `fill` | no | no | yes — stretched/squished if needed | - **`fit=cover` requires BOTH `w` and `h`.** Supplying only one silently misbehaves. - `contain` with one dimension calculates the other to preserve aspect ratio. ### Format & content negotiation - Source-only request (just `url`, no size/format): image is unchanged in size/shape but **still reformatted** to `avif`/`webp` based on the browser's `Accept` header. - No `fm` specified → `webp` if accepted, else `avif` if accepted, else original. - `fm=blurhash` returns a BlurHash **text string, not image bytes.** Pointing `` or a CSS background at it renders nothing. Fetch the string server-side/ahead of time, decode it client-side with a BlurHash library (https://blurha.sh), then load the real image as a separate request without `fm=blurhash`. ### Response codes - Invalid transformation param values → `404`. - Valid, new transformation → `200` with content + `content-type`. - Previously transformed → `304`. ## Remote source images Remote `url` values require allowlisting the domain in `netlify.toml`: ```toml [images] remote_images = ["https://my-images.com/.*", "https://animals.more-images.com/[bcr]at/.*"] ``` Then percent-encode the remote URL and request it: ```js const src = `/.netlify/images?url=${encodeURIComponent("https://my-images.com/owl.jpeg")}`; ``` - **Always `encodeURIComponent` the remote URL** before placing it in `url` — URLs containing `?` or `&` break otherwise. - In `remote_images` patterns, **escape only the dot**: `'https://example\.com/.*'`. Forward slashes are NOT regex metacharacters — do not write `https:\/\/`. - Remote sources must be **publicly accessible**. Netlify does NOT forward `Authorization` or `Cookie` headers to remote sources. For auth-required images use self-authorizing URLs (e.g. S3 presigned URLs) and make sure your `remote_images` pattern matches them. ## Reusable transformations (redirects) Reuse the same params across many images via a redirect: `_redirects`: ``` /transform-small/* /.netlify/images?url=/:splat&w=50&h=50 200 ``` `netlify.toml`: ```toml [[redirects]] from = "/transform-small/*" to = "/.netlify/images?url=/:splat&w=50&h=50" status = 200 ``` Then `GET /transform-small/owl.jpeg` yields a 50×50 transform. **Avoid cross-site redirects for transformations** — they hurt performance. ## Custom headers (caching) `_headers`: ``` /source-images/* Cache-Control: public, max-age=604800, must-revalidate ``` - Headers set on a source image are applied to the transformed asset served by Image CDN. - Custom headers **cannot** be applied to remote (other-domain) source images; Netlify respects whatever cache headers the external domain sends. - `Cache-Control` on source images applies only to browsers/CDNs in front of Netlify, **not** the Netlify Cache itself. ## Framework integrations Use the framework's native image component/handling; it wires to Image CDN automatically. Configure the remote allowlist per framework: | Framework | Prerequisite | Remote allowlist | |---|---|---| | Angular | none — `NgOptimizedImage` auto-uses it | `[images] remote_images` in `netlify.toml` | | Astro | none — `` auto-uses it | `image.domains` / `image.remotePatterns` in `astro.config.mjs` | | Nuxt | none — `nuxt/image` auto-uses it | `image.domains` in `nuxt.config.ts` | | Next.js | Next 13.5+ and adapter v5 | `remotePatterns` in `next.config.js` | | Gatsby | env `NETLIFY_IMAGE_CDN=true` + Contentful/Drupal/WordPress source plugin | `[images] remote_images` in `netlify.toml` | ## Local development Run `netlify dev` (Netlify CLI) to test transformations locally — it mimics production including Image CDN. - **A local `404` on `/.netlify/images` almost always means a framework dev server (`vite`, `next dev`, `astro dev`) is running instead of `netlify dev`.** The endpoint, `[images]` allowlisting, and image redirects only exist under `netlify dev`. The URL itself is usually fine. ## Caching & deploys Transformed results are uniquely cached on Netlify's edge. Atomic deploys are respected: changing a source image in a new deploy re-runs transformations on new requests so stale assets aren't served. ## User-uploaded image pipelines For user-uploaded image pipelines (Functions + Blobs + Image CDN composed), see `references/user-uploads.md` in this skill. ## Limitations - **Split Testing is not supported** — you may get inconsistent image results between split test branches. - Not currently supported in Netlify's HIPAA-compliant hosting offering. See the Trust Center for the HIPAA-compliant reference architecture. # Netlify house rules (image-cdn) These are org conventions, not docs facts — merged into the rendered skill by ctx-gen and never generated. Owned by the skills maintainer. 1. For user-uploaded image pipelines (Functions + Blobs + Image CDN composed), see `references/user-uploads.md` in this skill — an authored guide with no single docs source. 2. Percent-encode remote source URLs before placing them in the `url` parameter (`encodeURIComponent`) — URLs containing `?` or `&` break otherwise. 3. `fm=blurhash` returns a BlurHash TEXT string, not image bytes. Pointing an `` (or CSS background) at it renders nothing — fetch the string ahead of time, decode it client-side with a BlurHash library, and load the real image as a separate request without `fm=blurhash`. 4. A local 404 on `/.netlify/images` almost always means a framework dev server (`vite`, `next dev`, `astro dev`) is running instead of `netlify dev` — the endpoint, `[images]` allowlisting, and image redirects only exist under `netlify dev`. The URL itself is usually fine. 5. In `remote_images` patterns, the meaningful regex escape is the dot; forward slashes are not metacharacters — do not write `https:\/\/`. In `netlify.toml`, use a single-quoted literal string (`'https://example\.com/.*'`) or double the backslash in a double-quoted string (`"https://example\\.com/.*"`) — a bare `\.` inside double quotes is invalid TOML.

相关技能

Agent 工作流

Skill Creator

创造有效技能指南。 当用户想创造出新的技能(或更新现有的技能),以专业知识,工作流程,或工具集成来扩展克洛德的能力时,应该使用这种技能.

Agent 工作流

Clawdhub

使用ClawdHub CLI搜索,安装,更新并发布从taladhub.com的代理技能. 需要获取苍蝇上的新技能时使用,将安装的技能同步到最新版本或特定版本,或者发布 npm-instainddhub CLI 的新/更新的技能文件夹.

Agent 工作流

Agent Team Orchestration

管弦乐团多代理团队,任务设定周期,交接协议,审查工作流程. 使用时间: (1)建立2+特派员队伍,具有不同专业,(2)确定任务路线和生命周期(收录框_ spec_建设_审查_完成),(3)在特派员之间制定交接协议,(4)建立审查和质量关口,(5)管理特派员之间的交流和文物共享.

Agent 工作流

Superpowers

Spec-first,TDD,子代理驱动的软件开发工作流程. 当:(1)构建任何新功能或应用——触发脑暴_计划_子代理执行回路,(2)调试出一个bug或测试失败——触发系统性的根起过程,(3)用户说"让我们构建","帮助我计划","我想添加X",或"这个被打破",(4)完成一个功…