Skip to content

Instantly share code, notes, and snippets.

@dokeeffe
Created January 26, 2018 22:13
Show Gist options
  • Save dokeeffe/fbeda8db64d23cab0c90579842efee21 to your computer and use it in GitHub Desktop.
Save dokeeffe/fbeda8db64d23cab0c90579842efee21 to your computer and use it in GitHub Desktop.
import glob, os
from PIL import Image, ImageFont, ImageDraw
# Script used to generate https://www.youtube.com/watch?v=CYZBLVuM4nU
# run this command after this script runs > ffmpeg -framerate 15 -pattern_type glob -i '/home/dokeeffe/Desktop/xo-2b-transit-allsky/*.jpg' -c:v libx264 ~/Desktop/xo-2b-transit-allsky/allsky$.mp4
plot_image = Image.open('/home/dokeeffe/Pictures/Selection_037.png')
fit_image = Image.open('/home/dokeeffe/Pictures/Selection_038.png')
data_files = glob.glob('/home/dokeeffe/Desktop/xo-2b-transit-allsky/all*.jpg')
start_whiteout = 220
end_whiteout=1100
add_fit_image_at_frame=267
counter=0
for data_file in sorted(data_files):
print(data_file)
all_sky = Image.open(data_file)
new_im = Image.new('RGB', (1290, 960+382))
if counter < add_fit_image_at_frame:
new_im.paste(plot_image, (140,0))
else:
new_im.paste(fit_image, (140,0))
new_im.paste(all_sky, (0,380))
rectx = start_whiteout + ((end_whiteout-start_whiteout)/add_fit_image_at_frame)*counter
if rectx < end_whiteout:
dr = ImageDraw.Draw(new_im)
dr.rectangle(((rectx,70),(end_whiteout,335)), fill="white", outline = "white")
new_im.save('/home/dokeeffe/Desktop/movie/'+os.path.basename(data_file))
counter+=1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment