Skip to content

Image Processing

Resize, compress, convert, watermark and read image metadata.

Overview

Base path: https://api.infrai.cc/v1/image
Auth header: 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"

Methods

image.process

POST /v1/image/process

Process an image: resize, compress, convert, watermark, rotate or remove background.

Parameters

NameTypeRequiredDescription
inputImageRef { url? | base64? }
Required
Image reference as URL or base64.
widthnumberOptionalTarget width in pixels.
heightnumberOptionalTarget height in pixels.
format"jpeg" | "png" | "webp" | "avif"OptionalOutput image format.
qualitynumberOptionalCompression quality from 0 to 100.
idempotency_keystringOptionalOptional dedup key; identical retries return the same result.

Returns

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

Example

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

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

Read image dimensions, MIME type and EXIF metadata.

Parameters

NameTypeRequiredDescription
inputImageRef { url? | base64? }
Required
Image reference as URL or base64.

Returns

{ width, height, mime, exif? }

Example

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

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

Parameters

NameTypeRequiredDescription
filestring
Required
要上传的图片:本地文件路径或字节数据
filenamestringOptional可选的文件名,用于存储与展示
idempotency_keystringOptionalOptional dedup key; identical retries return the same result.

Returns

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

Example

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

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 读取单个图片资产的元信息

Parameters

NameTypeRequiredDescription
idstring
Required
图片资产 id

Returns

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

Example

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

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

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

Parameters

NameTypeRequiredDescription
cursorstringOptional分页游标:传入上一页返回的 next_cursor 获取下一页。
limitnumberOptional单页返回条数上限。

Returns

{ items: ImageAsset[], next_cursor? }

Example

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

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 删除已存储的图片资产

Parameters

NameTypeRequiredDescription
idstring
Required
要删除的图片资产 id
idempotency_keystringOptionalOptional dedup key; identical retries return the same result.

Returns

{ ok: boolean }

Example

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

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

缩放图片到指定宽高

Parameters

NameTypeRequiredDescription
imageImageRef { url? | base64? | id? }
Required
Image reference as URL or base64.
widthnumberOptionalTarget width in pixels.
heightnumberOptionalTarget height in pixels.
fit"inside" | "cover" | "contain" | "fill"Optional缩放适配模式:inside/cover/contain/fill
enlargebooleanOptional当原图小于目标尺寸时是否允许放大
format"jpeg" | "png" | "webp" | "avif"OptionalOutput image format.
idempotency_keystringOptionalOptional dedup key; identical retries return the same result.

Returns

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

Example

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

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 矩形框裁剪图片

Parameters

NameTypeRequiredDescription
imageImageRef { url? | base64? | id? }
Required
Image reference as URL or base64.
xnumber
Required
裁剪起点的横坐标(像素)
ynumber
Required
裁剪起点的纵坐标(像素)
widthnumber
Required
Target width in pixels.
heightnumber
Required
Target height in pixels.
format"jpeg" | "png" | "webp" | "avif"OptionalOutput image format.
idempotency_keystringOptionalOptional dedup key; identical retries return the same result.

Returns

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

Example

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

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

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

Parameters

NameTypeRequiredDescription
imageImageRef { url? | base64? | id? }
Required
Image reference as URL or base64.
aspectstring
Required
目标宽高比,例如 1:1、16:9
target"face" | "saliency"Optional裁剪聚焦目标:face(人脸)或 saliency(主体)
format"jpeg" | "png" | "webp" | "avif"OptionalOutput image format.
idempotency_keystringOptionalOptional dedup key; identical retries return the same result.

Returns

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

Example

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

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

按角度旋转图片

Parameters

NameTypeRequiredDescription
imageImageRef { url? | base64? | id? }
Required
Image reference as URL or base64.
degreesnumber
Required
旋转角度(度)
auto_orientbooleanOptional是否按 EXIF 信息自动校正方向
format"jpeg" | "png" | "webp" | "avif"OptionalOutput image format.
idempotency_keystringOptionalOptional dedup key; identical retries return the same result.

Returns

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

Example

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

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

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

Parameters

NameTypeRequiredDescription
imageImageRef { url? | base64? | id? }
Required
Image reference as URL or base64.
qualitynumberOptionalCompression quality from 0 to 100.
target_bytesnumberOptional目标输出字节数上限,用于限定压缩后大小
format"jpeg" | "png" | "webp" | "avif"OptionalOutput image format.
idempotency_keystringOptionalOptional dedup key; identical retries return the same result.

Returns

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

Example

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

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

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

Parameters

NameTypeRequiredDescription
imageImageRef { url? | base64? | id? }
Required
Image reference as URL or base64.
format"jpeg" | "png" | "webp" | "avif"
Required
Output image format.
idempotency_keystringOptionalOptional dedup key; identical retries return the same result.

Returns

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

Example

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

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

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

Parameters

NameTypeRequiredDescription
imageImageRef { url? | base64? | id? }
Required
Image reference as URL or base64.
textstringOptional水印文字内容
watermark_imageImageRef { url? | base64? | id? }Optional用作水印的图片引用(url/base64/id)
position"top-left" | "top-right" | "bottom-left" | "bottom-right" | "center"Optional水印位置:四角或居中
opacitynumberOptional水印不透明度,0 到 1 之间
format"jpeg" | "png" | "webp" | "avif"OptionalOutput image format.
idempotency_keystringOptionalOptional dedup key; identical retries return the same result.

Returns

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

Example

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

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 抠图去除图片背景

Parameters

NameTypeRequiredDescription
imageImageRef { url? | base64? | id? }
Required
Image reference as URL or base64.
format"jpeg" | "png" | "webp" | "avif"OptionalOutput image format.
idempotency_keystringOptionalOptional dedup key; identical retries return the same result.

Returns

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

Example

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

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

检测并模糊图片中的人脸

Parameters

NameTypeRequiredDescription
imageImageRef { url? | base64? | id? }
Required
Image reference as URL or base64.
format"jpeg" | "png" | "webp" | "avif"OptionalOutput image format.
idempotency_keystringOptionalOptional dedup key; identical retries return the same result.

Returns

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

Example

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

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

Parameters

NameTypeRequiredDescription
image_idstring
Required
已存储图片的 id
transformImageTransformOptional图片变换参数对象(宽高、格式、裁剪等)

Returns

{ url: string }

Example

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

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

Parameters

NameTypeRequiredDescription
image_idstring
Required
已存储图片的 id
expires_in_snumber
Required
签名 URL 的有效时长(秒)
transformImageTransformOptional图片变换参数对象(宽高、格式、裁剪等)

Returns

{ url: string, expires_at: string }

Example

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

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

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

Parameters

NameTypeRequiredDescription
namestring
Required
变换模板名称,用于在投放 URL 中复用
transformImageTransform
Required
图片变换参数对象(宽高、格式、裁剪等)
idempotency_keystringOptionalOptional dedup key; identical retries return the same result.

Returns

ImageTransformation { id, name, transform, created_at }

Example

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

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

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

Parameters

NameTypeRequiredDescription
cursorstringOptional分页游标:传入上一页返回的 next_cursor 获取下一页。
limitnumberOptional单页返回条数上限。

Returns

{ items: ImageTransformation[], next_cursor? }

Example

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

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

提交批量图片处理任务

Parameters

NameTypeRequiredDescription
itemsArray<{ image, ops }>
Required
批处理条目数组,每项含 image 与 ops(处理步骤)
webhook_urlstringOptional任务完成时回调通知的 Webhook 地址
idempotency_keystringOptionalOptional dedup key; identical retries return the same result.

Returns

ImageJob { id, status, count, created_at }

Example

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

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}

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

Parameters

NameTypeRequiredDescription
idstring
Required
批处理任务 job id

Returns

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

Example

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

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}

取消批量图片处理任务

Parameters

NameTypeRequiredDescription
idstring
Required
要取消的批处理任务 job id
idempotency_keystringOptionalOptional dedup key; identical retries return the same result.

Returns

ImageJob { id, status }

Example

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

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": "..."}'

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.

CapabilityEndpointDescription
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.

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.

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

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}'