Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

waifu-generator

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

waifu-generator

Scrap random anime girls from thiswaifudoesnotexist.net

  • 1.1.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5
decreased by-61.54%
Maintainers
1
Weekly downloads
 
Created
Source

waifu-generator

Write random anime girl pictures on file system, using Nodejs, thanks to thiswaifudoesnotexist.net

https://nodei.co/npm/waifu-generator.png?downloads=true&downloadRank=true&stars=true code style: prettier Known Vulnerabilities

Usecase ?

You need to generate random pngs for testing purposes, but js-image-generator is definitely too efficient and boring for the job?

Look no further! TheRealBarenziah(tm) brings you this StyleGAN2-empowered*,industrial grade, uwu-compliant, yet unlicensed module!

Compatibility

node >= 8 (we're using promises)

Use

npm i --save-dev waifu-generator

Case 1 : default (no option object)

In your generate.js file :

const generateWaifu = require("waifu-generator");

generateWaifu()
  .then(res => console.log(res))
  .catch(e => console.error(e));

Back in terminal (for the example):

node ./generate.js
# ...will write a random image file in cwd (current working directory).
# The filename will follow the pattern "$imageId_$uuid.png",
#     where $imageId is the image id for thiswaifudoesnotexist.net,
#     and $uuid some uuidv4 generated on the fly

data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=

# Since we logged the return value with .then(res => console.log(res))
# a base64 string representation of our image is printed in stdout.
# It is facultative, but may come in handy. You can check the string by copypasting it 
# into your favorite browser, or whatever. Just know it's there, in the resolve value !

Case 2 : providing an option object

In your generate.js file :

const generateWaifu = require("waifu-generator");

const options = {
  filename: "sugoi_kawaii",
  path: "./__TESTS__/images"
};

generateWaifu(options);

Back in terminal:

node ./generate.js
# ...will write a random image file in "./__TESTS__/images",
#     with "sugoi_kawaii.png" as its filename.
#
# No output since we didn't explicitely '.then(res => console.log(res));'

NB: options object is facultative; options.filename and options.path default to null; options.skipFs default to false.

You can pass a single option: providing a filename but no path, the path will default to root.
Providing a valid path but no filename, filename will be generated using standard pattern.

Case 2.5: skip the fs call

Sometimes, you don't want your tests to do I/O operations (typically when you're after performance). In that case you can skip the filesystem call entierely, leaving you to work with pure base64 strings, ready to be allocated.

Barebone example:

const generateWaifu = require("waifu-generator");

const yourCustomFunc = async () => {
  this.base64waifu = "";

  await generateWaifu({ skipFs: true })
    .then(res => this.base64waifu = res)
    .catch(e => e);

  const output = this.base64waifu.toString().toString().toString(); 
  // Example of arbitrary filth you're free to inflict to your base64 waifu here

  console.log(output); // printing our stuff
  return output;
};

yourCustomFunc();

NB: Activating skipFs will (indeed) make the other options irrelevant !

Clean your mess

This unbloated module doesn't support file deletion. To do that, it's your responsibility, as a developer, to chose the correct approach between using the awesome fs API, using higher level libs, or going for OS level operation.

..Of course you're also free to skip the hassle by using the skipFs parameter !

Take advantage of this module being unlicensed: please fork away and write the best solution for your specific need :)

BTW

Please don't read this seriously. This JavaScript does little more than exploiting the awesome work that was done on thiswaifudoesnotexist, so please pay them a visit and click their footer links :)

Keywords

FAQs

Package last updated on 20 Jan 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc