def get_image_info(url):
 r = requests.get(url, stream=True)
 image_size = r.headers.get('content-length')
 image_size = (float(image_size) / 1000)
 image_max_size = 10000
 image_data = {'content_type': '', 'size': image_size, 'width': 0, 'height': 0}
 if (image_size > image_max_size):
  return image_data
 data = None
 parser = ImageFile.Parser()
 while True:
  data = r.raw.read(1024)
  if (not data):
   break
  parser.feed(data)
  if parser.image:
   image_data['content_type'] = parser.image.format
   image_data['width'] = parser.image.size[0]
   image_data['height'] = parser.image.size[1]
   break
 return image_data

def get_image_info ( url ) : r = requests . get ( url , stream = True ) image_size = r . headers . get ( 'content-length' ) image_size = ( float ( image_size ) / 1000 ) image_max_size = 10000 image_data = { 'content_type' : '' , 'size' : image_size , 'width' : 0 , 'height' : 0 } if ( image_size > image_max_size ) : return image_data data = None parser = ImageFile . Parser ( ) while True : data = r . raw . read ( 1024 ) if ( not data ) : break parser . feed ( data ) if parser . image : image_data [ 'content_type' ] = parser . image . format image_data [ 'width' ] = parser . image . size [ 0 ] image_data [ 'height' ] = parser . image . size [ 1 ] break return image_data
returns the content-type .