Skip to content

Instantly share code, notes, and snippets.

@alaiacano
Created January 13, 2013 16:18
Show Gist options
  • Save alaiacano/4524896 to your computer and use it in GitHub Desktop.
Save alaiacano/4524896 to your computer and use it in GitHub Desktop.
#!/usr/bin/python
"""
python resize_files.py folder_of_input_images output_file.gif
"""
import os, sys, re
RESIZE_PERCENT = 12
QUALITY = 40
folder = sys.argv[1]
output = sys.argv[2]
for filename in os.listdir(folder):
if filename=='.DS_Store' or 'resized' in filename:
continue
print "resizing %s" % file
os.system('convert %s -resize %s%% -quality %s %s/resized_%s' % (os.path.join(folder, filename), RESIZE_PERCENT, QUALITY, folder, filename))
print "animating"
command = 'convert -delay 12 -layers optimizeplus -depth 8 -colors 64 %s/resized_*.JPG %s' % (folder, output)
os.system(command)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment