Image Resizer Logo

transform your images for FREE

Image Resizer API Documentation

← Back to Home

API Reference

Endpoint

POST https://www.imgresize.dev/resize

Request Body

{
  "imageUrl": string,    // URL of image to resize
  "width": number,      // Width in pixels
  "height": number,     // Height in pixels
  "outputFilename": string,  // Optional: save to file
  "keepTransparency": boolean, // Optional: preserve transparency (default: false)
  "rotateImage": boolean  // Optional: rotate 180 degrees (default: false)
}

Response

// Success
{
  "success": true,
  "imageUrl": string  // Base64 or file path
}

// Error
{
  "success": false,
  "error": string
}

Example Usage

fetch('https://www.imgresizer.dev/resize', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    imageUrl: 'https://example.com/image.jpg',
    width: 800,
    height: 600
  })
})
.then(response => response.json())
.then(data => {
  if (data.success) {
    console.log(data.imageUrl);
  }
});

Features

  • Resize images while maintaining aspect ratio
  • Option to receive base64 encoded image or save to file
  • White background added for transparent images
  • Support for common image formats (JPEG, PNG, WebP, etc.)
  • Option to preserve transparency in PNG/WebP images
  • Option to rotate images 180 degrees

Usage Notes

By default, the API returns a base64 encoded image string that can be directly used in image tags or stored. To save the resized image to a file instead, include the outputFilename parameter in your request.

The resize operation maintains aspect ratio using the 'contain' fit mode, which ensures the entire image is visible without distortion. Any empty space is filled with a white background.

When keepTransparency is enabled, the output will be in PNG format to preserve transparency. Otherwise, images are converted to JPEG with a white background.

When rotateImage is enabled, the image will be rotated 180 degrees before resizing. This can be combined with transparency and other options.

Rate Limits

The API is currently limited to:

  • 100 requests per minute per IP
  • Maximum image size: 10MB
  • Maximum output dimensions: 4096x4096 pixels