def format_image(self, image, image_format, **kwargs):
if image_format in ('<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>'):<EOL><INDENT>if image_format != '<STR_LIT>' and FORCE_WEBP:<EOL><INDENT>accept = self.request.META['<STR_LIT>'].split('<STR_LIT:U+002C>')<EOL>if '<STR_LIT>' in accept:<EOL><INDENT>image = image.convert('<STR_LIT>')<EOL>image_format = '<STR_LIT>'<EOL>kwargs = {'<STR_LIT>': True}<EOL><DEDENT><DEDENT>if image_format == '<STR_LIT>':<EOL><INDENT>kwargs['<STR_LIT>'] = True<EOL><DEDENT>elif image_format == '<STR_LIT>':<EOL><INDENT>image.convert('<STR_LIT>')<EOL>kwargs['<STR_LIT>'] = True<EOL><DEDENT>buffer = six.BytesIO()<EOL>image.save(buffer, image_format, **kwargs)<EOL>return buffer.getvalue(), "<STR_LIT>".format(image_format)<EOL><DEDENT>else:<EOL><INDENT>raise ValueError('<STR_LIT>'.format(image_format))<EOL><DEDENT>
Returns an image in the request format