Advertisement
Guest User

image_provider

a guest
Oct 9th, 2015
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.44 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3.  
  4. import pyotherside
  5. import urllib.request
  6.  
  7. import os
  8. import random
  9.  
  10.  
  11. def image_provider(image_id, requested_size):
  12.  
  13.     if requested_size == (-1, -1):
  14.         requested_size = (300, 300)
  15.  
  16.  
  17.     response = urllib.request.urlopen(image_id)
  18.     data = response.read()
  19.     return bytearray(data), requested_size, pyotherside.format_data
  20.  
  21. pyotherside.set_image_provider(image_provider)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement