Last active
August 29, 2015 14:17
-
-
Save andycmaj/21ce9e442cd33d53015f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ss to gif | |
import os | |
from PIL import Image | |
working_directory = r'C:\temp' | |
file_names = sorted((fn for fn in os.listdir(working_directory) if fn.endswith('.png'))) | |
file_names = file_names | |
#Open the files | |
print 'Opening the images' | |
images = [Image.open(working_directory + '/' + fn) for fn in file_names] | |
#Resize | |
baseSize = images[0].size | |
minheight = 192 | |
height = baseSize[1] | |
scale = float(height)/float(minheight) | |
print "Scale: " + str(scale) | |
print "Old Size: " + str(baseSize) | |
baseSize = ( int(baseSize[0] /scale) , int(baseSize[1] /scale) ) | |
print 'Resizing' | |
size = baseSize; | |
for im in images: | |
print im.filename | |
# im.thumbnail(size, Image.ANTIALIAS) | |
from images2gif import writeGif | |
from time import time | |
#Set to 24FPS | |
runningtime = 0.0416 | |
print runningtime | |
print 'Saving' | |
filename = "c:\\temp\\Gif" | |
print filename + str(int(time())) + ".gif" | |
writeGif(filename + str(int(time())) + ".gif", images, duration=runningtime, dither=1, nq = 0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment