Beispiel #1
0
def _query_image( ref, lasttry = False ):
   ''' ComicVine implementation of the identically named method in the db.py '''
   
   retval = None # the Image object that we will return

   # 1. determine the URL   
   image_url_s = None
   if isinstance(ref, SeriesRef):
      image_url_s = ref.thumb_url_s
   elif isinstance(ref, IssueRef):
      image_url_s = ref.thumb_url_s
   elif is_string(ref):
      image_url_s = ref
   
   # 2. attempt to load the image for the URL
   if image_url_s:
      response = None
      response_stream = None
      try:
         cvconnection.wait_until_ready() # throttle our request speed 
         request = WebRequest.Create(image_url_s)
         request.UserAgent = "[ComicVineScraper, version " + \
         Resources.SCRIPT_VERSION + "]"
         response = request.GetResponse()
         response_stream = response.GetResponseStream()
         retval = Image.FromStream(response_stream)
      except:
         if lasttry:
            log.debug_exc('ERROR retry image load failed:')
            retval = None
         else:
            log.debug('RETRY loading image -> ', image_url_s)
            retval = _query_image( ref, True )
      finally: 
         if response: response.Dispose()
         if response_stream: response_stream.Dispose()

   # if this value is stil None, it means an error occurred, or else comicvine 
   # simply doesn't have any Image for the given ref object             
   return retval 
Beispiel #2
0
def image_from_remote(source):
    """Construct an image from a remote source.

    Parameters
    ----------
    source : str
        The url of the remote source.

    Returns
    -------
    System.Drawing.Image
        Representation of an miage in memory.

    Examples
    --------
    .. code-block:: python

        image = image_from_remote('http://block.arch.ethz.ch/brg/images/cache/dsc02360_ni-2_cropped_1528706473_624x351.jpg')

    """
    w = WebClient()
    d = w.DownloadData(source)
    m = MemoryStream(d)
    return Image.FromStream(m)
Beispiel #3
0
	for l,m in zip(i,j):
		b = string1 + str(k) + string3 + str(z) + string34 + str(m) + string5 + str(l) + string7
		a.append(b)
	urlList.append(a)

bitmaps2 = []


for i in urlList:
	bitmaps = []
	for j in i:
		request = WebRequest.Create(j)
		request.Accept = "text/html"
		request.UserAgent = "Mozilla/5.0"
		response = request.GetResponse()
		bitmaps.append(Image.FromStream(response.GetResponseStream()))
	bitmaps2.append(bitmaps)

combinedBitmaps = []
for a,b,c in zip(bitmaps2,UniqueTileColumns,UniqueTileRows):
	TotalWidth = len(b)*PixelWidth
	TotalHeight = len(c)*PixelWidth
	img = Bitmap(TotalWidth,TotalHeight)
	g = Graphics.FromImage(img)
	LPx = []
	n = 0
	for l in j:
		LPx.append(n*PixelWidth)
		n=n+1
	
	LPy = []