Image Processing
Resize, compress, convert, watermark and read image metadata.
Overview
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"Methods
image.process
Process an image: resize, compress, convert, watermark, rotate or remove background.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
input | ImageRef { url? | base64? } | Required | Image reference as URL or base64. |
width | number | Optional | Target width in pixels. |
height | number | Optional | Target height in pixels. |
format | "jpeg" | "png" | "webp" | "avif" | Optional | Output image format. |
quality | number | Optional | Compression quality from 0 to 100. |
idempotency_key | string | Optional | Optional dedup key; identical retries return the same result. |
Returns
ImageOpResult { image_url, mime, width?, height?, bytes }Example
一次性前置(每个范例都假定已完成):
# 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
Read image dimensions, MIME type and EXIF metadata.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
input | ImageRef { url? | base64? } | Required | Image reference as URL or base64. |
Returns
{ width, height, mime, exif? }Example
一次性前置(每个范例都假定已完成):
# 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
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
file | string | Required | 要上传的图片:本地文件路径或字节数据 |
filename | string | Optional | 可选的文件名,用于存储与展示 |
idempotency_key | string | Optional | Optional dedup key; identical retries return the same result. |
Returns
ImageAsset { id, url, mime, width?, height?, bytes }Example
一次性前置(每个范例都假定已完成):
# 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 读取单个图片资产的元信息
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
id | string | Required | 图片资产 id |
Returns
ImageAsset { id, url, mime, width?, height?, bytes }Example
一次性前置(每个范例都假定已完成):
# 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
分页列出已存储的图片资产
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
cursor | string | Optional | 分页游标:传入上一页返回的 next_cursor 获取下一页。 |
limit | number | Optional | 单页返回条数上限。 |
Returns
{ items: ImageAsset[], next_cursor? }Example
一次性前置(每个范例都假定已完成):
# 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 删除已存储的图片资产
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
id | string | Required | 要删除的图片资产 id |
idempotency_key | string | Optional | Optional dedup key; identical retries return the same result. |
Returns
{ ok: boolean }Example
一次性前置(每个范例都假定已完成):
# 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
缩放图片到指定宽高
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
image | ImageRef { url? | base64? | id? } | Required | Image reference as URL or base64. |
width | number | Optional | Target width in pixels. |
height | number | Optional | Target height in pixels. |
fit | "inside" | "cover" | "contain" | "fill" | Optional | 缩放适配模式:inside/cover/contain/fill |
enlarge | boolean | Optional | 当原图小于目标尺寸时是否允许放大 |
format | "jpeg" | "png" | "webp" | "avif" | Optional | Output image format. |
idempotency_key | string | Optional | Optional dedup key; identical retries return the same result. |
Returns
ProcessedImage { image_url, mime, width, height, bytes }Example
一次性前置(每个范例都假定已完成):
# 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 矩形框裁剪图片
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
image | ImageRef { url? | base64? | id? } | Required | Image reference as URL or base64. |
x | number | Required | 裁剪起点的横坐标(像素) |
y | number | Required | 裁剪起点的纵坐标(像素) |
width | number | Required | Target width in pixels. |
height | number | Required | Target height in pixels. |
format | "jpeg" | "png" | "webp" | "avif" | Optional | Output image format. |
idempotency_key | string | Optional | Optional dedup key; identical retries return the same result. |
Returns
ProcessedImage { image_url, mime, width, height, bytes }Example
一次性前置(每个范例都假定已完成):
# 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
显著性感知裁剪到指定宽高比
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
image | ImageRef { url? | base64? | id? } | Required | Image reference as URL or base64. |
aspect | string | Required | 目标宽高比,例如 1:1、16:9 |
target | "face" | "saliency" | Optional | 裁剪聚焦目标:face(人脸)或 saliency(主体) |
format | "jpeg" | "png" | "webp" | "avif" | Optional | Output image format. |
idempotency_key | string | Optional | Optional dedup key; identical retries return the same result. |
Returns
ProcessedImage { image_url, mime, width, height, bytes }Example
一次性前置(每个范例都假定已完成):
# 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
按角度旋转图片
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
image | ImageRef { url? | base64? | id? } | Required | Image reference as URL or base64. |
degrees | number | Required | 旋转角度(度) |
auto_orient | boolean | Optional | 是否按 EXIF 信息自动校正方向 |
format | "jpeg" | "png" | "webp" | "avif" | Optional | Output image format. |
idempotency_key | string | Optional | Optional dedup key; identical retries return the same result. |
Returns
ProcessedImage { image_url, mime, width, height, bytes }Example
一次性前置(每个范例都假定已完成):
# 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
按质量或目标字节数压缩图片
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
image | ImageRef { url? | base64? | id? } | Required | Image reference as URL or base64. |
quality | number | Optional | Compression quality from 0 to 100. |
target_bytes | number | Optional | 目标输出字节数上限,用于限定压缩后大小 |
format | "jpeg" | "png" | "webp" | "avif" | Optional | Output image format. |
idempotency_key | string | Optional | Optional dedup key; identical retries return the same result. |
Returns
ProcessedImage { image_url, mime, width, height, bytes }Example
一次性前置(每个范例都假定已完成):
# 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
把图片重新编码为另一种格式
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
image | ImageRef { url? | base64? | id? } | Required | Image reference as URL or base64. |
format | "jpeg" | "png" | "webp" | "avif" | Required | Output image format. |
idempotency_key | string | Optional | Optional dedup key; identical retries return the same result. |
Returns
ProcessedImage { image_url, mime, width, height, bytes }Example
一次性前置(每个范例都假定已完成):
# 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
为图片叠加文字或图片水印
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
image | ImageRef { url? | base64? | id? } | Required | Image reference as URL or base64. |
text | string | Optional | 水印文字内容 |
watermark_image | ImageRef { url? | base64? | id? } | Optional | 用作水印的图片引用(url/base64/id) |
position | "top-left" | "top-right" | "bottom-left" | "bottom-right" | "center" | Optional | 水印位置:四角或居中 |
opacity | number | Optional | 水印不透明度,0 到 1 之间 |
format | "jpeg" | "png" | "webp" | "avif" | Optional | Output image format. |
idempotency_key | string | Optional | Optional dedup key; identical retries return the same result. |
Returns
ProcessedImage { image_url, mime, width, height, bytes }Example
一次性前置(每个范例都假定已完成):
# 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 抠图去除图片背景
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
image | ImageRef { url? | base64? | id? } | Required | Image reference as URL or base64. |
format | "jpeg" | "png" | "webp" | "avif" | Optional | Output image format. |
idempotency_key | string | Optional | Optional dedup key; identical retries return the same result. |
Returns
ProcessedImage { image_url, mime, width, height, bytes }Example
一次性前置(每个范例都假定已完成):
# 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
检测并模糊图片中的人脸
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
image | ImageRef { url? | base64? | id? } | Required | Image reference as URL or base64. |
format | "jpeg" | "png" | "webp" | "avif" | Optional | Output image format. |
idempotency_key | string | Optional | Optional dedup key; identical retries return the same result. |
Returns
ProcessedImage { image_url, mime, width, height, bytes }Example
一次性前置(每个范例都假定已完成):
# 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
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
image_id | string | Required | 已存储图片的 id |
transform | ImageTransform | Optional | 图片变换参数对象(宽高、格式、裁剪等) |
Returns
{ url: string }Example
一次性前置(每个范例都假定已完成):
# 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
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
image_id | string | Required | 已存储图片的 id |
expires_in_s | number | Required | 签名 URL 的有效时长(秒) |
transform | ImageTransform | Optional | 图片变换参数对象(宽高、格式、裁剪等) |
Returns
{ url: string, expires_at: string }Example
一次性前置(每个范例都假定已完成):
# 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
注册一个具名图片变换模板
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
name | string | Required | 变换模板名称,用于在投放 URL 中复用 |
transform | ImageTransform | Required | 图片变换参数对象(宽高、格式、裁剪等) |
idempotency_key | string | Optional | Optional dedup key; identical retries return the same result. |
Returns
ImageTransformation { id, name, transform, created_at }Example
一次性前置(每个范例都假定已完成):
# 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
列出已注册的具名图片变换模板
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
cursor | string | Optional | 分页游标:传入上一页返回的 next_cursor 获取下一页。 |
limit | number | Optional | 单页返回条数上限。 |
Returns
{ items: ImageTransformation[], next_cursor? }Example
一次性前置(每个范例都假定已完成):
# 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
提交批量图片处理任务
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
items | Array<{ image, ops }> | Required | 批处理条目数组,每项含 image 与 ops(处理步骤) |
webhook_url | string | Optional | 任务完成时回调通知的 Webhook 地址 |
idempotency_key | string | Optional | Optional dedup key; identical retries return the same result. |
Returns
ImageJob { id, status, count, created_at }Example
一次性前置(每个范例都假定已完成):
# 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
查询批量图片处理任务的进度
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
id | string | Required | 批处理任务 job id |
Returns
ImageJob { id, status, count, done, failed, results? }Example
一次性前置(每个范例都假定已完成):
# 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
取消批量图片处理任务
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
id | string | Required | 要取消的批处理任务 job id |
idempotency_key | string | Optional | Optional dedup key; identical retries return the same result. |
Returns
ImageJob { id, status }Example
一次性前置(每个范例都假定已完成):
# 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": "..."}'All capabilities
Every routed capability in this module — the complete public REST contract. The methods above are the guided walkthrough; this index is the full reference.
| Capability | Endpoint | Description |
|---|---|---|
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. |
End-to-end example
A production-style walkthrough of this module: configure once, then run the flow. It exercises most of the module's APIs.
一次性前置(每个范例都假定已完成):
# 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}'