Created
July 7, 2021 17:31
-
-
Save jbn/183b717fa93d287975016be6670fba4c to your computer and use it in GitHub Desktop.
How I rotate my AVI
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
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