code: def is_image(f, types=('png', 'jpeg', 'gif'), set_content_type=True):
      
      assert isinstance(types, (list, tuple))
      t = image_get_format(f)
      if t not in [t.lower() for t in types]:
          return False
      if set_content_type:
          set_uploaded_file_content_type_and_file_ext(f, t)
      return True
docs: Return True if file f is image (types type) and set its correct content_type and filename extension.
      Example:
          if is_image(request.FILES['file']):
              print 'File is image'
  
          if is_image(open('/tmp/image.jpeg', 'rb')):
              print 'File is image'