图像工具API
图像压缩、调整大小、转换、旋转、裁剪、背景移除、放大、人脸模糊和水印的端点。所有端点接受multipart/form-data并以二进制文件返回处理后的图像。
图像压缩
POST
/api/image-compress在保持视觉质量的同时压缩图像以减小文件大小。支持JPEG、PNG和WebP格式。
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
file | File | Required | 图像文件(JPG、PNG、WebP) |
quality | number | Optional | 压缩质量,10-100。默认:80 |
targetSizeKB | number | Optional | 目标文件大小(KB)。设置后会覆盖quality参数。 |
keepMetadata | string | Optional | 设为"true"以保留EXIF元数据 |
Response:
Binary filebash
curl -X POST https://freefiletools.io/api/image-compress \
-H "x-api-key: fft_your_api_key" \
-F "[email protected]" \
-F "quality=75" \
-o compressed.jpg图像调整大小
POST
/api/image-resize将图像调整为特定尺寸或按百分比缩放。支持像素尺寸和百分比缩放。
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
file | File | Required | 图像文件 |
width | number | Optional | 目标宽度(像素) |
height | number | Optional | 目标高度(像素) |
percentage | number | Optional | 缩放百分比(例如:50表示缩小一半) |
fit | string | Optional | "inside"(保持宽高比)或"fill"(拉伸到精确尺寸) |
Response:
Binary filebash
# Resize to specific width (height auto-calculated)
curl -X POST https://freefiletools.io/api/image-resize \
-H "x-api-key: fft_your_api_key" \
-F "[email protected]" \
-F "width=800" \
-o resized.jpg
# Resize by percentage
curl -X POST https://freefiletools.io/api/image-resize \
-H "x-api-key: fft_your_api_key" \
-F "[email protected]" \
-F "percentage=50" \
-o resized.jpg图像转换
POST
/api/image-convert在不同格式之间转换图像。支持PNG、JPG、WebP和AVIF。
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
file | File | Required | 图像文件 |
format | string | Required | 目标格式:"png"、"jpg"、"webp"或"avif" |
quality | number | Optional | 输出质量,10-100 |
Response:
Binary filebash
curl -X POST https://freefiletools.io/api/image-convert \
-H "x-api-key: fft_your_api_key" \
-F "[email protected]" \
-F "format=webp" \
-F "quality=85" \
-o photo.webp图像旋转
POST
/api/image-rotate旋转和/或翻转图像。支持任意旋转角度和水平/垂直翻转。
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
file | File | Required | 图像文件 |
angle | number | Required | 旋转角度(度数,例如:90、180、270) |
flipH | string | Optional | 设为"true"进行水平翻转 |
flipV | string | Optional | 设为"true"进行垂直翻转 |
Response:
Binary filebash
curl -X POST https://freefiletools.io/api/image-rotate \
-H "x-api-key: fft_your_api_key" \
-F "[email protected]" \
-F "angle=90" \
-o rotated.jpg图像裁剪
POST
/api/image-crop将图像裁剪为特定的矩形区域。
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
file | File | Required | 图像文件 |
x | number | Required | 裁剪矩形的左偏移量(像素) |
y | number | Required | 裁剪矩形的上偏移量(像素) |
width | number | Required | 裁剪矩形的宽度(像素) |
height | number | Required | 裁剪矩形的高度(像素) |
Response:
Binary filebash
curl -X POST https://freefiletools.io/api/image-crop \
-H "x-api-key: fft_your_api_key" \
-F "[email protected]" \
-F "x=100" \
-F "y=50" \
-F "width=500" \
-F "height=400" \
-o cropped.jpg移除背景
POST
/api/remove-bg自动移除图像背景。返回透明背景的PNG。
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
file | File | Required | 图像文件 |
Response:
透明背景的PNG图像bash
curl -X POST https://freefiletools.io/api/remove-bg \
-H "x-api-key: fft_your_api_key" \
-F "[email protected]" \
-o no-background.png图像放大
POST
/api/image-upscale使用AI放大图像以提高分辨率,同时保留细节。
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
file | File | Required | 图像文件 |
scale | number | Optional | 放大倍数:2或4。默认:2 |
Response:
Binary filebash
curl -X POST https://freefiletools.io/api/image-upscale \
-H "x-api-key: fft_your_api_key" \
-F "[email protected]" \
-F "scale=4" \
-o upscaled.jpg人脸模糊
POST
/api/blur-face自动检测并模糊图像中所有人脸以保护隐私。
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
file | File | Required | 图像文件 |
Response:
Binary filebash
curl -X POST https://freefiletools.io/api/blur-face \
-H "x-api-key: fft_your_api_key" \
-F "[email protected]" \
-o blurred.jpg图像水印
POST
/api/watermark-image为图像添加文字水印。可自定义文本和位置。
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
file | File | Required | 图像文件 |
text | string | Required | 水印文本 |
position | string | Optional | 位置:"center"、"top-left"、"top-right"、"bottom-left"、"bottom-right" |
Response:
Binary filebash
curl -X POST https://freefiletools.io/api/watermark-image \
-H "x-api-key: fft_your_api_key" \
-F "[email protected]" \
-F "text=Copyright 2024" \
-F "position=bottom-right" \
-o watermarked.jpg