---
title: Change Image Aspect Ratio API
slug: restore-image-aspect-ratio
url: https://apyhub.com/dosvak/service/restore-image-aspect-ratio
provider: Dosvak LLC
categories: [File Manipulation]
tags: [image-processing, aspect-ratio, image-restoration, image-transformation, binary-image]
auth: api_key
version: 1.0.0
service_type: sync
endpoints: 1
atoms: 100
---

# Change Image Aspect Ratio API

Restore a stretched image to a target aspect ratio. Send an image file and get corrected binary output back for cleanup and publishing workflows.

## Endpoints

| Method | URL | Description | Atoms |
| --- | --- | --- | --- |
| POST | `https://api.eu.apyhub.com/dosvak/restore-image-aspect-ratio` | What it does Restores a stretched image to a target aspect ratio by accepting an uploaded image fil… | 100 |

## Endpoint reference

### Restore a stretched image to a target aspect ratio

`POST https://api.eu.apyhub.com/dosvak/restore-image-aspect-ratio` · 100 atoms · accepts `multipart/form-data` · returns `application/json`

| Parameter | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `file` | body | string (binary) | yes | Image file |
| `target_aspect` | query | string | no | Default: `1:1`. Example: `4:3`. |
| `keep_long_edge` | query | boolean | no | Default: `true`. Example: `true`. |

#### Quickstart

Restore an image while keeping its aspect ratio by uploading a file and choosing the target ratio as a query parameter.

```bash
curl -X POST "https://api.eu.apyhub.com/dosvak/restore-image-aspect-ratio?target_aspect=4%3A3" \
  -H "apy-token: $APY_TOKEN" \
  -F "file=@/path/to/image.jpg"
```

#### What you'll get back

Returns a binary file (`string` with `format: binary`), which is the restored image.

## About

## What it does
Image Aspect Ratio Restore takes a stretched image and returns a binary image adjusted to a target aspect ratio. Send a single image file in the request body, and optionally set `target_aspect` in the query string to values like `4:3` or use the default `1:1`.

Use `keep_long_edge` when you want to preserve the longer side of the image while restoring proportions. The service is designed for cases where an image has been displayed or resized incorrectly and needs to be brought back into a standard layout for further editing, publishing, or storage.

The response is the corrected image as binary data, so you can pass it straight into your next image workflow without parsing extra metadata. That makes it useful in automated asset pipelines, CMS cleanup jobs, or any process that needs to normalize user-uploaded images before delivery.

## Usage

Base URL: `https://api.eu.apyhub.com` (default region — see
`GET https://apyhub.com/api/public/regions` for the rest).

Authenticate with an ApyHub API key in the `apy-token` header.
Full docs and a live playground: https://apyhub.com/dosvak/service/restore-image-aspect-ratio
