GET
图片处理
图片缩放
按宽或高等比缩放图片,也可指定宽高。
累计调用 16
今日调用 0
更新于 2026-10-16
调用地址
GET
https://itapi.top/api/imgresize
请求参数
| 参数名 | 类型 | 必填 | 说明 | 示例 |
|---|---|---|---|---|
| url | string | 必填 | 图片链接,或 data:image/...;base64,... | https://itapi.top/og.png |
| image | string | 可选 | 图片的 base64(与 url 二选一,可带 data:image 前缀) | https://itapi.top/og.png |
| width | int | 可选 | 目标宽 | 800 |
| height | int | 可选 | 目标高 | 600 |
| img | int | 可选 | 传 1 直接输出图片二进制 | 1 |
| raw | string | 可选 | img 的别名,传 1 效果相同 | 1 |
返回字段
| 字段名 | 类型 | 说明 |
|---|---|---|
| code | int | 状态码 |
| data.image | string | data URI(可直接放 img src) |
| data.format | string | 图片格式 |
| data.original | string | 原尺寸 |
| data.width | int | 新宽 |
| data.height | int | 新高 |
响应示例
200 OK
{"code":200,"msg":"success","data":{"original":"1200x630","width":800,"height":600,"image":"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAyAAAAJYCAYAAACadoJwAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAgAElEQVR4nOzdeXDc9WH\/\/9fqlixZsg5L1mHJp3whsGwL34DBiUNiBn6JMyUxnRxMmrSQYwpDKcMk6dRNU0iTGWiSL800bcwkJYTQhBAgxgZs+UD4lG3Zkqz7lq37lvb4\/eFIsWxJ+5G0+\/ns8Xz8hdn37uflQ9K+9vM+bC6XyyUAAAAAMEGI1QEAAAAABA8KCAAAAADTUEAAAAAAmIYCAgAAAMA0FBAAAAAApqGAAAAAADANBQQAAACAaSggAAAAAExDAQEAAABgGgoIAAAAANNQQAAAAACYhgICAAAAwDQUEAAAAACmoYAAAAAAMA0FBAAAAIBpKCAAAAAATEMBAQAAAGAaCggAAAAA01BAAAAAAJiGAgIAAADANBQQAAAAAKahgAAAAAAwDQUEAAAAgGkoIAAAAABMQwEBAAAAYBoKCAAAAADTUEAAAAAAmIYCAgAAAMA0FBAAAAAApqGAAAAAADANBQQAAACAaSggAAAAAExDAQEAAABgG...
在线测试
代码示例
cURL · GET
curl "https://itapi.top/api/imgresize?url=https%3A%2F%2Fitapi.top%2Fog.png&image=https%3A%2F%2Fitapi.top%2Fog.png&width=800&height=600&img=1&raw=1"
PHP
<?php
$res = file_get_contents("https://itapi.top/api/imgresize?url=https%3A%2F%2Fitapi.top%2Fog.png&image=https%3A%2F%2Fitapi.top%2Fog.png&width=800&height=600&img=1&raw=1");
$json = json_decode($res, true);
print_r($json);
JavaScript
const res = await fetch("https://itapi.top/api/imgresize?url=https%3A%2F%2Fitapi.top%2Fog.png&image=https%3A%2F%2Fitapi.top%2Fog.png&width=800&height=600&img=1&raw=1");
const json = await res.json();
console.log(json);
Python
import requests
r = requests.get("https://itapi.top/api/imgresize?url=https%3A%2F%2Fitapi.top%2Fog.png&image=https%3A%2F%2Fitapi.top%2Fog.png&width=800&height=600&img=1&raw=1", timeout=10)
print(r.json())