跳到正文

图像处理

缩放、压缩、转换、加水印与读取图像元数据。

概览

基础路径: https://api.infrai.cc/v1/image
鉴权头: Authorization: Bearer $INFRAI_API_KEY
bash
# 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

POST /v1/image/process

处理图像:缩放、压缩、转换、加水印、旋转或去背景。

参数

名称类型必填说明
inputImageRef { url? | base64? }
必填
图像引用,URL 或 base64。
widthnumber可选目标宽度(像素)。
heightnumber可选目标高度(像素)。
format"jpeg" | "png" | "webp" | "avif"可选输出图像格式。
qualitynumber可选压缩质量,0 到 100。
idempotency_keystring可选可选去重 key;相同重试将返回同一结果。

返回

ImageOpResult { image_url, mime, width?, height?, bytes }

示例

一次性前置(每个范例都假定已完成):

bash
# 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_..."
bash
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

POST /v1/image/metadata

读取图像尺寸、MIME 类型与 EXIF 元数据。

参数

名称类型必填说明
inputImageRef { url? | base64? }
必填
图像引用,URL 或 base64。

返回

{ width, height, mime, exif? }

示例

一次性前置(每个范例都假定已完成):

bash
# 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_..."
bash
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

POST /v1/image/upload

上传图片资源并返回资产 id 与 URL

参数

名称类型必填说明
filestring
必填
要上传的图片:本地文件路径或字节数据
filenamestring可选可选的文件名,用于存储与展示
idempotency_keystring可选可选去重 key;相同重试将返回同一结果。

返回

ImageAsset { id, url, mime, width?, height?, bytes }

示例

一次性前置(每个范例都假定已完成):

bash
# 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_..."
bash
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

GET /v1/image/get/{id}

按 id 读取单个图片资产的元信息

参数

名称类型必填说明
idstring
必填
图片资产 id

返回

ImageAsset { id, url, mime, width?, height?, bytes }

示例

一次性前置(每个范例都假定已完成):

bash
# 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_..."
bash
curl -X GET https://api.infrai.cc/v1/image/get/ID \
  -H "Authorization: Bearer $INFRAI_API_KEY"

image.list

GET /v1/image/list

分页列出已存储的图片资产

参数

名称类型必填说明
cursorstring可选分页游标:传入上一页返回的 next_cursor 获取下一页。
limitnumber可选单页返回条数上限。

返回

{ items: ImageAsset[], next_cursor? }

示例

一次性前置(每个范例都假定已完成):

bash
# 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_..."
bash
curl -X GET https://api.infrai.cc/v1/image/list \
  -H "Authorization: Bearer $INFRAI_API_KEY"

image.delete

DELETE /v1/image/delete/{id}

按 id 删除已存储的图片资产

参数

名称类型必填说明
idstring
必填
要删除的图片资产 id
idempotency_keystring可选可选去重 key;相同重试将返回同一结果。

返回

{ ok: boolean }

示例

一次性前置(每个范例都假定已完成):

bash
# 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_..."
bash
curl -X DELETE https://api.infrai.cc/v1/image/delete/ID \
  -H "Authorization: Bearer $INFRAI_API_KEY"

image.resize

POST /v1/image/resize

缩放图片到指定宽高

参数

名称类型必填说明
imageImageRef { url? | base64? | id? }
必填
图像引用,URL 或 base64。
widthnumber可选目标宽度(像素)。
heightnumber可选目标高度(像素)。
fit"inside" | "cover" | "contain" | "fill"可选缩放适配模式:inside/cover/contain/fill
enlargeboolean可选当原图小于目标尺寸时是否允许放大
format"jpeg" | "png" | "webp" | "avif"可选输出图像格式。
idempotency_keystring可选可选去重 key;相同重试将返回同一结果。

返回

ProcessedImage { image_url, mime, width, height, bytes }

示例

一次性前置(每个范例都假定已完成):

bash
# 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_..."
bash
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

POST /v1/image/crop

按 xywh 矩形框裁剪图片

参数

名称类型必填说明
imageImageRef { url? | base64? | id? }
必填
图像引用,URL 或 base64。
xnumber
必填
裁剪起点的横坐标(像素)
ynumber
必填
裁剪起点的纵坐标(像素)
widthnumber
必填
目标宽度(像素)。
heightnumber
必填
目标高度(像素)。
format"jpeg" | "png" | "webp" | "avif"可选输出图像格式。
idempotency_keystring可选可选去重 key;相同重试将返回同一结果。

返回

ProcessedImage { image_url, mime, width, height, bytes }

示例

一次性前置(每个范例都假定已完成):

bash
# 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_..."
bash
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

POST /v1/image/smart_crop

显著性感知裁剪到指定宽高比

参数

名称类型必填说明
imageImageRef { url? | base64? | id? }
必填
图像引用,URL 或 base64。
aspectstring
必填
目标宽高比,例如 1:1、16:9
target"face" | "saliency"可选裁剪聚焦目标:face(人脸)或 saliency(主体)
format"jpeg" | "png" | "webp" | "avif"可选输出图像格式。
idempotency_keystring可选可选去重 key;相同重试将返回同一结果。

返回

ProcessedImage { image_url, mime, width, height, bytes }

示例

一次性前置(每个范例都假定已完成):

bash
# 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_..."
bash
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

POST /v1/image/rotate

按角度旋转图片

参数

名称类型必填说明
imageImageRef { url? | base64? | id? }
必填
图像引用,URL 或 base64。
degreesnumber
必填
旋转角度(度)
auto_orientboolean可选是否按 EXIF 信息自动校正方向
format"jpeg" | "png" | "webp" | "avif"可选输出图像格式。
idempotency_keystring可选可选去重 key;相同重试将返回同一结果。

返回

ProcessedImage { image_url, mime, width, height, bytes }

示例

一次性前置(每个范例都假定已完成):

bash
# 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_..."
bash
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

POST /v1/image/compress

按质量或目标字节数压缩图片

参数

名称类型必填说明
imageImageRef { url? | base64? | id? }
必填
图像引用,URL 或 base64。
qualitynumber可选压缩质量,0 到 100。
target_bytesnumber可选目标输出字节数上限,用于限定压缩后大小
format"jpeg" | "png" | "webp" | "avif"可选输出图像格式。
idempotency_keystring可选可选去重 key;相同重试将返回同一结果。

返回

ProcessedImage { image_url, mime, width, height, bytes }

示例

一次性前置(每个范例都假定已完成):

bash
# 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_..."
bash
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

POST /v1/image/convert

把图片重新编码为另一种格式

参数

名称类型必填说明
imageImageRef { url? | base64? | id? }
必填
图像引用,URL 或 base64。
format"jpeg" | "png" | "webp" | "avif"
必填
输出图像格式。
idempotency_keystring可选可选去重 key;相同重试将返回同一结果。

返回

ProcessedImage { image_url, mime, width, height, bytes }

示例

一次性前置(每个范例都假定已完成):

bash
# 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_..."
bash
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

POST /v1/image/watermark

为图片叠加文字或图片水印

参数

名称类型必填说明
imageImageRef { url? | base64? | id? }
必填
图像引用,URL 或 base64。
textstring可选水印文字内容
watermark_imageImageRef { url? | base64? | id? }可选用作水印的图片引用(url/base64/id)
position"top-left" | "top-right" | "bottom-left" | "bottom-right" | "center"可选水印位置:四角或居中
opacitynumber可选水印不透明度,0 到 1 之间
format"jpeg" | "png" | "webp" | "avif"可选输出图像格式。
idempotency_keystring可选可选去重 key;相同重试将返回同一结果。

返回

ProcessedImage { image_url, mime, width, height, bytes }

示例

一次性前置(每个范例都假定已完成):

bash
# 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_..."
bash
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

POST /v1/image/background_remove

AI 抠图去除图片背景

参数

名称类型必填说明
imageImageRef { url? | base64? | id? }
必填
图像引用,URL 或 base64。
format"jpeg" | "png" | "webp" | "avif"可选输出图像格式。
idempotency_keystring可选可选去重 key;相同重试将返回同一结果。

返回

ProcessedImage { image_url, mime, width, height, bytes }

示例

一次性前置(每个范例都假定已完成):

bash
# 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_..."
bash
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

POST /v1/image/face_blur

检测并模糊图片中的人脸

参数

名称类型必填说明
imageImageRef { url? | base64? | id? }
必填
图像引用,URL 或 base64。
format"jpeg" | "png" | "webp" | "avif"可选输出图像格式。
idempotency_keystring可选可选去重 key;相同重试将返回同一结果。

返回

ProcessedImage { image_url, mime, width, height, bytes }

示例

一次性前置(每个范例都假定已完成):

bash
# 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_..."
bash
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

POST /v1/image/deliver_url

构建带变换参数的 CDN 投放 URL

参数

名称类型必填说明
image_idstring
必填
已存储图片的 id
transformImageTransform可选图片变换参数对象(宽高、格式、裁剪等)

返回

{ url: string }

示例

一次性前置(每个范例都假定已完成):

bash
# 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_..."
bash
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

POST /v1/image/signed_url

生成带时效的签名投放 URL

参数

名称类型必填说明
image_idstring
必填
已存储图片的 id
expires_in_snumber
必填
签名 URL 的有效时长(秒)
transformImageTransform可选图片变换参数对象(宽高、格式、裁剪等)

返回

{ url: string, expires_at: string }

示例

一次性前置(每个范例都假定已完成):

bash
# 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_..."
bash
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

POST /v1/image/transformation/create

注册一个具名图片变换模板

参数

名称类型必填说明
namestring
必填
变换模板名称,用于在投放 URL 中复用
transformImageTransform
必填
图片变换参数对象(宽高、格式、裁剪等)
idempotency_keystring可选可选去重 key;相同重试将返回同一结果。

返回

ImageTransformation { id, name, transform, created_at }

示例

一次性前置(每个范例都假定已完成):

bash
# 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_..."
bash
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

GET /v1/image/transformation/list

列出已注册的具名图片变换模板

参数

名称类型必填说明
cursorstring可选分页游标:传入上一页返回的 next_cursor 获取下一页。
limitnumber可选单页返回条数上限。

返回

{ items: ImageTransformation[], next_cursor? }

示例

一次性前置(每个范例都假定已完成):

bash
# 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_..."
bash
curl -X GET https://api.infrai.cc/v1/image/transformation/list \
  -H "Authorization: Bearer $INFRAI_API_KEY"

image.batch.submit

POST /v1/image/batch/submit

提交批量图片处理任务

参数

名称类型必填说明
itemsArray<{ image, ops }>
必填
批处理条目数组,每项含 image 与 ops(处理步骤)
webhook_urlstring可选任务完成时回调通知的 Webhook 地址
idempotency_keystring可选可选去重 key;相同重试将返回同一结果。

返回

ImageJob { id, status, count, created_at }

示例

一次性前置(每个范例都假定已完成):

bash
# 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_..."
bash
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

GET /v1/image/batch/status/{id}

查询批量图片处理任务的进度

参数

名称类型必填说明
idstring
必填
批处理任务 job id

返回

ImageJob { id, status, count, done, failed, results? }

示例

一次性前置(每个范例都假定已完成):

bash
# 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_..."
bash
curl -X GET https://api.infrai.cc/v1/image/batch/status/ID \
  -H "Authorization: Bearer $INFRAI_API_KEY"

image.batch.cancel

POST /v1/image/batch/cancel/{id}

取消批量图片处理任务

参数

名称类型必填说明
idstring
必填
要取消的批处理任务 job id
idempotency_keystring可选可选去重 key;相同重试将返回同一结果。

返回

ImageJob { id, status }

示例

一次性前置(每个范例都假定已完成):

bash
# 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_..."
bash
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_removePOST /v1/image/background_removeTransform an EXISTING image by AI-removing its background. To GENERATE images with AI use ai.image.
image.batch.cancelPOST /v1/image/batch/cancel/{id}Cancel a batch image-processing job by job ID; idempotent write.
image.batch.statusGET /v1/image/batch/status/{id}Get the progress and results of a batch image-processing job by job ID.
image.batch.submitPOST /v1/image/batch/submitSubmit a batch image-processing job and get a job handle, with optional webhook callback.
image.compressPOST /v1/image/compressTransform 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.convertPOST /v1/image/convertTransform an EXISTING image by re-encoding it to another format (jpeg/png/webp/avif). To GENERATE images with AI use ai.image.
image.cropPOST /v1/image/cropTransform an EXISTING image by cropping it to an x/y/w/h rectangle. To GENERATE images with AI use ai.image.
image.deleteDELETE /v1/image/delete/{id}Delete a stored image asset by ID; idempotent write.
image.deliver_urlPOST /v1/image/deliver_urlBuild a CDN delivery URL with transform parameters for a stored image.
image.face_blurPOST /v1/image/face_blurTransform an EXISTING image by detecting and blurring faces for redaction. To GENERATE images with AI use ai.image.
image.getGET /v1/image/get/{id}Get the metadata of one stored image asset (URL, MIME type, dimensions, byte size) by ID.
image.listGET /v1/image/listPage through the stored image assets on the account.
image.metadataPOST /v1/image/metadataInspect an EXISTING image's metadata (dimensions, format, EXIF) without modifying it; read-only.
image.moderatePOST /v1/image/moderateClassify 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.ocrPOST /v1/image/ocrExtract 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.processPOST /v1/image/processTransform an EXISTING image through a chained pipeline of ops, re-encoded once at the end. To GENERATE images with AI use ai.image.
image.resizePOST /v1/image/resizeTransform an EXISTING image by resizing it with a fit mode and optional upscaling/format. To GENERATE images with AI use ai.image.
image.rotatePOST /v1/image/rotateTransform an EXISTING image by rotating it, optionally auto-correcting orientation from EXIF. To GENERATE images with AI use ai.image.
image.signed_urlPOST /v1/image/signed_urlGenerate a time-limited signed delivery URL for a stored image.
image.smart_cropPOST /v1/image/smart_cropTransform 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.tagPOST /v1/image/tagDetect labels/objects in an image returning label + confidence pairs. Real vendor dispatch: Google Vision LABEL_DETECTION, AWS Rekognition DetectLabels. service_markup applies.
image.transformation.createPOST /v1/image/transformation/createRegister a named image-transformation template reusable in delivery URLs.
image.transformation.listGET /v1/image/transformation/listPage through the registered named image-transformation templates.
image.uploadPOST /v1/image/uploadUpload an image and get an asset with an ID and URL for later processing.
image.watermarkPOST /v1/image/watermarkTransform an EXISTING image by overlaying a text or image watermark with position and opacity. To GENERATE images with AI use ai.image.

完整示例

本模块的生产级端到端范例:先一次性配置,再运行业务流程,尽量覆盖本模块的多数 API。

一次性前置(每个范例都假定已完成):

bash
# 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_..."
bash
# 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}'