How to create an animated NFT Collection in GIF?

@AnimAllsNFT

Why Gif?

Initial thought

Aha moment #1

Aha moment #2

Workflow for Generative Gif with Python & After Effects

Why am I excited?

Python ❤

import random        # Shuffle and make random choices
import os # Fetch assets from disk to create databases
import pandas as pd # Play with datas
import csv # Create CSV for After Effects
import openpyxl # Create a XLS file (optional)
import json # Create the NFT metadata
from datetime import datetime # Date in the metadata (optional)

Rarity Cards vs Rarity Traits

Type of Cards

['Rare', 'Common', 'Common', 'Common', 'Common', 'Rare', 'Common', 'Ultra', 'Common','Common']

Type of Assets

  • If Common Card Then: 3/4 chance to choose a common asset and 1/4 chance to select a rare asset.
  • If Rare Card Then: 2/4 chance to choose a common asset and 1/4 chance to select a rare asset, 1/4 chance to select an ultra-rare asset.
  • If Ultra Rare Card Then: 1/2 chance to choose a rare asset and 1/2 chance to select an ultra-rare asset.
def chose_cards(card):
#for card in collection_base:
global x
global cx
if card == "Common":
cx = random.choice(["common", "common", "common", "rare"])
if cx == "common":
x = random.choice(asset_common)
else:
x = random.choice(asset_rare)
elif card == "Rare":
cx = random.choice(["common", "common", "rare", "ultra"])
if cx == "common":
x = random.choice(asset_common)
elif cx == "rare":
x = random.choice(asset_ultra)
else:
x = random.choice(asset_rare)
else:
cx = random.choice(["rare", "ultra"])
if cx == "rare":
x = random.choice(asset_ultra)
else:
x = random.choice(asset_rare)

After Effect & Final GIF

Expressions

  • In the CSV, I can add a column “angle”. For each NFT, the script will generate a random number between -45 and 180.
  • CompsFromSpreadsheet can fetch the “angle” column and update a dedicated Text Layer in the composition.
  • My light source in the composition called Sun links to this Text Layer. If the Text is 90, the Sun will be at 90° in the composition.
Dynamic light linked with a Text Layer
Left: Wiggle off — Right: Wiggle on
  • Starting with ^ will replace the text with another text (like the Sun Angle)
  • Starting with > will replace the layer with a file (image or video)
Layers in After Effects
  • If Top layer is “Aquarium” Then: use AnimAlls Aquarium Composition
Aquarium Composition

Key Take Away

  • Use Python to generate a CSV with all the traits
  • Use CompsFromSpreadsheet to generate compositions in After Effects from your spreadsheet
  • Use GifGun to batch render in Gif!
  • Additionally you can generate advanced Metadata (not covered in this article) still with Python

What’s Next?

Where to find me?

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store