DEV Community

Discussion on: NFT images generator using Python Jupyter Notebook

victorquanlam profile image
Victor Quan Lam Author

Looks like it cannot find the images with the given names. Can you show me the declaration of im2 im3 and im4 as well? Thanks

Thread Thread
Sloan, the sloth mascot
Comment deleted
gkc98 profile image
gkc98

here they are, thank you so much for all your help. i really appreciate it

im1 = Image.open(f'./images/background/{background_files[item["background"]]}.png').convert('RGBA')
im2 = Image.open(f'./images/mouth/{mouth_files[item["mouth"]]}.png').convert('RGBA')
im3 = Image.open(f'./images/spoon/{spoon_files[item["spoon"]]}.png').convert('RGBA')
im4 = Image.open(f'./images/eyes/{eyes_files[item["eyes"]]}.png').convert('RGBA')

#Create each composite
com1 = Image.alpha_composite(im1, im2)
com2 = Image.alpha_composite(com1, im3)
com3 = Image.alpha_composite(com2, im4)
#Convert to RGB
rgb_im = com3.convert('RGB')
file_name = str(item["tokenId"]) + ".png"
rgb_im.save("./images/" + file_name)
Enter fullscreen mode Exit fullscreen mode
Thread Thread
gkc98 profile image
gkc98

hi victor, thanks for all your help. I realised that one of my images was not the same dimension as the other. i think that created the error. i've since resolved it and managed to generate the little images! thanks so much for the speedy replies and all your help!

Thread Thread
victorquanlam profile image
Victor Quan Lam Author

Congrats! You got it. Thanks for reading my blogs. I'm about to upload another post soon. Please consider to check it out. Thanks again