five

Image Cropper API

收藏
RapidAPI2025-05-23 更新2025-05-24 收录
下载链接:
https://rapidapi.com/contactimgram/api/image-cropper-api1
下载链接
链接失效反馈
官方服务:
资源简介:
A powerful API that enables precise image cropping with pixel-perfect accuracy. Perfect for applications requiring image manipulation, content management systems, or any service needing automated image cropping capabilities.
创建时间:
2025-05-23
原始信息汇总

Image Cropper API 数据集概述

基本信息

  • API名称: Image Cropper API
  • 类别: Video, Images
  • 当前版本: v1
  • API地址: https://rapidapi.com/contactimgram/api/image-cropper-api1
  • 订阅计划:
    • BASIC: $0.00 / mo
    • PRO: $1.00 / mo
    • ULTRA: $2.00 / mo
    • MEGA: $5.00 / mo

API概述

  • 功能: 提供精确的图像裁剪功能,适用于图像处理、内容管理系统等需要自动化图像裁剪的场景。

主要特性

  • 精确裁剪: 支持按像素坐标裁剪图像。
  • 通用格式支持: 支持JPG、PNG等常见图像格式。
  • 高性能: 优化处理速度和响应时间。
  • 自动清理: 内置文件管理系统。
  • 安全处理: 安全可靠的图像处理。
  • 简单集成: 易于与任何应用集成。

API端点

1. 获取API信息

  • 方法: GET
  • 路径: /
  • 响应示例: json { "message": "Welcome to Image Cropper API. Use POST /crop-image endpoint to crop images." }

2. 裁剪图像

  • 方法: POST
  • 路径: /crop-image
  • 请求头:
    • Content-Type: multipart/form-data
  • 参数:
    参数名 类型 必填 约束 示例 描述
    file File - 最大10MB<br>- 格式: JPG, PNG, JPEG image.jpg 待裁剪的图像文件
    x Integer - ≥0<br>- <图像宽度 100 裁剪区域的起始x坐标
    y Integer - ≥0<br>- <图像高度 100 裁剪区域的起始y坐标
    width Integer - >0<br>- ≤(图像宽度 - x) 300 裁剪区域的宽度(像素)
    height Integer - >0<br>- ≤(图像高度 - y) 300 裁剪区域的高度(像素)
  • 响应:
    • Content-Type: image/jpeg
    • 文件下载: 裁剪后的图像
    • 文件名格式: cropped_[timestamp]_[original_filename]

代码示例

Python

python import requests

url = "https://your-rapidapi-url.com/crop-image" headers = { "X-RapidAPI-Key": "YOUR_API_KEY", "X-RapidAPI-Host": "your-rapidapi-host.com" }

files = {file: (image.jpg, open(image.jpg, rb), image/jpeg)} data = {x: 100, y: 100, width: 300, height: 300}

response = requests.post(url, files=files, data=data, headers=headers)

with open(cropped_image.jpg, wb) as f: f.write(response.content)

Node.js

javascript const axios = require(axios); const FormData = require(form-data); const fs = require(fs); const path = require(path);

const formData = new FormData(); formData.append(file, fs.createReadStream(path.resolve(image.jpg))); formData.append(x, 100); formData.append(y, 100); formData.append(width, 300); formData.append(height, 300);

const options = { method: POST, url: https://your-rapidapi-url.com/crop-image, headers: { X-RapidAPI-Key: YOUR_API_KEY, X-RapidAPI-Host: your-rapidapi-host.com, ...formData.getHeaders() }, data: formData, responseType: arraybuffer };

axios.request(options) .then(function (response) { fs.writeFileSync(cropped_image.jpg, response.data); console.log(Image cropped successfully!); }) .catch(function (error) { console.error(error); });

cURL

bash curl --location https://your-rapidapi-url.com/crop-image --header X-RapidAPI-Key: YOUR_API_KEY --header X-RapidAPI-Host: your-rapidapi-host.com --form file=@"/path/to/image.jpg" --form x="100" --form y="100" --form width="300" --form height="300"

使用场景

  1. 电商平台: 裁剪商品图像至统一尺寸。
  2. 社交媒体管理: 为不同平台准备图像。
  3. 内容管理系统: 自动化图像处理流程。
  4. 照片编辑应用: 提供基础裁剪功能。
  5. 数字资产管理: 标准化图像尺寸。
  6. 移动应用: 在移动设备上实现图像裁剪。

错误处理

常见错误响应: json {"detail": "No file provided"} {"detail": "Invalid coordinates. Values must be positive integers."} {"detail": "Invalid file format. Only image files are supported."} {"detail": "File size exceeds maximum limit of 10MB"} {"detail": "Crop area exceeds image boundaries"}

注意事项

  • 最大文件大小: 10MB
  • 支持的图像格式: JPG, PNG, JPEG
  • 坐标从0开始(0,0为左上角)
  • 所有尺寸单位为像素
  • 输出自动转换为JPEG格式
  • 必须使用multipart/form-data内容类型
  • 文件参数必须作为文件上传,而非base64字符串
  • 处理完成后自动清理文件
  • 坐标和尺寸必须在原图范围内
5,000+
优质数据集
54 个
任务类型
进入经典数据集
二维码
社区交流群

面向社区/商业的数据集话题

二维码
科研交流群

面向高校/科研机构的开源数据集话题

数据驱动未来

携手共赢发展

商业合作