Online Upscaler

You can get started quickly and easily using our API on RapidAPI.

Scale

Quick Start

In general, images are processed by submitting a request containing a base64 encoded image or the url of an image. Aisthetic then processes the image and returns a Base64 encoded response. Please visit our docs for additional information.

Javascript
Uploading Images - Express.js example
router.post('/upload', (req,res) => {
  //Get your uploaded file from a form. This is using express-fileupload.
  let image = req.files.image;
  //Convert your image to base64 encoding
  let encodedImage = Buffer.from(image.data).toString("base64")
  //Replace characters for a url-friendly encoded image
  let urlEncodedImage = encodedImage.replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/g, '');
  //Set the amount the image should be upscaled (2, 4, or 8)
  let scale = 4

  //Configure the post request using unirest
  let unirest = require("unirest");
  let request = unirest("POST", "https://enlarge-images.p.rapidapi.com/"");

  request.headers({
    "x-rapidapi-host": "enlarge-images.p.rapidapi.com",
    "x-rapidapi-key": "Your RapidApi Key",
    "content-type": "application/x-www-form-urlencoded"
  });

  request.form({
    "scale": scale,
    "b64image": urlEncodedImage
  });

  request.end((response) => {
    if (response.error) {console.log(response.error)}
    res.json(response.body)
  });
})
Response - Client-side Javascript or via backend Express.js
//within API request callback
callback (response) {
  //parse JSON from response
  var imageData = JSON.parse(response).body.replace(/-/g, '\+').replace(/_/g, '\/')
  
  //if frontend: 
    //re-insert characters removed during encoding
    var imageSrc = 'data:image/png;base64, ' + imageData;
    //Set as the "src" for an image tag, a user will then be able to download the image. 
    document.getElementById("image").src = imageSrc  

  //or if backend use:  
    //if storing locally, use buffer to convert base64 to binary
    let binaryImage = Buffer.from(imageData, 'base64')
    //if storing in the cloud, use your cloud provider's api to upload the data in the format required.
}
Python
Python GET Example
# formulate the request
  url = "https://enlarge-images.p.rapidapi.com/"
  querystring = {"url":"https://aisthetic.io/assets/images/bird_before_closeup.jpg","scale":"2"}
  headers = {
    'x-rapidapi-host': "enlarge-images.p.rapidapi.com",
    'x-rapidapi-key': "your-API-key-here"
    }

  # send the request 
  response = requests.request("GET", url, headers=headers, params=querystring)

  # show the response image
  response_data = json.loads(json.loads(response.text))["body"]
  Image.open(BytesIO(base64.urlsafe_b64decode(response_data)))
Python POST Example
# b64 encode jpg file in a web-safe manner
with open("/my_images/filename.jpg", "rb") as image_file:  
  img_str = base64.urlsafe_b64encode(image_file.read()).decode()

  # formulate the request
  payload = "scale=2&b64image={}".format(img_str)
  url = "https://enlarge-images.p.rapidapi.com/"
  headers = {
      'x-rapidapi-host': "enlarge-images.p.rapidapi.com",
      'x-rapidapi-key': "your-API-key-here",
      'content-type': "application/x-www-form-urlencoded"
      }

  # send the request
  response = requests.request("POST", url, data=payload, headers=headers)

  # view the response image
  response_data = json.loads(json.loads(response.text))["body"]
  Image.open(BytesIO(base64.urlsafe_b64decode(response_data)))

Get Started with our API

Learn more on RapidAPI

Connect on RapidAPI