Image Converter Microservice

High-performance image processing API with format conversion, resizing, and compression

๐Ÿ“‹ Overview

This microservice provides powerful image processing capabilities through simple HTTP endpoints. Built with Node.js, Express, and Sharp for optimal performance.

Features

๐Ÿ” Authentication

All image processing endpoints require authentication via API key. You can provide the API key in two ways:

Method 1: HTTP Header

X-API-Key: your-api-key

Method 2: Query Parameter

?apiKey=your-api-key

Note: Make sure to keep your API key secure and don't expose it in client-side code.

๐Ÿ› ๏ธ API Endpoints

POST /image/convert

Convert an image from one format to another.

file form-data

The image file to convert (required)

format query

Target format (optional, default: "png")
Supported: png, jpeg, webp, gif, tiff, avif

Example:

curl -X POST \ 'http://localhost:3000/image/convert?format=jpeg&apiKey=your-key' \ -F 'file=@image.png'

POST /image/resize

Resize an image to specified dimensions.

file form-data

The image file to resize (required)

width query

Target width in pixels (optional)

height query

Target height in pixels (optional)

format query

Output format (optional, default: "png")

Example:

curl -X POST \ 'http://localhost:3000/image/resize?width=800&height=600&apiKey=your-key' \ -F 'file=@image.jpg'

POST /image/compress

Compress an image to reduce file size.

file form-data

The image file to compress (required)

format query

Output format (optional, default: "jpeg")
Supported: jpeg, png, webp

quality query

Compression quality 1-100 (optional, default: 80)
Only applies to JPEG and WebP formats

Example:

curl -X POST \ 'http://localhost:3000/image/compress?format=webp&quality=75&apiKey=your-key' \ -F 'file=@image.png'

๐Ÿงช Try It Out

Test the API directly from this page

Upload an image and test the different endpoints:

๐Ÿ“Š Response Codes

๐Ÿ’ก Best Practices