Image Compressor
基于 rv-image-optimize 的图片压缩、上传与格式转换 skill。
An image compression, upload, and format-conversion skill powered by rv-image-optimize.
核心功能 / Features
- 压缩单张或批量图片 / Compress single images or whole folders
- 转换
jpeg、png、webp、avif/ Convert betweenjpeg,png,webp, andavif - 压缩时限制尺寸 / Resize while compressing with max width and height
- 通过
upload子命令按FormData配置上传文件 / Upload files through theuploadsubcommand withFormDataconfig - 通过
pipeline子命令一条命令完成“压缩 + 上传” / Complete "compress + upload" in one command with thepipelinesubcommand - 通过
chunkUpload配置执行分片上传 / 断点续传 / Run chunked and resumable uploads throughchunkUploadconfig - 输出结构化 JSON 结果 / Return structured JSON summaries for agents
- 默认安全输出到新目录 / Default to safe output in a new directory
何时使用 / When to use
当用户提到以下需求时使用:
- “压缩图片”
- “图片太大”
- “减小文件大小”
- “转成 WebP / AVIF”
- “批量处理整个图片目录”
- “压缩时顺便缩小尺寸”
- “让 Agent / CLI 自动处理图片”
- “压缩后上传到接口”
- “按接口配置上传文件”
- “大文件分片上传”
- “断点续传”
Use this skill when the user asks to:
- compress one or more images
- reduce image file size
- convert images to
webporavif - batch-process an image folder
- resize images while compressing
- run image optimization from an agent or CLI workflow
- upload files to an API through CLI
- compress files and immediately upload them
- perform chunked uploads for large files
- resume interrupted uploads
默认策略 / Default behavior
除非用户明确要求修改原图,否则优先使用安全模式:
- 使用
--output-dir输出到新目录 - 使用
--json方便 Agent 汇总结果 - 默认不删除原图
- 默认不替换原图
- 大文件上传优先把
chunkUpload写进--config
Preferred command:
rv-image-optimize "{input}" --output-dir "{outputDir}" --format webp --quality 82 --json
如果全局命令不可用,可回退到:
npx rv-image-optimize "{input}" --output-dir "{outputDir}" --format webp --quality 82 --json
如果任务是“压缩后上传接口”,优先使用:
rv-image-optimize pipeline "{input}" --format webp --quality 82 --config "{configPath}" --json
如果任务是“已有文件直接上传接口”,优先使用:
rv-image-optimize upload "{input}" --config "{configPath}" --json
安全规则 / Safety rules
以下选项只有在用户明确要求时才允许使用:
--delete-original--replace-original
--replace-original 不能和以下参数一起使用:
--output--output-dir--suffix
If the user wants to preserve source files, always choose --output-dir.
上传相关安全约定:
- 当前只保留
FormData请求方式 - 复杂上传字段优先写进
--configJSON 文件 - 大文件 / 可恢复上传优先使用
chunkUpload配置块 Authorization、Cookie、Content-Type优先用配置文件显式字段表达Content-Type在FormData模式下通常建议留空,让运行时自动生成 boundary
常用命令 / Common recipes
单张图片压缩 / Compress a single image
rv-image-optimize "./photo.jpg" --output-dir "./compressed" --format webp --quality 82 --json
批量压缩目录 / Compress a folder
rv-image-optimize "./images" --output-dir "./images-compressed" --format webp --quality 82 --json
调整尺寸并压缩 / Resize and compress
rv-image-optimize "./images" --output-dir "./images-compressed" --format webp --quality 82 --max-width 1920 --max-height 1080 --json
压缩成功后删除原图 / Delete originals after success
rv-image-optimize "./images" --output-dir "./images-compressed" --format webp --quality 82 --delete-original --json
直接替换原图 / Replace originals in place
rv-image-optimize "./images" --format webp --quality 82 --replace-original --json
直接上传已有文件 / Upload existing files
rv-image-optimize upload "./dist/demo.webp" --config "./upload.config.json" --json
分片上传 / 断点续传 / Chunked resumable upload
rv-image-optimize upload "./large-assets" --config "./upload.chunk.config.json" --timeout-ms 10000 --json
压缩后直接上传 / Compress then upload
rv-image-optimize pipeline "./images" --format webp --quality 82 --config "./upload.config.json" --json
仅预览上传字段 / Preview upload fields only
rv-image-optimize upload "./dist/demo.webp" --config "./upload.config.json" --preview-only --json
汇报结果 / Reporting results
使用 --json 时,建议汇总:
totalsuccessfailed- 输出目录或是否替换了原图
- 失败文件列表
- 上传模式下的 HTTP 状态码或预览字段
推荐参数 / Recommended defaults
- 默认格式:
webp - 默认质量:
82 - 更小体积优先且接受更慢编码时:
avif - 上传任务默认优先使用
--config - 大文件上传默认优先使用
chunkUpload - 压缩后上传默认优先使用
pipeline - 如需更多示例和参数说明,见 reference.md