How to issue NFT in the primary market (2): NFT image generation

In the previous article How to Issue NFT Series in the Primary Market (1): Blockchain Contract Development We have completed the development of the blockchain contract code. In this article, we will learn how to generate NFT pictures and Uploaded in IPFS and thus mapped on the token.

 

It is strongly recommended to finish reading the above article first, and then read this article, otherwise there will be a lot of content that cannot be understood continuously.

At present, the mainstream NFT projects have thousands of pictures, each of which is similar, and there are differences in expressions, accessories, colors, etc. These pictures must not be drawn one by one, otherwise the workload is huge, and they are all through script code automatically generated.

We use a set of open source image generation tools https://github.com/HashLips/hashlips_art_engine, which can overlap multiple layers into one image, and each layer can set the weight of the probability of occurrence.

​​​​​​​​​​​​​

As shown above, the layers folder is used to store the layer materials for generating images. The first-level file is the layer attribute, and the second-level file is the style type under this attribute. The file name of each specific layer is name + # + Number, this number is the probability weight of the type appearing under the attribute.

​​​​​​​​​​​​ Set the total number of pictures to be generated in growEditionSizeTo in configs, and set the stacking order of each type of layer in layerOrder. The following figure shows that the "background" layer is generated first, and then superimposed" Two layers", and finally superimpose "three layers". ​​​​​​​​​​​​​​​​

​​​​​​​​​​​​​​​​​​​​​​​​​​​

namePrefix indicates the name of the NFT project, description indicates the description of the NFT project, and baseUri is the address of the NFT project stored in IPFS. We will not set baseUri here because after running the code, two folders will be generated respectively, one It is to store all the generated pictures, one to store the json corresponding to each picture, and the baseUri is stored in the json, so first upload the generated pictures to IPFS to obtain the address, and then replace the baseUri address corresponding to the json in batches.

We execute node index.js to run the code, and we can see a new folder appears on the left, which contains images and json.

We open the images folder, and we can see that 30 preset images have been generated, each of which is composed of three layers superimposed with different styles.

​​​​​​​​​​​​​​

Also open the json folder, and you can see that 30 json files are generated in one-to-one correspondence.

We open one of them arbitrarily, which contains all the information of the NFT, the most important of which are the two attributes of image and attributes, image is the URI link of the NFT image in IPFS, attributes is the attribute of the NFT, that is, the rarity , these rarities will be displayed in Opensea. ​​​​​​​​

But at this time we have not uploaded the picture to IPFS, so the address of the image here is invalid. We open https://app.pinata.cloud/, register and log in, click Upload, and select the images folder just generated upload.

After the upload is complete, copy the CID. ​​​​​​​​​​​​​​​​​​​​​​​​​​

Replace the previously invalid baseUri.

We only need to update the image addresses of all json files without regenerating images and json, so execute node utils/update_info.js. After execution, you will find that all images in json have been replaced with new ones .

So far our NFT materials are all done.

Guess you like

Origin blog.csdn.net/xiaozhupeiqi321/article/details/124857854#comments_25186364