Identikon (original) (raw)

8.15

A small framework for generating identicons.

1 Installation & updates🔗ℹ

At the command line:

raco pkg install identikon

After that, you can update the package from the command line:

raco pkg update identikon

Identikon has a full command line interface which you can view with

2 Generating identicons🔗ℹ

Identikon provides a single function, identikon, which produces images based on input. If input is a string or symbole, a SHA1 hash will be produced and used to geneate an image. If a filename is provided a SHA1 of the file will be produced and used as input for generating images.

Produces an identikon with dimensions specified by width andheight.

input is converted into a list of numbers based on a SHA1 hash and passed to a rules module for processing into an image?.

rules is the name of the rules module to use in generating the identicon. This defaults to "default".

If #:filename is #t then identikon will treat the value of input as a filename and attempt fo open it for processing.

Examples:

Create a 300x300px identicon for "racket" using the "default.rkt" rule module.

Example:

> (identikon 300 300 "racket")
image

Create a 300x300 identicon for "racket" using the "squares.rkt" rule module.

Example:

> (identikon 300 300 "racket" 'squares)
image

Save an identikon image to disk. Available types are svg,png and jpeg. If the file already exists, a new version of the file will be saved with a timestamp (seconds) appended.

#:quality only affects jpeg images.

(save-identikon "foo" 'png
(identikon 300 300 'racket 'qbert))

Return an identikon in a string format. This is useful if you want to inject the image directly into an HTML page as an element or as a data-uri.

Available types are svg, png and jpeg.

svg will emit a well formed SVG element.

png and jpeg types will emit a string of base-64 encoded bytes suitable for use in an HTML data-uri.

#:quality only affects jpeg images.

(identikon->string (identikon 300 300 'racket 'qbert) 'svg)

3 Rules modules🔗ℹ

All rules modules must provide a single draw-rules function and live in the rules folder.

Example:

> (draw-rules 200 200 '(27 180 200 176 189 77 68 156 1 211 209 117 218 72 146 38 144 184 241 76))
image

4 License & source code🔗ℹ

This module is under the MIT license.

Source repository at https://github.com/DarrenN/identikon. Suggestions, corrections and pull-requests welcome.