npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

waifu-generator

v3.0.0

Published

Get random anime girls as files or base64 strings

Downloads

61

Readme

waifu-generator

https://nodei.co/npm/waifu-generator.png?downloads=true&downloadRank=true&stars=true 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

tl;dr

  • options object is facultative
  • options.filename default to null
  • options.path default to null
  • options.skipFs default to false; pass true to skip the fs.createWriteStream() call
  • options.withoutPrefix default to false; pass true to remove 'data:image/png;base64,' prefix from returned string
  • options.mosaic default to null; enable to create a mosaic of waifus. Infos here
  • options.macrophilia default to null; enable to quickly create big files. Infos here

The Long Read

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"

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));'

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:

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

const yourCustomFunc = async () => {
  const base64waifu = await generateWaifu({ skipFs: true });

  const output = 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 path/filename options irrelevant !

Mosaic

Available from 2.0.0 onward. Incompatible with macrophilia. Opt-in by defining option.mosaic:

const waifuGenerator = require("./index")

waifuGenerator({
  filename: "mosaic", // indeed compatible with other waifu-generator options
  mosaic: {
    number: 3, // mandatory; must be integer in 1-99 range
    options: { /* facultative merge-img option object
      one usecase is to generate near-infinite different (from a shasum perspective) files */
      direction: true,
      color: 0x000000
    }
  }
})

Macrophilia

Available from 3.0.0 onward. Incompatible with mosaic. Opt-in by defining option.macrophilia:

const waifuGenerator = require("./index")

waifuGenerator({
  filename: "33mb_girl", // indeed compatible with other waifu-generator options
    macrophilia: {
    height: 5742, // The height of the waifu (which is always a square)
    thiqq: false // Add some meat to the waifu (increases png quality & reduces compression)
    }
  }
})

Clean your mess

This 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 and thisanimedoesnotexist, so please pay them a visit :)

Changelog

CHANGELOG