跳至內容

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.com/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.com/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.com/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.com/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.com/v1/requests/req_8k2m4q7x1z9c3v5b6n0p2r4t",
    "cancel": "https://api.doitong.com/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-TW/developers/models/image2pixel.md. 所有模型與指南: https://doitong.com/developers/llms.txt