Created
July 10, 2014 15:36
-
-
Save vaclavcadek/d52fb355a87ff78a84df to your computer and use it in GitHub Desktop.
Download image from url, make polyline and convert it to base64
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
from base64 import b64encode | |
from PIL import Image, ImageDraw | |
import requests | |
from StringIO import StringIO | |
url = 'http://jssgallery.org/other_artists/andy_warhol/campbells.jpg' | |
response = requests.get(url) | |
img = Image.open(StringIO(response.content)) | |
draw = ImageDraw.Draw(img) | |
draw.line([(449, 203), (447, 763), (208, 763), (215, 200), (449, 203)], fill=126, width=3) | |
output = StringIO() | |
img.save(output, 'PNG') | |
contents = output.getvalue() | |
print b64encode(contents) | |
img.save("img.png", "PNG") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment