DEV Community

GuGuData
GuGuData

Posted on

Image Compress API

Image Compress API

Image Compress API

The Image Compress API from Gugudata enables developers to efficiently compress and optimize images via API. Whether you're working with user-uploaded files or image URLs, this API provides full control over compression quality, resizing, and format conversion.

Designed for integration into high-performance websites, mobile applications, and content management systems (CMS), this API helps reduce bandwidth usage and improve image loading speeds without compromising on visual quality.

๐Ÿ“˜ View full API documentation

๐Ÿ”ง Manage your appkey & usage


๐Ÿ”ง Features Overview

  • Supports both file upload and image URL processing
  • Customizable compression quality (1โ€“95, default: 85)
  • Flexible size control: set exact target dimensions or max constraints
  • Maintains image aspect ratio automatically
  • Optional format conversion: JPEG, PNG, etc.
  • Handles large image files (up to 10MB)
  • High-performance API with load balancing
  • TLS 1.0โ€“1.3 supported, fully HTTPS and Apple ATS compatible
  • Distributed CDN across regions for fast response

๐Ÿ“Œ API Endpoint

  • URL: https://api.gugudata.io/v1/image/image-compress
  • Method: POST
  • Content-Type: multipart/form-data or application/x-www-form-urlencoded
  • Test the API: Demo here

๐Ÿงพ Request Parameters

Name Type Required Default Description
appkey string Yes YOUR_APPKEY Your API key from Gugudata. Required for authentication.
file file No N/A Upload an image file (JPEG, PNG, etc.). Provide either file or image_url, not both.
image_url string No N/A Public image URL to process. Provide either image_url or file, not both.
targetWidth integer No N/A Desired width (px). Will maintain aspect ratio.
targetHeight integer No N/A Desired height (px). Will maintain aspect ratio.
maxWidth integer No N/A Maximum allowed width. Image will be resized if larger.
maxHeight integer No N/A Maximum allowed height. Image will be resized if larger.
quality integer No 85 Compression level (1โ€“95). Higher = better quality.
format string No original Output format (e.g., jpeg, png). Defaults to original format.

๐Ÿ“ค Response Format

The API responds with a binary stream of the compressed image.

  • Content-Type: Based on the image format (e.g., image/jpeg)
  • Response: Direct binary image data

Make sure your client handles binary image responses correctly.


โ— Error Codes

Code Message Description
200 Normal return Image compressed successfully
400 Parameter error Invalid or missing parameters; file or URL required
402 APPKEY error Invalid or unauthorized appkey
403 Account in arrears Service blocked due to unpaid usage
429 Too many requests Exceeded 100 requests/second
500 Server error Internal processing error
503 Service unavailable External service is currently down

๐Ÿ’ก Example Request

curl -X POST "https://api.gugudata.io/v1/image/image-compress" \
  -H "Content-Type: multipart/form-data" \
  -F "appkey=YOUR_APPKEY" \
  -F "file=@your-image.jpg" \
  -F "quality=80" \
  -F "format=jpeg"
Enter fullscreen mode Exit fullscreen mode

Or using a URL:

curl -X POST "https://api.gugudata.io/v1/image/image-compress" \
  -d "appkey=YOUR_APPKEY" \
  -d "image_url=https://example.com/image.png" \
  -d "quality=75" \
  -d "maxWidth=800"
Enter fullscreen mode Exit fullscreen mode

โœ… Use Case Scenarios

  • Website Performance: Compress homepage banners and thumbnails before delivery.
  • User Uploads: Optimize profile pictures or gallery images in real time.
  • CMS Integration: Automatically resize and convert images during publishing.
  • E-Commerce: Generate optimized product images for faster loading.
  • Mobile Apps: Reduce bandwidth and storage for image-heavy apps.

๐Ÿ“Š Developer Resources


The Image Compress API is ideal for developers building performance-oriented platforms with rich media content. With intelligent optimization and high-speed delivery, it streamlines your image pipeline while preserving quality.

Top comments (0)