跳转到内容

Image2Pixel

集成

模型 id image2pixel
# Run the model; wait up to 20 s for the finished result in the same call
curl -X POST "https://api.doitong.ru/v1/run/image2pixel?wait=20" \
  -H "Authorization: Bearer $DOITONG_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "image": "https://content.doitong.com/images/showcase/v3/gen_fox_cartoon.jpg"
  }'

# Still "queued" or "running"? Poll with the id from the response:
curl "https://api.doitong.ru/v1/requests/REQUEST_ID?wait=20" \
  -H "Authorization: Bearer $DOITONG_API_KEY"

每次运行最高 $0.153 按实际用量收费,剩余部分退款 在此页面运行

获取 API 密钥
Utility 图像编辑 #post-processing#pixel-art

将图像转换为简洁的像素艺术,支持调色板限制、比例检测和可选透明背景

Utility · 图像

你的第一个结果会显示在这里

在下方构建请求,并使用你的 API 密钥运行。输出会复制到我们的存储中,可永久保存,也可免费保存 7 天。

构建请求

控件根据模型架构生成。修改控件时,代码和价格会同步更新。

•必填 image_url
拖放文件,或

用于转换为改进像素艺术的源图像 URL。

高级 detect_method · downscale_method · background_mode · max_colors · scale · alpha_threshold · dominant_color_threshold · background_tolerance · auto_color_detect · trim_borders · transparent_background · cleanup_morph · cleanup_jaggy · snap_grid · fixed_palette
detect_method 默认 auto

用于检测缩放比例的方法。

downscale_method 默认 dominant

用于缩小为像素艺术的方法。

background_mode 默认 corners

移除背景时洪水填充的起始位置。

默认 32

输出调色板的颜色数量上限;None 允许使用无限数量的颜色。

要强制使用的像素缩放比例;None 启用自动检测。

默认 128

Alpha 二值化阈值,范围为 0 到 255。

默认 0.05

主色阈值,范围为 0.0 到 1.0。

默认 0

背景容差,范围为 0 到 255。

使用十六进制字符串指定的可选预定义调色板,例如 ['#000000', '#ffffff']。

POST /run/image2pixel?wait=20 报价 → $0.153
# Run the model; wait up to 20 s for the finished result in the same call
curl -X POST "https://api.doitong.ru/v1/run/image2pixel?wait=20" \
  -H "Authorization: Bearer $DOITONG_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "image": "https://content.doitong.com/images/showcase/v3/gen_fox_cartoon.jpg"
  }'

# Still "queued" or "running"? Poll with the id from the response:
curl "https://api.doitong.ru/v1/requests/REQUEST_ID?wait=20" \
  -H "Authorization: Bearer $DOITONG_API_KEY"

运行此请求

你的密钥会保留在此浏览器中:仅发送到 Doitong API;只有勾选“记住”后才会保存到 localStorage。 获取 API 密钥

关于 Image2Pixel

将输入图像转换为像素艺术,并以 PNG 文件返回处理后的图像和缩放版本。可以使用 `max_colors`(1 到 256)限制调色板,提供由十六进制颜色组成的 `fixed_palette`,或强制设置 1 到 64 的 `scale`。支持多种缩小方法、清理选项和背景移除模式。响应还会报告颜色数量、调色板和检测到的像素比例。

参数

发送规范名称或原生名称之一,不要同时发送两者。 规范名称

名称类型 默认值允许值 描述
image_url必填 image
类型url · image
用于转换为改进像素艺术的源图像 URL。
max_colors可选
类型integer | null
默认值32
1 – 256
输出调色板的颜色数量上限;None 允许使用无限数量的颜色。
auto_color_detect可选
类型boolean
默认值false
启用自动选择最佳颜色数量。
fixed_palette可选
类型string[]
使用十六进制字符串指定的可选预定义调色板,例如 ['#000000', '#ffffff']。
detect_method可选
类型enum
默认值auto
autorunsedge
用于检测缩放比例的方法。
scale可选
类型integer | null
1 – 64
要强制使用的像素缩放比例;None 启用自动检测。
downscale_method可选
类型enum
默认值dominant
dominantmedianmodemeancontent-adaptive
用于缩小为像素艺术的方法。
trim_borders可选
类型boolean
默认值false
控制图像边框的裁剪。
transparent_background可选
类型boolean
默认值false
通过透明度移除背景:图像校正完成后,与图像边缘相连的同色区域将变为透明。
cleanup_morph可选
类型boolean
默认值false
使用形态学操作去除噪声。
cleanup_jaggy可选
类型boolean
默认值false
通过移除孤立的对角像素来清理锯齿边缘。
snap_grid可选
类型boolean
默认值true
将输出对齐到像素网格。
alpha_threshold可选
类型integer
默认值128
0 – 255
Alpha 二值化阈值,范围为 0 到 255。
dominant_color_threshold可选
类型number
默认值0.05
0 – 1
主色阈值,范围为 0.0 到 1.0。
background_tolerance可选
类型integer
默认值0
0 – 255
背景容差,范围为 0 到 255。
background_mode可选
类型enum
默认值corners
edgescornersmidpoints
移除背景时洪水填充的起始位置。
必填 规范名称,也可接受

文件参数接受公开的 https:// URL、最大 10 MB 的 data: URI,或上传文件的 file_url。 文件

输出

GET /requests/req_8k2m4q7x1z9c3v5b6n0p2r4t
{
  "id": "req_8k2m4q7x1z9c3v5b6n0p2r4t",
  "object": "request",
  "model": "image2pixel",
  "status": "succeeded",
  "created_at": "2026-10-20T12:00:00Z",
  "started_at": "2026-10-20T12:00:02Z",
  "completed_at": "2026-10-20T12:00:09Z",
  "queue_position": null,
  "cost": {
    "credits": 153,
    "usd": "0.153",
    "charged": 153,
    "refunded": 0
  },
  "input": {
    "image_url": "https://content.doitong.com/images/showcase/v3/gen_fox_cartoon.jpg"
  },
  "output": {
    "pixel_scale": 21,
    "palette": [
      "string"
    ],
    "num_colors": 10,
    "images": [
      {
        "url": "https://content.doitong.com/dev-api/2026/10/20/req_8k2m4q7x1z9c3v5b6n0p2r4t/0-output.jpeg",
        "content_type": "image/jpeg",
        "file_name": "0-output.jpeg",
        "file_size": 1843200,
        "width": 1024,
        "height": 768
      }
    ]
  },
  "outputs": [
    {
      "type": "image",
      "url": "https://content.doitong.com/dev-api/2026/10/20/req_8k2m4q7x1z9c3v5b6n0p2r4t/0-output.jpeg",
      "content_type": "image/jpeg",
      "file_size": 1843200,
      "width": 1024,
      "height": 768,
      "stored": true
    }
  ],
  "error": null,
  "metrics": {
    "inference_seconds": 6.8
  },
  "urls": {
    "self": "https://api.doitong.ru/v1/requests/req_8k2m4q7x1z9c3v5b6n0p2r4t",
    "cancel": "https://api.doitong.ru/v1/requests/req_8k2m4q7x1z9c3v5b6n0p2r4t/cancel"
  }
}
文件由你选择每个 outputs[].url 都是我们存储中的副本:可永久保存(按 GB-月付费),也可免费保存 7 天,由账户设置或 ?storage= 决定。
所有模型的结构一致图像、视频和音频的字段均为 type、url、content_type、width、height 和 duration。output 是模型自身的结果对象。
输出字段
pixel_scale
integer在输入中检测到的像素缩放比例。
palette
array of string处理后媒体的颜色调色板。
num_colors
integer处理后媒体的颜色数量。
images
array of object {url, content_type, file_name, file_size, width, height}处理后的像素艺术图像和缩放图像,均为 PNG 格式。

对于 AI 代理:此页面的 Markdown 版本位于 https://doitong.com/zh-CN/developers/models/image2pixel.md. 所有模型和指南: https://doitong.com/developers/llms.txt