Skip to content

Instantly share code, notes, and snippets.

@snuke
Last active June 15, 2019 01:59
Show Gist options
  • Save snuke/5fe531ef1d33494fb9973d0840ebf609 to your computer and use it in GitHub Desktop.
Save snuke/5fe531ef1d33494fb9973d0840ebf609 to your computer and use it in GitHub Desktop.
rotate twitter icon
import twitter # pip install python-twitter
from PIL import Image # pip install pillow
import datetime, calendar
icon_path = 'icon.jpg'
save_path = 'tmp.jpg'
api = twitter.Api(
consumer_key='',
consumer_secret='',
access_token_key='',
access_token_secret=''
)
# today = datetime.date.today()
# day = today.day
# days = calendar.monthrange(today.year, today.month)[1]
# angle = 360*(day-1)/days
angle = 360*(datetime.datetime.now().hour)/12
img = Image.open(icon_path)
img.rotate(-angle, fillcolor=(255,255,255)).save(save_path)
api.UpdateImage(save_path)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment