Created
November 9, 2015 14:57
-
-
Save maryburford/3d4c3b25b74ddefed18c to your computer and use it in GitHub Desktop.
This file contains hidden or 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 urllib | |
| import os | |
| import tweepy | |
| import csv | |
| import time | |
| import PIL | |
| from PIL import Image, ImageOps | |
| def tweet_image(url, message): | |
| api = twitter_api() | |
| urllib.urlretrieve(url, "image.jpg") | |
| filename = 'image.jpg' | |
| image = Image.open(filename) | |
| size = (440,220) | |
| image.thumbnail(size, Image.ANTIALIAS) | |
| background = Image.new('RGBA', size, (255, 255, 255, 0)) | |
| background.paste(image,((size[0] - image.size[0]) / 2, (size[1] - image.size[1]) / 2)) | |
| background.save('resized_image.jpg') | |
| filename1 = 'resized_image.jpg' | |
| api.update_with_media(filename1, status=message) | |
| os.remove(filename1) | |
| os.remove(filename) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment