图像处理
缩放、压缩、转换、加水印与读取图像元数据。
概览
https://api.infrai.cc/v1/imageAuthorization: Bearer $INFRAI_API_KEY# Call any /v1/image capability over raw HTTP — no SDK to install.
# curl:
curl https://api.infrai.cc/v1/image/... \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json"方法
image.process
处理图像:缩放、压缩、转换、加水印、旋转或去背景。
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
input | ImageRef { url? | base64? } | 必填 | 图像引用,URL 或 base64。 |
width | number | 可选 | 目标宽度(像素)。 |
height | number | 可选 | 目标高度(像素)。 |
format | "jpeg" | "png" | "webp" | "avif" | 可选 | 输出图像格式。 |
quality | number | 可选 | 压缩质量,0 到 100。 |
idempotency_key | string | 可选 | 可选去重 key;相同重试将返回同一结果。 |
返回
ImageOpResult { image_url, mime, width?, height?, bytes }示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."curl -X POST https://api.infrai.cc/v1/image/process \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"image": {"url": "https://example.com/photo.jpg"}, "ops": [{"op": "resize", "params": {"width": 800}}, {"op": "compress", "params": {"quality": 80}}]}'image.metadata
读取图像尺寸、MIME 类型与 EXIF 元数据。
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
input | ImageRef { url? | base64? } | 必填 | 图像引用,URL 或 base64。 |
返回
{ width, height, mime, exif? }示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."curl -X POST https://api.infrai.cc/v1/image/metadata \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"image": "..."}'image.upload
上传图片资源并返回资产 id 与 URL
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
file | string | 必填 | 要上传的图片:本地文件路径或字节数据 |
filename | string | 可选 | 可选的文件名,用于存储与展示 |
idempotency_key | string | 可选 | 可选去重 key;相同重试将返回同一结果。 |
返回
ImageAsset { id, url, mime, width?, height?, bytes }示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."curl -X POST https://api.infrai.cc/v1/image/upload \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"file": "..."}'image.get
按 id 读取单个图片资产的元信息
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
id | string | 必填 | 图片资产 id |
返回
ImageAsset { id, url, mime, width?, height?, bytes }示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."curl -X GET https://api.infrai.cc/v1/image/get/ID \
-H "Authorization: Bearer $INFRAI_API_KEY"image.list
分页列出已存储的图片资产
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
cursor | string | 可选 | 分页游标:传入上一页返回的 next_cursor 获取下一页。 |
limit | number | 可选 | 单页返回条数上限。 |
返回
{ items: ImageAsset[], next_cursor? }示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."curl -X GET https://api.infrai.cc/v1/image/list \
-H "Authorization: Bearer $INFRAI_API_KEY"image.delete
按 id 删除已存储的图片资产
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
id | string | 必填 | 要删除的图片资产 id |
idempotency_key | string | 可选 | 可选去重 key;相同重试将返回同一结果。 |
返回
{ ok: boolean }示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."curl -X DELETE https://api.infrai.cc/v1/image/delete/ID \
-H "Authorization: Bearer $INFRAI_API_KEY"image.resize
缩放图片到指定宽高
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
image | ImageRef { url? | base64? | id? } | 必填 | 图像引用,URL 或 base64。 |
width | number | 可选 | 目标宽度(像素)。 |
height | number | 可选 | 目标高度(像素)。 |
fit | "inside" | "cover" | "contain" | "fill" | 可选 | 缩放适配模式:inside/cover/contain/fill |
enlarge | boolean | 可选 | 当原图小于目标尺寸时是否允许放大 |
format | "jpeg" | "png" | "webp" | "avif" | 可选 | 输出图像格式。 |
idempotency_key | string | 可选 | 可选去重 key;相同重试将返回同一结果。 |
返回
ProcessedImage { image_url, mime, width, height, bytes }示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."curl -X POST https://api.infrai.cc/v1/image/resize \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"image": {"base64": "<...>"}, "width": 800, "fit": "cover"}'image.crop
按 xywh 矩形框裁剪图片
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
image | ImageRef { url? | base64? | id? } | 必填 | 图像引用,URL 或 base64。 |
x | number | 必填 | 裁剪起点的横坐标(像素) |
y | number | 必填 | 裁剪起点的纵坐标(像素) |
width | number | 必填 | 目标宽度(像素)。 |
height | number | 必填 | 目标高度(像素)。 |
format | "jpeg" | "png" | "webp" | "avif" | 可选 | 输出图像格式。 |
idempotency_key | string | 可选 | 可选去重 key;相同重试将返回同一结果。 |
返回
ProcessedImage { image_url, mime, width, height, bytes }示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."curl -X POST https://api.infrai.cc/v1/image/crop \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"image": "...", "x": 0, "y": 0, "width": 0, "height": 0}'image.smart_crop
显著性感知裁剪到指定宽高比
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
image | ImageRef { url? | base64? | id? } | 必填 | 图像引用,URL 或 base64。 |
aspect | string | 必填 | 目标宽高比,例如 1:1、16:9 |
target | "face" | "saliency" | 可选 | 裁剪聚焦目标:face(人脸)或 saliency(主体) |
format | "jpeg" | "png" | "webp" | "avif" | 可选 | 输出图像格式。 |
idempotency_key | string | 可选 | 可选去重 key;相同重试将返回同一结果。 |
返回
ProcessedImage { image_url, mime, width, height, bytes }示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."curl -X POST https://api.infrai.cc/v1/image/smart_crop \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"image": "...", "aspect": "..."}'image.rotate
按角度旋转图片
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
image | ImageRef { url? | base64? | id? } | 必填 | 图像引用,URL 或 base64。 |
degrees | number | 必填 | 旋转角度(度) |
auto_orient | boolean | 可选 | 是否按 EXIF 信息自动校正方向 |
format | "jpeg" | "png" | "webp" | "avif" | 可选 | 输出图像格式。 |
idempotency_key | string | 可选 | 可选去重 key;相同重试将返回同一结果。 |
返回
ProcessedImage { image_url, mime, width, height, bytes }示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."curl -X POST https://api.infrai.cc/v1/image/rotate \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"image": "...", "degrees": 0}'image.compress
按质量或目标字节数压缩图片
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
image | ImageRef { url? | base64? | id? } | 必填 | 图像引用,URL 或 base64。 |
quality | number | 可选 | 压缩质量,0 到 100。 |
target_bytes | number | 可选 | 目标输出字节数上限,用于限定压缩后大小 |
format | "jpeg" | "png" | "webp" | "avif" | 可选 | 输出图像格式。 |
idempotency_key | string | 可选 | 可选去重 key;相同重试将返回同一结果。 |
返回
ProcessedImage { image_url, mime, width, height, bytes }示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."curl -X POST https://api.infrai.cc/v1/image/compress \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"image": "..."}'image.convert
把图片重新编码为另一种格式
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
image | ImageRef { url? | base64? | id? } | 必填 | 图像引用,URL 或 base64。 |
format | "jpeg" | "png" | "webp" | "avif" | 必填 | 输出图像格式。 |
idempotency_key | string | 可选 | 可选去重 key;相同重试将返回同一结果。 |
返回
ProcessedImage { image_url, mime, width, height, bytes }示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."curl -X POST https://api.infrai.cc/v1/image/convert \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"image": "...", "format": "..."}'image.watermark
为图片叠加文字或图片水印
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
image | ImageRef { url? | base64? | id? } | 必填 | 图像引用,URL 或 base64。 |
text | string | 可选 | 水印文字内容 |
watermark_image | ImageRef { url? | base64? | id? } | 可选 | 用作水印的图片引用(url/base64/id) |
position | "top-left" | "top-right" | "bottom-left" | "bottom-right" | "center" | 可选 | 水印位置:四角或居中 |
opacity | number | 可选 | 水印不透明度,0 到 1 之间 |
format | "jpeg" | "png" | "webp" | "avif" | 可选 | 输出图像格式。 |
idempotency_key | string | 可选 | 可选去重 key;相同重试将返回同一结果。 |
返回
ProcessedImage { image_url, mime, width, height, bytes }示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."curl -X POST https://api.infrai.cc/v1/image/watermark \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"image": {"base64": "<...>"}, "text": "© Infrai", "position": "bottom_right", "opacity": 0.6}'image.background_remove
AI 抠图去除图片背景
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
image | ImageRef { url? | base64? | id? } | 必填 | 图像引用,URL 或 base64。 |
format | "jpeg" | "png" | "webp" | "avif" | 可选 | 输出图像格式。 |
idempotency_key | string | 可选 | 可选去重 key;相同重试将返回同一结果。 |
返回
ProcessedImage { image_url, mime, width, height, bytes }示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."curl -X POST https://api.infrai.cc/v1/image/background_remove \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"image": "..."}'image.face_blur
检测并模糊图片中的人脸
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
image | ImageRef { url? | base64? | id? } | 必填 | 图像引用,URL 或 base64。 |
format | "jpeg" | "png" | "webp" | "avif" | 可选 | 输出图像格式。 |
idempotency_key | string | 可选 | 可选去重 key;相同重试将返回同一结果。 |
返回
ProcessedImage { image_url, mime, width, height, bytes }示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."curl -X POST https://api.infrai.cc/v1/image/face_blur \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"image": "..."}'image.deliver_url
构建带变换参数的 CDN 投放 URL
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
image_id | string | 必填 | 已存储图片的 id |
transform | ImageTransform | 可选 | 图片变换参数对象(宽高、格式、裁剪等) |
返回
{ url: string }示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."curl -X POST https://api.infrai.cc/v1/image/deliver_url \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"image_id": "..."}'image.signed_url
生成带时效的签名投放 URL
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
image_id | string | 必填 | 已存储图片的 id |
expires_in_s | number | 必填 | 签名 URL 的有效时长(秒) |
transform | ImageTransform | 可选 | 图片变换参数对象(宽高、格式、裁剪等) |
返回
{ url: string, expires_at: string }示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."curl -X POST https://api.infrai.cc/v1/image/signed_url \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"image_id": "...", "expires_in_s": 0}'image.transformation.create
注册一个具名图片变换模板
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
name | string | 必填 | 变换模板名称,用于在投放 URL 中复用 |
transform | ImageTransform | 必填 | 图片变换参数对象(宽高、格式、裁剪等) |
idempotency_key | string | 可选 | 可选去重 key;相同重试将返回同一结果。 |
返回
ImageTransformation { id, name, transform, created_at }示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."curl -X POST https://api.infrai.cc/v1/image/transformation/create \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"name": "...", "transform": "..."}'image.transformation.list
列出已注册的具名图片变换模板
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
cursor | string | 可选 | 分页游标:传入上一页返回的 next_cursor 获取下一页。 |
limit | number | 可选 | 单页返回条数上限。 |
返回
{ items: ImageTransformation[], next_cursor? }示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."curl -X GET https://api.infrai.cc/v1/image/transformation/list \
-H "Authorization: Bearer $INFRAI_API_KEY"image.batch.submit
提交批量图片处理任务
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
items | Array<{ image, ops }> | 必填 | 批处理条目数组,每项含 image 与 ops(处理步骤) |
webhook_url | string | 可选 | 任务完成时回调通知的 Webhook 地址 |
idempotency_key | string | 可选 | 可选去重 key;相同重试将返回同一结果。 |
返回
ImageJob { id, status, count, created_at }示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."curl -X POST https://api.infrai.cc/v1/image/batch/submit \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"items": []}'image.batch.status
查询批量图片处理任务的进度
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
id | string | 必填 | 批处理任务 job id |
返回
ImageJob { id, status, count, done, failed, results? }示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."curl -X GET https://api.infrai.cc/v1/image/batch/status/ID \
-H "Authorization: Bearer $INFRAI_API_KEY"image.batch.cancel
取消批量图片处理任务
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
id | string | 必填 | 要取消的批处理任务 job id |
idempotency_key | string | 可选 | 可选去重 key;相同重试将返回同一结果。 |
返回
ImageJob { id, status }示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."curl -X POST https://api.infrai.cc/v1/image/batch/cancel/ID \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"job_id": "..."}'全部能力
本模块全部已路由能力——完整的对外 REST 契约。上方方法是带讲解的入门示例,此表是完整参考。
| 能力 | 端点 | 说明 |
|---|---|---|
image.background_remove | POST /v1/image/background_remove | Transform an EXISTING image by AI-removing its background. To GENERATE images with AI use ai.image. |
image.batch.cancel | POST /v1/image/batch/cancel/{id} | Cancel a batch image-processing job by job ID; idempotent write. |
image.batch.status | GET /v1/image/batch/status/{id} | Get the progress and results of a batch image-processing job by job ID. |
image.batch.submit | POST /v1/image/batch/submit | Submit a batch image-processing job and get a job handle, with optional webhook callback. |
image.compress | POST /v1/image/compress | Transform an EXISTING image by compressing it to a target quality or byte size, optionally re-encoding. To GENERATE images with AI use ai.image. |
image.convert | POST /v1/image/convert | Transform an EXISTING image by re-encoding it to another format (jpeg/png/webp/avif). To GENERATE images with AI use ai.image. |
image.crop | POST /v1/image/crop | Transform an EXISTING image by cropping it to an x/y/w/h rectangle. To GENERATE images with AI use ai.image. |
image.delete | DELETE /v1/image/delete/{id} | Delete a stored image asset by ID; idempotent write. |
image.deliver_url | POST /v1/image/deliver_url | Build a CDN delivery URL with transform parameters for a stored image. |
image.face_blur | POST /v1/image/face_blur | Transform an EXISTING image by detecting and blurring faces for redaction. To GENERATE images with AI use ai.image. |
image.get | GET /v1/image/get/{id} | Get the metadata of one stored image asset (URL, MIME type, dimensions, byte size) by ID. |
image.list | GET /v1/image/list | Page through the stored image assets on the account. |
image.metadata | POST /v1/image/metadata | Inspect an EXISTING image's metadata (dimensions, format, EXIF) without modifying it; read-only. |
image.moderate | POST /v1/image/moderate | Classify an image for unsafe content (adult/violence/etc.) returning a flagged verdict plus per-category flags/scores. Real vendor dispatch: Google Vision SafeSearch, Aliyun Green image scan. service_markup applies. |
image.ocr | POST /v1/image/ocr | Extract text from an image (distinct from pdf.ocr) returning full text plus per-line blocks. Real vendor dispatch: Aliyun OCR, Baidu OCR, AWS Textract; self_hosted tesseract honestly degrades to a 503 when the binary is absent (no synthetic text). |
image.process | POST /v1/image/process | Transform an EXISTING image through a chained pipeline of ops, re-encoded once at the end. To GENERATE images with AI use ai.image. |
image.resize | POST /v1/image/resize | Transform an EXISTING image by resizing it with a fit mode and optional upscaling/format. To GENERATE images with AI use ai.image. |
image.rotate | POST /v1/image/rotate | Transform an EXISTING image by rotating it, optionally auto-correcting orientation from EXIF. To GENERATE images with AI use ai.image. |
image.signed_url | POST /v1/image/signed_url | Generate a time-limited signed delivery URL for a stored image. |
image.smart_crop | POST /v1/image/smart_crop | Transform an EXISTING image with saliency-aware cropping to an aspect ratio, optionally targeting faces or subject. To GENERATE images with AI use ai.image. |
image.tag | POST /v1/image/tag | Detect labels/objects in an image returning label + confidence pairs. Real vendor dispatch: Google Vision LABEL_DETECTION, AWS Rekognition DetectLabels. service_markup applies. |
image.transformation.create | POST /v1/image/transformation/create | Register a named image-transformation template reusable in delivery URLs. |
image.transformation.list | GET /v1/image/transformation/list | Page through the registered named image-transformation templates. |
image.upload | POST /v1/image/upload | Upload an image and get an asset with an ID and URL for later processing. |
image.watermark | POST /v1/image/watermark | Transform an EXISTING image by overlaying a text or image watermark with position and opacity. To GENERATE images with AI use ai.image. |
完整示例
本模块的生产级端到端范例:先一次性配置,再运行业务流程,尽量覆盖本模块的多数 API。
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."# 1) Auth: every call is a raw HTTPS request to the Infrai gateway carrying
# only your project key. No SDK, no install.
# Get your key: sign in with Google/GitHub at the console for a project key
# + $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..." # from the console
# 2) image.process
curl -X POST https://api.infrai.cc/v1/image/process \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"image": {"url": "https://example.com/photo.jpg"}, "ops": [{"op": "resize", "params": {"width": 800}}, {"op": "compress", "params": {"quality": 80}}]}'
# 3) image.metadata
curl -X POST https://api.infrai.cc/v1/image/metadata \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"image": "..."}'
# 4) image.upload
curl -X POST https://api.infrai.cc/v1/image/upload \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"file": "..."}'
# 5) image.get
curl -X GET https://api.infrai.cc/v1/image/get/ID \
-H "Authorization: Bearer $INFRAI_API_KEY"
# 6) image.list
curl -X GET https://api.infrai.cc/v1/image/list \
-H "Authorization: Bearer $INFRAI_API_KEY"
# 7) image.delete
curl -X DELETE https://api.infrai.cc/v1/image/delete/ID \
-H "Authorization: Bearer $INFRAI_API_KEY"
# 8) image.resize
curl -X POST https://api.infrai.cc/v1/image/resize \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"image": {"base64": "<...>"}, "width": 800, "fit": "cover"}'
# 9) image.crop
curl -X POST https://api.infrai.cc/v1/image/crop \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"image": "...", "x": 0, "y": 0, "width": 0, "height": 0}'