Skip to content

Instantly share code, notes, and snippets.

@jbn
Created July 7, 2021 17:31
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jbn/183b717fa93d287975016be6670fba4c to your computer and use it in GitHub Desktop.
Save jbn/183b717fa93d287975016be6670fba4c to your computer and use it in GitHub Desktop.
How I rotate my AVI
import tweepy
import json
import time
import datetime
from calendar import monthrange
from PIL import Image, ImageEnhance
import pathlib
import pylunar
def calc_phase():
mi = pylunar.MoonInfo((37, 26, 30), (122, 8, 34))
mi.update(datetime.datetime.utcnow())
return mi.fractional_phase()
def rotated_image(original_path, phase):
im = Image.open(original_path)
mi = pylunar.MoonInfo((37, 26, 30), (122, 8, 34))
mi.update(datetime.datetime.utcnow())
if phase < 0.95:
return ImageEnhance.Brightness(im).enhance(phase)
else:
return ImageEnhance.Brightness(im).enhance(1000)
if __name__ == '__main__':
with open("/home/generativist/.brittlewit.json") as fp:
creds = json.load(fp)
auth = tweepy.OAuthHandler(creds['appKey'], creds['appSecret'])
auth.set_access_token(creds['userToken'], creds['userSecret'])
api = tweepy.API(auth)
output_path = pathlib.Path("/home/generativist/Projects/cron/avi-rotator/current_me.png")
img = rotated_image("/home/generativist/Projects/cron/avi-rotator/me_conway.png", calc_phase())
img.save(output_path)
api.update_profile_image(str(output_path))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment