#This code is altered by Langqing Yi to fit the astro degree globe maps 
#the original code was written by Eric Myers. The code was downloaded from
#http://hawksites.newpaltz.edu/myerse/2018/04/02/vernal-equinox-in-wooster-hall-how-it-was-done/

from PIL import Image 
import os

images = []
durations = []
filenames = []

#----------------------------------------------------------------------------

# Get a list of .png files

for file in os.listdir('.'):
    name, ext = os.path.splitext(file)
    if os.path.isfile(file) and ext == ".png":
        filenames.append(file)
print ("Found ", len(filenames), "image files.  ")

filenames.sort()

for file in filenames:
    img =  Image.open(file)
    
    images.append(img)

#-----------------------------------------------------------------------------

print ("Writing the movie...")
first = images.pop(0)

print (len(images), len(durations))
first.save("map_movie.gif",save_all=True,
                              append_images=images,duration=10,loop=0)
