Skip to content

Instantly share code, notes, and snippets.

@justinwoo
Last active December 9, 2015 23:18
Show Gist options
  • Save justinwoo/4343114 to your computer and use it in GitHub Desktop.
Save justinwoo/4343114 to your computer and use it in GitHub Desktop.
Chops up an image so that it may be used for scrolling image videos. Not very sophisticated.
from PIL import Image
#what image?
im = Image.open("./xgCGa.jpg")
outdir = "./output/"
#define time to match
time = 177.0
frametime = .03
#define size of image
size_x = im.size[0]
size_y = im.size[1]
#define stepsize
total_frames = time / frametime
stepsize = (float(size_y) - float(size_x)) / total_frames
steps = []
val = 0
while val < (size_y - size_x):
steps.append(val)
val += stepsize
#go through steps of the image
a = 0
for val in steps:
step = int(val)
stepim = im.crop((0, step, size_x, step + size_x))
stepim.save(outdir + "frame" + str(a) + ".jpg", "JPEG")
a += 1
@justinwoo
Copy link
Author

not using os.path
2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment