This repo takes advantage of rust's multithreading and low level capability to provide a blazingly fast NFT Image and Metadata Generator
Big thanks to hashlips for making his repo open source. I used his demo images in this repo, so all credits to him.
Check out his repo here
Note: this will be affected by your computer's specs since we multithread based on the number of cores on the computer.
To install rust, visit The Official Rust lang Install Tutorial
To build, run rust cargo build --release
to execute, run rust cargo run --release
- Go To src/main.rs
Inspect the main file.
fn main() {
utils::before_runtime::before_runtime();
let start_time = std::time::Instant::now();
let layers = vec![
Layer::new(String::from("Backgrounds"),String::from("layers/Background")),
Layer::new(String::from("Bottom Lid"),String::from("layers/Bottom lid")),
Layer::new(String::from("Eye Color"),String::from("layers/Eye color")),
Layer::new(String::from("Eyeball"),String::from("layers/Eyeball")),
Layer::new(String::from("Goo"),String::from("layers/Goo")),
Layer::new(String::from("Iris"),String::from("layers/Iris")),
Layer::new(String::from("Shine"),String::from("layers/Shine")),
Layer::new(String::from("Top Lid"),String::from("layers/Top lid")),
];
let my_gen = Generator::new(START_TOKEN_ID,END_TOKEN_ID,layers,DESCRIPTION);
my_gen.run_generation();
let end_time = std::time::Instant::now();
let duration = end_time.duration_since(start_time);
println!("Time taken to generate {} images: {:?}",END_TOKEN_ID,duration);
}
Each layer item takes in the name of the layer and the path to where its images lie.
You define the layer in which you want it to be pasted on the image.
i.e. Backgrounds first, body second, etc. etc...
You then create a Generator
and define a start token , end token, the layers, and a description.
The generation will start with start token and end with end token.
Then, the execution of generation runs through the function rust my_gen.run_generation()
Rarity works the same as in the hashlips repo.
Each image should have "#x" after the filename. The x is the weight of the image in the overall generation.
For example, let's say we have 3 images in a certain folder.
- blue_hat#5.png
- red_hat#4.png
- special_hat#1.png
The probability of blue_hat would be (5+4+1) /5 = 50% Chance.
The probability of red_hat would be (5+4+1) / 4 = 40% Chance
the probablity of special_hat would be (5+4+1)/1 = 10% Chance.
Side Note: No Duplicates Can Be Generated From This Script