title: Correct way to handle mime types in a downloader
body: <p>I use the requests library in python to download an image file using http. I convert the received content to raw bytes using BytesIO in python and then use Pillow() to save this raw content as a jpeg file.</p>
  
  <pre><code>from PIL import Image
  from io import BytesIO
  
  rsp = requests.get(imageurl)
  content_type_received = rsp.headers['Content-Type'] # mime type
  binarycontent = BytesIO(rsp.content)
  if content_type_received.startswith('image'): # image/jpeg, image/png etc
      i = Image.open(binarycontent)
      outfilename = os.path.join(outfolder,'myimg'+'.jpg')
      with open(outfilename, 'wb') as f:
          f.write(rsp.content)
      rsp.close()
  </code></pre>
  
  <p>In the above code, I am forcing conversion to jpg irrespective of the mime type. This does not seem nice to me viscerally. Is there a standard way of handling the mime subtypes image/png, image/gif etc in python or the Pillow library?</p>