Created
February 23, 2014 13:22
-
-
Save notsobad/9171424 to your computer and use it in GitHub Desktop.
convert 360° images to gif.
This file contains 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
from PIL import Image | |
import sys | |
import os | |
img_file = sys.argv[1] | |
im = Image.open(img_file) | |
w, h = im.size | |
print w, h | |
FRAME_WIDTH = 480 | |
im_big = Image.new("RGB", (w + FRAME_WIDTH, h)) | |
im_big.paste(im, (0, 0)) | |
im_extra = im.crop((0, 0, FRAME_WIDTH, h)) | |
im_big.paste(im_extra, (w, 0)) | |
w_slice = 100 | |
n_slice = w / w_slice | |
images = [] | |
print im_big.size | |
for i in range(n_slice): | |
print i * w_slice, im_big.size | |
im_tmp = im_big.crop((i * w_slice, 0, i * w_slice + FRAME_WIDTH, h)) | |
im_tmp.save('a-%02d.jpg' % i) | |
os.system('convert a-*.jpg a.gif') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment