Skip to main content

Usage with NPM

View this page on the UpscalerJS website

Demonstrates a basic implementation of UpscalerJS for the browser.

Open example in Codesandbox.

Getting Started

In this example we're using Vite, a development server, and we've installed UpscalerJS via npm.

We can import UpscalerJS with the following:

import Upscaler from 'upscaler'

We can then instantiate an instance of UpscalerJS with:

const upscaler = new Upscaler()

Upscaling an Image

Input images can come in a variety of formats, including URL strings, <img /> elements, and more.

Our input will be a string representing a URL. Provide the string to the upscale method with:

import pathToImage from '/path/to/image.png'


This will upscale the image and return a promise that resolves to the upscaled image src represented as a base64 string:

upscaler.upscale(pathToImage).then(upscaledImageSrc => {
// Create a new image, set its src to the upscaled src,
// and place it on the page
const img = document.createElement("img")
img.src = upscaledImgSrc

There are a number of options we can pass to the upscale method, detailed here.

Next, read about the concept of models and how they work with UpscalerJS.