Skip to content

Randomised NFT art generator built using Python's Pillow module, inspired by hashlips_art_engine.

License

Notifications You must be signed in to change notification settings

adarsh-mamgain/NFT-art-generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NFT ART GENERATOR

This is a python art generative code, which uses 'Pillow' python module to merge various layers into one.

INSTALLATION 🛠

  • Clone this repository into your working directory.
git clone https://github.com/adarsh-mamgain/NFT-art-generator.git

cd NFT-art-generator
  • Install and create a virtualenv to install python modules
pip3 install virtualenv

virtualenv venv
  • Start using the virtual environment.

    1. On Windows
      venv\scripts\activate
    2. On Linux and MacOS
      source venv/bin/activate
  • Run the following command to install Pillow and other dependencies

pip3 install -r requirements.txt


WORKING 🚀

INPUT

Arrange all the .png files inside respective folder types and rename the file. If filename in background directory is Blue.png then the metadata stores the metadata in the below way.

...
"attributes": [
    {
        "trait_type": "background",
        "value": "Blue"
    },
    ...
]
...

CODE/CONFIG.PY

All the required configurations are stored and accessed from code/config.py

The rarity_percent for original, rare and super_rare out of your total edition_size (eg: 10000).

NOTE: You can modify the variable values in code/config.py file to get the required ouput.


CODE/LAYERS.PY

This file serves all elements and it's details in each layers inside the input folder.

NOTE: Please change the relative path name inside the called get_element() function for each element in the races -> layers -> elements -> inside the list key.

...
...
"background": {
    "layer_id": "A",
    "elements": {
        "original": {
        "rarity_id": 0,
        "list": [
            {
                "element_id": 0,
                "name": "Bazaar",
                "location": "./input/background/original/Bazaar.png"
            },
            {
                "element_id": 1,
                "name": "Yellow",
                "location": "./input/background/original/Yellow.png"
            }
        ]
        }
    }
},
"armour": {
    "layer_id": "B",
    "elements": {
        "original": {
        "rarity_id": 0,
        "list": [
            {
                "element_id": 0,
                "name": "Blue",
                "location": "./input/armour/original/Blue.png"
            },
            {
                "element_id": 1,
                "name": "Violet",
                "location": "./input/armour/original/Violet.png"
            }
        ]
    }
}
...
...

CODE/REGENERATE_METADATA.PY

This code regenerates the metadata inside the build/metadata/ for all the #.json files and metadata.json.

The new attributes DESCRIPTION, BASE_IMAGE_URI must be changed inside the code/config.py


CODE/MAIN.PY

CODE/MAIN.PY is the main file to generate art. The code performs the following functions clear_data, get_rarity, create_dna, is_dna_unique, save_metadata and create_image.



RUNNING THE PROGRAM 🏃‍♀️🏃🏃‍♂️

python3 code/main.py


ABOUT 🏷️

Founder: Adarsh Mamgain

Contact: LinkedIn

About

Randomised NFT art generator built using Python's Pillow module, inspired by hashlips_art_engine.

Resources

License

Stars

Watchers

Forks