def image(request, data):
<EOL>try:<EOL><INDENT>width = int(request.GET.get("<STR_LIT:w>", PYDENTICON_WIDTH))<EOL><DEDENT>except ValueError:<EOL><INDENT>raise SuspiciousOperation("<STR_LIT>")<EOL><DEDENT>try:<EOL><INDENT>height = int(request.GET.get("<STR_LIT:h>", PYDENTICON_HEIGHT))<EOL><DEDENT>except ValueError:<EOL><INDENT>raise SuspiciousOperation("<STR_LIT>")<EOL><DEDENT>output_format = request.GET.get("<STR_LIT:f>", PYDENTICON_FORMAT)<EOL>try:<EOL><INDENT>padding = [int(p) for p in request.GET["<STR_LIT:p>"].split("<STR_LIT:U+002C>")]<EOL><DEDENT>except KeyError:<EOL><INDENT>padding = PYDENTICON_PADDING<EOL><DEDENT>except ValueError:<EOL><INDENT>raise SuspiciousOperation("<STR_LIT>")<EOL><DEDENT>if "<STR_LIT:i>" in request.GET:<EOL><INDENT>inverted = request.GET.get("<STR_LIT:i>")<EOL>if inverted.lower() == "<STR_LIT:true>":<EOL><INDENT>inverted = True<EOL><DEDENT>elif inverted.lower() == "<STR_LIT:false>":<EOL><INDENT>inverted = False<EOL><DEDENT>else:<EOL><INDENT>raise SuspiciousOperation("<STR_LIT>")<EOL><DEDENT><DEDENT>else:<EOL><INDENT>inverted = PYDENTICON_INVERT<EOL><DEDENT>if not isinstance(width, int) or width <= <NUM_LIT:0>:<EOL><INDENT>raise SuspiciousOperation("<STR_LIT>")<EOL><DEDENT>if not isinstance(height, int) or height <= <NUM_LIT:0>:<EOL><INDENT>raise SuspiciousOperation("<STR_LIT>")<EOL><DEDENT>if not all([isinstance(p, int) and p >= <NUM_LIT:0> for p in padding]) or len(padding) != <NUM_LIT:4>:<EOL><INDENT>raise SuspiciousOperation("<STR_LIT>")<EOL><DEDENT>if output_format == "<STR_LIT>":<EOL><INDENT>content_type = "<STR_LIT>"<EOL><DEDENT>elif output_format == "<STR_LIT:ascii>":<EOL><INDENT>content_type = "<STR_LIT>"<EOL><DEDENT>else:<EOL><INDENT>raise SuspiciousOperation("<STR_LIT>")<EOL><DEDENT>generator = Generator(PYDENTICON_ROWS, PYDENTICON_COLUMNS,<EOL>foreground = PYDENTICON_FOREGROUND, background = PYDENTICON_BACKGROUND,<EOL>digest = PYDENTICON_DIGEST)<EOL>content = generator.generate(data, width, height, padding=padding, output_format=output_format, inverted=inverted)<EOL>response = HttpResponse(content, content_type=content_type)<EOL>return response<EOL>
Generates identicon image based on passed data.

Arguments:

  data - Data which should be used for generating an identicon. This data
  will be used in order to create a digest which is used for generating the
  identicon. If the data passed is a hex digest already, the digest will be
  used as-is.

Returns:

  Identicon image in raw format.