Image Processing
Resize, compress, convert, watermark and read image metadata.
Overview
Base path:
/v1/imagePython namespace:
infra.image_processtext
# Python
from infrai import infra
# TypeScript
import { InfraiClient } from "@infrai/sdk";
const client = new InfraiClient({ apiKey: process.env.INFRAI_API_KEY! });
// → client.imageMethods
image.process
POST /v1/image/process
Process an image: resize, compress, convert, watermark, rotate or remove background.
Python
python
infra.image_process.process(...) # resize / compress / convert / watermark / rotate / removebgTypeScript
typescript
client.image.resize(opts) | .compress(opts) | .convert(opts) | .watermark(opts) | .rotate(opts) | .removebg(opts)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
一次性前置(每个范例都假定已完成):
bash
pip install infrai
# one-time auth (no secret needed): anonymous account + trial, writes ~/.infrai/credentials
python -c "from infrai import infra; infra.activate()"
# returning user instead: export INFRAI_API_KEY=ifr_pk_proj_...python
from infrai import infra
out = infra.image_process.resize(input={"url": "https://ex.com/photo.jpg"}, width=800)
print("image url:", out.get("image_url"))image.metadata
POST /v1/image/metadata
Read image dimensions, MIME type and EXIF metadata.
Python
python
infra.image_process.metadata(input=...)TypeScript
typescript
client.image.metadata(opts: { input }): Promise<{ width, height, mime, exif? }>Parameters
| Name | Type | Required | Description |
|---|---|---|---|
input | ImageRef { url? | base64? } | Required | Image reference as URL or base64. |
Returns
{ width, height, mime, exif? }Example
一次性前置(每个范例都假定已完成):
bash
pip install infrai
# one-time auth (no secret needed): anonymous account + trial, writes ~/.infrai/credentials
python -c "from infrai import infra; infra.activate()"
# returning user instead: export INFRAI_API_KEY=ifr_pk_proj_...python
from infrai import infra
meta = infra.image_process.metadata(input={"url": "https://ex.com/photo.jpg"})
print(meta.get("width"), "x", meta.get("height"), meta.get("mime"))