GET
图片处理
图片取色
取图片某点的颜色,或统计出主色调。
累计调用 21
今日调用 0
更新于 2026-10-16
调用地址
GET
https://itapi.top/api/imgcolor
请求参数
| 参数名 | 类型 | 必填 | 说明 | 示例 |
|---|---|---|---|---|
| url | string | 必填 | 图片链接 | https://itapi.top/og.png |
| image | string | 可选 | 图片的 base64(与 url 二选一,可带 data:image 前缀) | https://itapi.top/og.png |
| x | int | 可选 | 取色点 X(可选) | 风景 |
| y | int | 可选 | 取色点 Y(可选) | 风景 |
| img | string | 可选 | 传 1 直接输出图片二进制(不套 JSON) | 1 |
| raw | string | 可选 | img 的别名,传 1 效果相同 | 1 |
返回字段
| 字段名 | 类型 | 说明 |
|---|---|---|
| code | int | 状态码 |
| data.main | string | 主色 hex |
| data.colors | array | 主要颜色列表 |
| data.hex | string | 指定点颜色 |
响应示例
200 OK
{"code":200,"msg":"success","data":{"x":0,"y":0,"hex":"#ffffff","rgb":"rgb(255, 255, 255)","r":255,"g":255,"b":255}}
在线测试
代码示例
cURL · GET
curl "https://itapi.top/api/imgcolor?url=https%3A%2F%2Fitapi.top%2Fog.png&image=https%3A%2F%2Fitapi.top%2Fog.png&x=%E9%A3%8E%E6%99%AF&y=%E9%A3%8E%E6%99%AF&img=1&raw=1"
PHP
<?php
$res = file_get_contents("https://itapi.top/api/imgcolor?url=https%3A%2F%2Fitapi.top%2Fog.png&image=https%3A%2F%2Fitapi.top%2Fog.png&x=%E9%A3%8E%E6%99%AF&y=%E9%A3%8E%E6%99%AF&img=1&raw=1");
$json = json_decode($res, true);
print_r($json);
JavaScript
const res = await fetch("https://itapi.top/api/imgcolor?url=https%3A%2F%2Fitapi.top%2Fog.png&image=https%3A%2F%2Fitapi.top%2Fog.png&x=%E9%A3%8E%E6%99%AF&y=%E9%A3%8E%E6%99%AF&img=1&raw=1");
const json = await res.json();
console.log(json);
Python
import requests
r = requests.get("https://itapi.top/api/imgcolor?url=https%3A%2F%2Fitapi.top%2Fog.png&image=https%3A%2F%2Fitapi.top%2Fog.png&x=%E9%A3%8E%E6%99%AF&y=%E9%A3%8E%E6%99%AF&img=1&raw=1", timeout=10)
print(r.json())