1.0.0 • Published 3 years ago

@ibaraki-douji/anime4k v1.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
3 years ago

Anime4K

A simple image upscaler using anime-4k-cpp

Getting started

npm i @ibaraki-douji/anime4k --save

Usage

Import the lib

const anime4k = require('@ibaraki-douji/anime4k')

Start Upscale

const anime4k = require('@ibaraki-douji/anime4k')

const input = "./path/to/image";
//const input = readFileSync('./path/to/image'); // <- Buffer
const output = "./path/to/upscaled/image";
//const output = "" // <- IF BufferOutput Option

const options = {
    /**
     * Threads
     * -t
     */
    threads: 16,
    /**
     * Upscale Multiplier
     * -z
     */
    scale: 2,
    /**
     * Choose GPU
     * -q
     */
    gpu: true,
    
    outputAsBuffer: true
}

anime4k.upscale(input, output, options);

Wait the end

const anime4k = require('@ibaraki-douji/anime4k')
const upscale = anime4k.upscale(input, output, options);

upscale.finishedPromise().then(() => {
    console.log("Finished")
})

Get Buffer at End

const anime4k = require('@ibaraki-douji/anime4k')
const upscale = anime4k.upscale(input, output, options);

upscale.finishedPromise().then(() => {
    writeFileSync("./buffer.mp4", upscale.endBuffer);
})

List yours GPUs

const anime4k = require('@ibaraki-douji/anime4k')
anime4k.listGPUs().then(console.log)

Exemple

const anime4k = require('@ibaraki-douji/anime4k')
// npm i axios
const axios = require('axios').default

// MAKE A ASYNC FUNCTION AT START
(async () => {
    const upscale = anime4k.upscale((await axios.get('https://cdn.discordapp.com/attachments/770019121349001227/874597329594892338/in.mp4')).data, "./output.mp4", {
        upscale: 2
    });
    await upscale.finishedPromise()
    console.log("Finished");
})()

More Help and Support

Discord : https://discord.gg/mD9c4zP4Er

Ask me what you want in the Discord server