DEV Community

Discussion on: NFT images generator using Python Jupyter Notebook

Collapse
 
thestud1 profile image
thestud1

Hey there Victor

First of let me start by saying thank you for your code, I have used it and I extended it to randomize how many features will be taken for each Picture.
For example some will only have a background or some will have a background and a circle.

The code works but im struggling with the last step of creating a picture. The problem is in your code all 3 attributes are always included in the dictionary so you know that the program needs to open all three layers and you will always have to stack them up the same way. Now in my code there are instances where only 2 attributes are used and therefore only those two layers need to be opened and and merged.

I have solved it with different if statements but I was wondering if there is a smoother way to do so.

Thank you for your answer in advance

Collapse
 
victorquanlam profile image
Victor Quan Lam

You can use the filename reader to solve this issue. You can use it to read and the folder names and figure out the layers you want to draw onto your image.

for file in os.listdir('.'):
    #draw layer using fileName eg: circle, rectangles, etc....
Enter fullscreen mode Exit fullscreen mode

Anyway, this is only a basic program which introduces people to images generator and Python. And yet you will have to manually add the layer names and bit of code for combination. For something a bit more advanced where all the layers get included themselves please check another blog of mine out.
dev.to/victorquanlam/generate-879-...