Image Compression API Documentation

Upload an image and receive a compressed version with optional resizing and quality control.

Don't have any Rate Limit but do use the API responsibly.

API Overview

The Image Compression API allows clients to upload images and receive optimized versions with optional resizing and compression parameters. The image is returned directly in the response, either as a base64 string or file stream.

Base URL: https://hishuanigami.com/api/v1/image/compress

Features

Endpoint

POST
/api/v1/compress

Parameters

Parameter Type Required Description
image file (jpeg, png, webp) Yes The image file to upload and compress
width integer No Target width (maintains aspect ratio if only width is provided)
height integer No Target height (maintains aspect ratio if only height is provided)
quality integer No Compression quality (10-100, default is 80)
format string No Convert to jpeg, png, or webp
base64 boolean No Return image as base64 string instead of stream (true/false)
download boolean No Force file download if false returns it inline

Response Format

{
  "message": "Image compressed successfully",
  "image_base64": "data:image/jpeg;base64,...",
  "extension": "jpeg",
  "mime": "image/jpeg",
  "size_kb": 123.45
}

Usage Examples

1. Basic Compression

POST https://hishuanigami.com/api/v1/image/compress
Form Data:
- image: [yourfile.png]

2. Resize & Compress

POST https://hishuanigami.com/api/v1/image/compress
Form Data:
- image: [yourfile.jpg]
- width: 500
- height: 500
- quality: 70

3. Convert to WebP + Return as Base64

POST https://hishuanigami.com/api/v1/image/compress
Form Data:
- image: [yourfile.png]
- format: webp
- base64: true

4. Force Download

POST https://hishuanigami.com/api/v1/image/compress
Form Data:
- image: [yourfile.jpg]
- format: jpeg
- download: true

Response Codes

200 Success

Returns compressed image as file or base64

400 Bad Request

Invalid file or parameters

{"message": "The image field is required."}

429 Too Many Requests

Rate limit exceeded

{"error": "Too many requests"}

500 Internal Server Error

Error during image processing

{"error": "Image processing failed"}