{"id":16555023,"url":"https://github.com/wykerd/waifu2x-node","last_synced_at":"2025-10-28T19:31:21.801Z","repository":{"id":44716160,"uuid":"264535833","full_name":"Wykerd/waifu2x-node","owner":"Wykerd","description":"Image Super-Resolution in NodeJS using libw2xc from waifu2x-converter-cpp.","archived":false,"fork":false,"pushed_at":"2022-01-28T23:49:11.000Z","size":157,"stargazers_count":5,"open_issues_count":6,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-03T08:38:02.327Z","etag":null,"topics":["cpp","image","image-processing","node-module","node-native-addons","nodejs","opencv","upscale","upscaler","waifu2x","waifu2x-converter-cpp"],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Wykerd.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-05-16T22:04:11.000Z","updated_at":"2024-03-16T14:42:08.000Z","dependencies_parsed_at":"2022-09-17T08:35:00.344Z","dependency_job_id":null,"html_url":"https://github.com/Wykerd/waifu2x-node","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Wykerd%2Fwaifu2x-node","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Wykerd%2Fwaifu2x-node/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Wykerd%2Fwaifu2x-node/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Wykerd%2Fwaifu2x-node/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Wykerd","download_url":"https://codeload.github.com/Wykerd/waifu2x-node/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219858914,"owners_count":16556039,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cpp","image","image-processing","node-module","node-native-addons","nodejs","opencv","upscale","upscaler","waifu2x","waifu2x-converter-cpp"],"created_at":"2024-10-11T19:52:52.912Z","updated_at":"2025-10-28T19:31:21.384Z","avatar_url":"https://github.com/Wykerd.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Waifu2x Converter for NodeJS\n\nNodeJS bindings / wrapper for using [libw2xc from waifu2x-converter-cpp](https://github.com/DeadSix27/waifu2x-converter-cpp)\n\nUsed to upscale photos or Anime-style art using convolutional neural networks.\n\n# Usage\n\nThis module currently only supports GNU/Linux and Windows.\n\n## Prerequisites\n\nThis project requires node-gyp to build, make sure it is installed using ```npm install -g node-gyp```\n\n### Windows x64\n\nMake sure you have node-gyp setup correctly. You'll need Visual Studio 2015 or later installed to compile the source. See https://www.npmjs.com/package/node-gyp#on-windows for more info.\n\nDependencies are installed automatically but require 7z to extract the binaries, make sure it is installed at the default install path `C:\\Program Files\\7-Zip\\7z.exe`\n\nThe install scripts should install all dependencies automatically so no additional setup is required.\n\n### Linux\n\nInstall the dependencies listed below.\n\nMake sure the you install it in one of the linker's search directories. It should be by default if you use your package manager or follow the build instructions below.\n\n#### OpenCV\n\nInstall OpenCV using your distrobution's package manager.\n\nOn arch you'll use ```pacman -S opencv```\n\n#### waifu2x-converter-cpp\n\n- AUR (ArchLinux based distros)\n    - [waifu2x-converter-cpp-git](https://aur.archlinux.org/packages/waifu2x-converter-cpp-git/)\n\n- Fedora\n    - [waifu2x-converter-cpp](https://apps.fedoraproject.org/packages/waifu2x-converter-cpp)\n\n- Other Linux\n    - Build from source. See instructions here https://github.com/DeadSix27/waifu2x-converter-cpp/blob/master/BUILDING.md\n\n## Installation\n\nInstall using npm\n```\nnpm install waifu2x-node\n```\n\n## Synchronous Examples\n\n### Upscaling a file\n\n```typescript\nimport { W2XCJS, DEFAULT_MODELS_DIR } from 'waifu2x-node';\n\nconst converter = new W2XCJS();\n\nconst err = converter.loadModels(DEFAULT_MODELS_DIR);\n\nif (!err) {\n    const conv_err = converter.convertFile(\"in.png\", \"out.webp\");\n    if (!err) {\n        console.log('File converted successfully');\n    }\n}\n```\n\n### Upscale a buffer\n\n```typescript\nimport { W2XCJS, DEFAULT_MODELS_DIR } from 'waifu2x-node';\nimport fs from 'fs';\n\nconst converter = new W2XCJS();\n\nconst err = converter.loadModels(DEFAULT_MODELS_DIR);\n\nif (!err) {\n    const input_buffer = fs.readFileSync(\"in.png\");\n    const output_buffer = converter.convertBuffer(input_buffer, '.JPG'); // second parameter is the file extension to encode to.\n    fs.writeFileSync(\"out.jpg\", output_buffer);\n}\n```\n\n## Asynchronous examples\n\nAsynchronous functions only work on GPU processor types due to instabilities on the CPU\n\n### Upscaling using callbacks\n\n```typescript\nimport { W2XCJS, DEFAULT_MODELS_DIR } from 'waifu2x-node';\nimport fs from 'fs';\n\nconst converter = new W2XCJS();\n\nconst err = converter.loadModels(DEFAULT_MODELS_DIR); // model loading is synchronous\n\nif (!err) {\n    fs.readFile(\"in.png\", (err, input_buffer) =\u003e {\n        if (err) throw err;\n        converter.convertBufferAsync(input_buffer, '.WEBP', { /* AsyncOptions */ }, dst_buffer =\u003e {\n            fs.writeFile(\"out.webp\", dst_buffer, err =\u003e {\n                if (err) throw err;\n            })\n        })\n    });\n}\n```\n\n### Upscaling using promises\n\nThe library provides a wrapper class for using promises\n\n```typescript\nimport { W2XCJS, DEFAULT_MODELS_DIR, W2XCJSPromises } from 'waifu2x-node';\nimport fs from 'fs';\n\nconst promises = new W2XCJSPromises(new W2XCJS());\n\nconst err = promises.converter.loadModels(DEFAULT_MODELS_DIR); // model loading is synchronous\n\nif (!err) {\n    (async () =\u003e {\n        const input_buffer = await fs.promises.readFile(\"in.png\");\n        const dst_buffer = await promises.convertBuffer(input_buffer, '.WEBP', { /* AsyncOptions */ });\n        await fs.promises.writeFile(\"out.webp\", dst_buffer);\n    })();\n}\n```\n\n### Asynchronous convert options (AsyncOptions)\n\nAbstract of the library source for reference, you could also generate the documentation for more detailed overview.\n\n```typescript\ninterface AsyncOptions {\n    // encoding options for destination buffer.\n    imwrite_params: ImwriteParams;\n    // denoising options (number value from -1 to 3 where -1 is no denoising)\n    denoise_level: DenoiseLevel;\n    // Scale factor.\n    scale: number;\n}\n```\n\n```typescript\ninterface ImwriteParams {\n    // quality factor for webp and jpeg from 0 to 101 where 101 is lossless.\n    webp_quality?: number;\n    jpeg_quality?: number;\n    // compression factor for png from 0 to 9 where 9 is smallest size and longest time.\n    png_compression?: number;\n}\n```\n\n# Documentation\n\nDocumentation is generated using TypeDoc, run `npm run docs:build` to build the documentation and `npm run docs:serve` to serve a local copy of the documentation.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwykerd%2Fwaifu2x-node","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwykerd%2Fwaifu2x-node","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwykerd%2Fwaifu2x-node/lists"}