Giter Club home page Giter Club logo

nft-art-generator's Introduction

NFT ART GENERATOR

This tool generates generative NFT art, based of all available traits.
It was made with the intention to make the generative art field more accessible to anyone.
With this tool you don't need to be a programmer to create generative art.

Features:

  • Generate Images of an infinite amount of traits
  • Weight traits for different rarities
  • Remove duplicated combinations
  • Generate metadata for direct use on OpenSea

Installation npm install -g nft-art-generator

Usage nft-generate [--save-config] [--load-config filename]

Options

  • save-config: saves all entered values to a config.json file, which gets used in future runs
  • load-config: loads values from a specific json config file

Documentation

Before you start, make sure your file structure looks something like this:

YOUR_PROJECT/  
├─ images/  
│  ├─ trait1_name/  
│  │  ├─ file1.png  
│  │  ├─ file2.png  
│  │  ├─ file3.png  
│  │  ├─ ...  
│  ├─ trait2_name/  
│  │  ├─ file4.png  
│  │  ├─ file5.png  
│  │  ├─ ...  
│  ├─ trait3_name/  
│  │  ├─ file6.png  
│  │  ├─ ...  
│  ├─ ...  

This is really important, since the scripts imports the traits based on the folder structure.

The first input allows you to select where your images are located.

  • Current directory: Will look for an images folder inside the directory the script has been run in.
  • Somewhere else on my computer: Will let you enter an absolute filepath to your images folder.

In the next step you are able to select where your files should be outputted to.

  • Current directory: Will create a folder called output inside the current location and output all images there.
  • Somewhere else on my computer: Will let you enter an absolute filepath to your preferred output folder.

The next input lets you decide if you want to allow duplicates or not.

The next input lets you decide if you want to generate metadata or not.

If you want metadata to be generated the script will ask you for a name, a description and an image url.

  • Name: Enter the name you want to be saved in the metadata.
    Example: If you enter Crypto Punk, the script would output Crypto Punk#ID to the metadata

  • Description: The description that should be saved in the metadata.

  • Image URL: Enter the base url of your images.
    Example: If you enter https://google.com/api/cryptopunks/, the script will output https://google.com/api/cryptopunks/ID

After that the script will output a list of all traits it could find, and asks you to select your background trait.
When you did this the script, will continue to ask you which trait should be the next layer.
Imagine it like the different layers in Photoshop and you are selecting the order of those.

The next input lets you decide if you want to use filenames as traits names, or to define custom names for each trait.

If you selected the last option, you will enter a name for all your files.
These names will be used in the Metadata as well as in the script to make weighting the traits easier.
Example: If you have a file name bg1.png the script will ask you to name it. If its just a white background you could name it "White".

The next step is the weighting of your traits.
You can enter the amount you want to have of the listed trait.
Please make sure that all traits end up with the same amount of images, otherwise there will be issues.
Example: You want 50 total images. You enter 50 White background, 25 red balls and 25 blue balls.
That would result in 50 total spheres and 50 total background.

Please note that if you selected the option to remove duplicates there might be less images then expected.

That's it check your output folder for your images and metadata file.

If you encounter any issues feel free to sent me a DM on my Twitter @notluksus3D

Known issues Some special characters may resolve in some "File couldnt be loaded" errors. Try to remove any special characters from your file paths to resolve.

nft-art-generator's People

Contributors

0xalexs avatar bbjay avatar cybermonk42 avatar klabianco avatar mrmeier-1 avatar naei avatar notluksus avatar turupawn avatar yrik avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nft-art-generator's Issues

crashes when attribute values are not identical

crashes when not all "how many __ should there be?" values are not all the same.

for example;

how many _ should there be? 9
how many _ should there be? 5

will result in crashing after generating a few images.

also unrelated, but I don't see the config.js file even with the [--save-config] flag

/usr/local/lib/node_modules/nft-art-generator/node_modules/merge-images/dist/index.umd.js:39
			img.onerror = function () { return reject(new Error('Couldn\'t load image')); };
			                                          ^

Error: Couldn't load image
    at img.onerror (/usr/local/lib/node_modules/nft-art-generator/node_modules/merge-images/dist/index.umd.js:39:46)
    at setSource (/usr/local/lib/node_modules/nft-art-generator/node_modules/canvas/lib/image.js:91:13)
    at Image.set (/usr/local/lib/node_modules/nft-art-generator/node_modules/canvas/lib/image.js:62:9)
    at /usr/local/lib/node_modules/nft-art-generator/node_modules/merge-images/dist/index.umd.js:41:12
    at new Promise (<anonymous>)
    at /usr/local/lib/node_modules/nft-art-generator/node_modules/merge-images/dist/index.umd.js:30:55
    at Array.map (<anonymous>)
    at /usr/local/lib/node_modules/nft-art-generator/node_modules/merge-images/dist/index.umd.js:30:24
    at new Promise (<anonymous>)
    at mergeImages (/usr/local/lib/node_modules/nft-art-generator/node_modules/merge-images/dist/index.umd.js:22:10)

.PNG Placement

Hi Everyone, so I have run the program and generates my images. However they are all stacked in a top right corner. Does anyone know what section of code I need to change to get them to be placed where I want them?

It throws an error that it could not load the images

It asks me about each folder and file correctly and everything looks normal until it starts generating and then this error occurs
Error: Couldn't load image at img.onerror (C:\Users\user\OneDrive\Documents\nft generator\nft-art-generator-main\node_modules\merge-images\dist\index.umd.js:39:46) at setSource (C:\Users\user\OneDrive\Documents\nft generator\nft-art-generator-main\node_modules\canvas\lib\image.js:91:13) at Image.set (C:\Users\user\OneDrive\Documents\nft generator\nft-art-generator-main\node_modules\canvas\lib\image.js:62:9) at C:\Users\user\OneDrive\Documents\nft generator\nft-art-generator-main\node_modules\merge-images\dist\index.umd.js:41:12 at new Promise (<anonymous>) at C:\Users\user\OneDrive\Documents\nft generator\nft-art-generator-main\node_modules\merge-images\dist\index.umd.js:30:55 at Array.map (<anonymous>) at C:\Users\user\OneDrive\Documents\nft generator\nft-art-generator-main\node_modules\merge-images\dist\index.umd.js:30:24 at new Promise (<anonymous>) at mergeImages (C:\Users\user\OneDrive\Documents\nft generator\nft-art-generator-main\node_modules\merge-images\dist\index.umd.js:22:10)

Outdated versions

I have errors that accure becuase the script is based of outdated versions. Is there a way to bypass this? How can i fix it.

Regards
TheChased1

Config option to use the filenames as key in the metadata

Currently the metadata can only mapped my the basename. It would be nice to have the option to use the full filename.

{
    "0.png": {
        "name": "dsfsdf",
        "description": "The best shapes around",
        "image": "No URL/0",
        "attributes": [{
                "trait_type": "Background",
                "value": "Purple Background"
            }, {
                "trait_type": "Body",
                "value": "Main Body"
            }, {
                "trait_type": "Hat",
                "value": "Triangle Hat"
            }, {
                "trait_type": "Weapon",
                "value": "none"
            }
        ]
    }
}

Is this expected behavior ?

I have 5 images in each trait. Turned off duplicate deletion and Metadata. I'm getting only 24 images in output.
Not sure why it is asking the same question equal to number of each trait.

image

Traits grouped by value (e.g. colour)

Hi there,

Just had a play with this piece of software and it's really awesome.

I was wondering if it's possible to group certain traits based on colour?

For example, if I had a character that could have a grey, blue or white body colour and an "Eyes" trait that could be grey, blue or white, is it possible to ensure that only blue eyes end up on blue bodies and white on white etc?

e.g.

images ---\
  Eyes --\
    TiredEyes --\
      BlueTiredEyes.png
      WhiteTiredEyes.png
      GreyTiredEyes.png
  BodyColour --\
    White.png
    Blue.png
    Grey.png

Let me know if this doesn't make sense and I will try explain in a better way 😂

Where can i change the saved config?

Sorry i'm new to this scripting thing, and i'm glad to got it run. But where can i change the saved config.json? Just tried a few runs, but now i need to change the traids etc...

Issues About the generation (Solved)

When i try to generate total i get every time 624

Background: 23
Hat: 19
Skin: 5
Rarity: 5
Enviorement: 25

This is strange i tryed with google colab with same settings and i get total of 624 there too

Error Generating Metadata

The code works perfectly for generating the images I need, however, when it comes to generating the metadata it stops working. After all of the images are generated I receive long string of errors starting with Error: Couldn't load image
(node:196704) UnhandledPromiseRejectionWarning: Error: Couldn't load image at img.onerror (C:\Users\user\AppData\Roaming\npm\node_modules\nft-art-generator\node_modules\merge-images\dist\index.umd.js:39:46) at setSource (C:\Users\user\AppData\Roaming\npm\node_modules\nft-art-generator\node_modules\canvas\lib\image.js:91:13) at Image.set (C:\Users\user\AppData\Roaming\npm\node_modules\nft-art-generator\node_modules\canvas\lib\image.js:62:9) at C:\Users\user\AppData\Roaming\npm\node_modules\nft-art-generator\node_modules\merge-images\dist\index.umd.js:41:12 at C:\Users\user\AppData\Roaming\npm\node_modules\nft-art-generator\node_modules\merge-images\dist\index.umd.js:30:55 at new Promise (<anonymous>) (Use node --trace-warnings ...to show where the warning was created) (node:196704) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag--unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2) (node:196704) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
If anyone could help me with this that'd be greatly appreciated.

Multiple generation of a project

Hi, I have a question, for example: I now generate 500 NFTs. A month later, I will add more picture types to the original pictures and continue to generate 500 NFTs. They are a project, but the generation time is different. I don't want them to have duplicates, and the numbers are generated in the previous order. What should I do? Thank you

Option to dump & read configuration to/from file

Great project! I had something similar in mind and was happy to find that this already exists.

As I was experimenting with a growing number of different traits, it became quite cumbersome to answer all the questions for settings, names & weights on each run.
While this interface is good for starters, i think an option to dump these information into a config-file, along with an option to skip the questions and instead read them from a config-file would be very helpful.

Would this be a feature you would want to merge? i could have a look into this...

Suggestions to improve usability of generator

Hey, love the project. I've got a few suggestions, let me know what you think.

  1. Create a sample config.json which contains default values, all set to null. This allows a user of the package to set config values before executing the program. After running the generator, any null or unset config values are populated when the --save-dev flag is set.

  2. Update the setNames method to use the filename as name for each file, instead of requiring the user to input a name for each file. For example:

async function setNames(trait) {
  const files = fs.readdirSync(basePath + '/' + trait);
  files.forEach((file, i) => {
    names[file] = file.split('.')[0];
  });
}
  1. It is fairly tedious to have to pre-calculate the number of images containing each trait, and entering an invalid number can result in the program crashing. To remedy, the weighting algorithm can adopt a percentage weight system for determining the weightings of each trait.

For example:
What percentages of ' + names[file] + ' ' + trait + ' should there be?'. To which the user would input 5 as in 5%.

Followed by What is the total number of images that should be generated?. To which the user would input 1000 (sum).

Using these values, you would be able to determine the number of images containing each trait as a percentage of the sum provided by the user.

Cheers!

Suggestion to leave traits out of remaining amount of images

Hey, first of all thanks for the great project, I've been looking for something like this for a while!

I have a suggestion for an improvement:
It would be awesome if the sum of each used trait should not match the exact amount of images you try to make, but instead the trait should not be showed on the remaining amount / percentage of images.

Example
If I want to make 100 images and have 2 different hairstyles, I would like 50 to have hairstyle A, 25 of them should have hairstyle B and the remaining 25 should not have hair.

The only solution that I found for now is putting an empty png in the folder.

Thanks!

Help

Hello.
how to upload 10.000 nft on opensea, without adding them manually?

Problem with Canvas dependency at npm level

npm install failed on my machine. I did a little search and found it to be an issue with canvas dependency from node modules. what do you think I can do to get it working?

Getting Unexpected Token issue on run

Just installed the project and ran nft-generate but seeing the error below

/usr/local/lib/node_modules/nft-art-generator/node_modules/ora/index.js:401
		} catch {
		        ^

SyntaxError: Unexpected token {
    at createScript (vm.js:80:10)
    at Object.runInThisContext (vm.js:139:10)
    at Module._compile (module.js:616:28)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/usr/local/lib/node_modules/nft-art-generator/bin/index.js:9:13)

I'm running the script from the /nftg folder and the structure of images matches what is expected
image

Any suggestions on how to fix?

Metadata

Hi,
So when uploading your images to IPFS the hash of the file changes.
When you also generate images, the images get created in a completely different order so its impossible to upload this to IPFS.

Am I missing something here?
Is there anything I can do?

NFTs generated are all off-centered/skewed

sorry - this is a pretty 'newbie' question; i was able to get a few NFTs generated using this, but all of the traits are off-centered.. is there any way to tweak this (either before the script runs or after the image is produced?)

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.