Upscale or Downscale image to specified dimensions
August 8, 2024
Table of contents
Runway AI Tools » Audio tools » Upscale Image.
This endpoint provides free & unlimited image upscaling/downscaling services. It works with free accounts without any limitations as well.
https://api.useapi.net/v1/runwayml/image_upscaler/?…
Request Headers
Authorization: Bearer {API token}
API token
is required, see Setup useapi.net for details.
Query Parameters
email
is optional when only one account configured. However, if you have multiple accounts configured, this parameter becomes required.image_url
is required. Image URL should be either the URL provided by text_to_image_preview or an asset URL from GET /assets. You may need to upload the image using POST /assets and use the URL provided for this parameter.weight
is required. Specify image width.height
is required. Specify image height.
Responses
-
Binary response containing a new image.
-
{ "error": "<Error message>", "code": 400 }
-
{ "error": "Unauthorized", "code": 401 }
-
{ "message": "Image was not found" }
Model
Binary stream in case of HTTP 200 response.
Otherwise see type provided below:
{ // TypeScript, all fields are optional
error: string,
message: string,
code: number
}
Examples
-
curl "https://api.useapi.net/v1/runwayml/image_upscaler/?image_url=https://…image.jpg&width=100&height=100" \ -H "Accept: application/json" \ -o resized_image.jpg
-
const token = "API token"; const image_url="https://…image.jpg"; const width = 100; const height = 200; const apiUrl = `https://api.useapi.net/v1/runwayml/image_upscaler/?image_url=${image_url}&width=${width}&height=${height}`; const response = await fetch(apiUrl, { headers: { "Authorization": `Bearer ${token}`, }, }); console.log("response", {response, result}); // response.blob() contains resized image // • Node.js saving resized image to file: // response.blob() // .then(blob => blob.arrayBuffer()) // .then(buffer => fs.writeFile('resized_image.jpg', Buffer.from(buffer))); // • Displaying response as an image on the webpage, as you see below in Try It section: // const imageBlob = await response.blob(); // const imageUrl = URL.createObjectURL(imageBlob); // const imageElement = document.getElementById('your-image-id'); // imageElement.src = imageUrl;
-
import requests # from io import BytesIO # from PIL import Image token = "API token" image_url = "https://…image.jpg" width = 100 height = 200 api_url = f"https://api.useapi.net/v1/runwayml/image_upscaler/?image_url={image_url}&width={width}&height={height}" headers = { "Authorization": f"Bearer {token}", } response = requests.get(api_url, headers=headers) with open('resized_image.jpg', 'wb') as f: f.write(response.content) # • Display the image (for example in a Jupyter Notebook) # image_stream = BytesIO(response.content) # image = Image.open(image_stream) # image.show()