Created
September 25, 2017 06:05
-
-
Save anonymous/592658623d5317e7db40164e4d75b95c to your computer and use it in GitHub Desktop.
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 gi | |
gi.require_version('GdkPixbuf', '2.0') | |
from gi.repository import GdkPixbuf | |
from urllib import request | |
import sys | |
pbl = GdkPixbuf.PixbufLoader() | |
url = sys.argv[1] | |
def prepped(*args): | |
pb: GdkPixbuf.Pixbuf = pbl.get_pixbuf() | |
print('prepped', pb, pb.get_width(), 'x', pb.get_height()) | |
def updated(*args): | |
print('updated', *args) | |
pbl.connect('area-prepared', prepped) | |
pbl.connect('area-updated', updated) | |
with request.urlopen(url) as fp: | |
while True: | |
buf = fp.read(1024) | |
if not buf: | |
break | |
pbl.write(buf) | |
pbl.close() | |
pb = pbl.get_pixbuf() | |
print('pixbuf', pb, pb.get_width(), 'x', pb.get_height()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment