Docs图片工具

图像工具API

图像压缩、调整大小、转换、旋转、裁剪、背景移除、放大、人脸模糊和水印的端点。所有端点接受multipart/form-data并以二进制文件返回处理后的图像。

图像压缩

POST/api/image-compress

在保持视觉质量的同时压缩图像以减小文件大小。支持JPEG、PNG和WebP格式。

Parameters

NameTypeRequiredDescription
fileFileRequired图像文件(JPG、PNG、WebP)
qualitynumberOptional压缩质量,10-100。默认:80
targetSizeKBnumberOptional目标文件大小(KB)。设置后会覆盖quality参数。
keepMetadatastringOptional设为"true"以保留EXIF元数据
Response:Binary file
bash
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

NameTypeRequiredDescription
fileFileRequired图像文件
widthnumberOptional目标宽度(像素)
heightnumberOptional目标高度(像素)
percentagenumberOptional缩放百分比(例如:50表示缩小一半)
fitstringOptional"inside"(保持宽高比)或"fill"(拉伸到精确尺寸)
Response:Binary file
bash
# 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

NameTypeRequiredDescription
fileFileRequired图像文件
formatstringRequired目标格式:"png"、"jpg"、"webp"或"avif"
qualitynumberOptional输出质量,10-100
Response:Binary file
bash
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

NameTypeRequiredDescription
fileFileRequired图像文件
anglenumberRequired旋转角度(度数,例如:90、180、270)
flipHstringOptional设为"true"进行水平翻转
flipVstringOptional设为"true"进行垂直翻转
Response:Binary file
bash
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

NameTypeRequiredDescription
fileFileRequired图像文件
xnumberRequired裁剪矩形的左偏移量(像素)
ynumberRequired裁剪矩形的上偏移量(像素)
widthnumberRequired裁剪矩形的宽度(像素)
heightnumberRequired裁剪矩形的高度(像素)
Response:Binary file
bash
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

NameTypeRequiredDescription
fileFileRequired图像文件
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

NameTypeRequiredDescription
fileFileRequired图像文件
scalenumberOptional放大倍数:2或4。默认:2
Response:Binary file
bash
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

NameTypeRequiredDescription
fileFileRequired图像文件
Response:Binary file
bash
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

NameTypeRequiredDescription
fileFileRequired图像文件
textstringRequired水印文本
positionstringOptional位置:"center"、"top-left"、"top-right"、"bottom-left"、"bottom-right"
Response:Binary file
bash
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