Upscale an Image
Use image upscaling when you need a larger version of an existing image for publishing, printing, or another high-resolution workflow. Mirako enlarges one image by 2× or 4× and returns a PNG.
Image upscaling is synchronous: the request waits for processing to finish, so you do not need to poll when it succeeds.
Before You Start
Prepare an image that meets these requirements:
| Requirement | Supported value |
|---|---|
| Format | JPEG, PNG, or static WebP |
| Maximum file size | 32 MiB |
| Enlargement | 2 or 4; the default is 4 |
| Output | PNG |
Note: Animated WebP files are not supported. The API checks the file contents, not only the filename extension.
If this is your first Mirako request, complete Authentication before continuing.
Quick Start with the CLI
Upscale an image by 4× and save the result:
mirako image upscale \
--image product-photo.jpg \
--output product-photo-4x.png
Choose 2× when you need a smaller enlargement:
mirako image upscale \
--image product-photo.jpg \
--outscale 2 \
--output product-photo-2x.png
| Option | Required | Description |
|---|---|---|
--image, -i |
Yes | Path to a JPEG, PNG, or static WebP file. |
--outscale |
No | Enlargement factor: 2 or 4. Defaults to 4. |
--output, -o |
No | Where to save the PNG. If omitted, the CLI uses a generated filename. |
--no-save, -n |
No | Print the temporary result URL instead of downloading it. Cannot be combined with --output. |
If a completed task needs to be downloaded again, run:
mirako image upscale status <task-id> --output recovered-image.png
Integrate with the REST API
Set your API key as the MIRAKO_API_KEY environment variable. Send the source image as the file field of a multipart form. Do not set the Content-Type header yourself; your HTTP client needs to add the multipart boundary.
import os
import shutil
from pathlib import Path
import requests
API_KEY = os.environ["MIRAKO_API_KEY"]
BASE_URL = "https://mirako.co"
INPUT_PATH = Path("product-photo.jpg")
OUTPUT_PATH = Path("product-photo-4x.png")
headers = {"Authorization": f"Bearer {API_KEY}"}
try:
with INPUT_PATH.open("rb") as image_file:
response = requests.post(
f"{BASE_URL}/v1/image/upscale",
headers=headers,
params={"outscale": "4"},
files={"file": (INPUT_PATH.name, image_file)},
timeout=120,
)
response.raise_for_status()
task = response.json()["data"]
output = task["result"]["output"]
with requests.get(output["file_url"], stream=True, timeout=120) as download:
download.raise_for_status()
with OUTPUT_PATH.open("wb") as output_file:
shutil.copyfileobj(download.raw, output_file)
print(f"Saved {output['width']}×{output['height']} PNG to {OUTPUT_PATH}")
print(f"Result remains available until {output['readable_until']}")
except requests.RequestException as error:
detail = error.response.text if error.response is not None else str(error)
raise SystemExit(f"Image upscale failed: {detail}") from error
| Parameter | Location | Required | Description |
|---|---|---|---|
file |
Multipart form | Yes | JPEG, PNG, or static WebP image, up to 32 MiB. |
outscale |
Query | No | 2 or 4. Defaults to 4. |
webhook_url |
Multipart form | No | Public HTTPS callback URL, up to 1000 bytes. Usually unnecessary because this operation completes before returning. |
webhook_token |
Multipart form | No | Token sent to the callback as Authorization: Bearer <token>, up to 512 bytes. Requires webhook_url. |
See the Upscale Image API reference for the complete request and response schema.
Download the Result Promptly
A successful response includes the temporary download URL in data.result.output.file_url. The same object also provides its dimensions, file size, and readable_until timestamp.
The result remains available for 24 hours after it is created. A signed URL can expire sooner; before readable_until, request GET /v1/image/upscale/{task_id} to obtain a fresh URL. After that time, the API returns 410 RESULT_EXPIRED.
Going Next
Use the upscaled PNG in your publishing workflow, or use Generate Images with API when you need to create a new image instead of enlarging an existing one.