Skip to content

Instantly share code, notes, and snippets.

Created September 25, 2017 06:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/592658623d5317e7db40164e4d75b95c to your computer and use it in GitHub Desktop.
Save anonymous/592658623d5317e7db40164e4d75b95c to your computer and use it in GitHub Desktop.
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