def is_image(f, types=('<STR_LIT>', '<STR_LIT>', '<STR_LIT>'), set_content_type=True):
assert isinstance(types, (list, tuple))<EOL>t = image_get_format(f)<EOL>if t not in [t.lower() for t in types]:<EOL><INDENT>return False<EOL><DEDENT>if set_content_type:<EOL><INDENT>set_uploaded_file_content_type_and_file_ext(f, t)<EOL><DEDENT>return True<EOL>
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'