0 purchases
blockify
Generate and configure image avatars
based off of the hash of any arbitrary string content.
This functionality is inspired by GitHub's
identicons,
but uses a different algorithm so will not result in identical outputs.
Note
The algorithm of this package may change over time
to improve generated image quality,
so there is no guarantee of stability of generated images between versions.
We will consider this a semver break,
so if image generation changes without any action by the user,
we would for example upgrade the version
from 0.1.0 -> 0.2.0 or 1.0.0 -> 2.0.0.
We are always open to suggestions about how to improve the algorithm
and/or image quality so please reach out if you have any suggestions!
Usage #
A simple usage example generating an avatar based off the string parlough
and storing it as a PNG image on the file system.
import 'dart:io';
import 'package:blockify/blockify.dart';
import 'package:image/image.dart';
/// This example generates a rendered icon using most of the default parameter
/// values but setting the background as transparent. Then it proceeds to
/// encode the result as a PNG with the `image` package, and proceeds to store
/// the encoded PNG in a file named `parlough.png`.
void main() {
const content = 'parlough';
// Render the image with a transparent background.
final image = render(
content: content,
backgroundColor: ColorRgba8(0, 0, 0, 0),
);
// Encode the image as a PNG image with the `image` package.
final encoded = encodePng(image);
// Create a new file with the `dart:io` library.
final file = File('$content.png');
// Finally write out the encoded PNG to the newly created file.
file.writeAsBytesSync(encoded);
}
copied to clipboard
Generated image:
Another example:
Features and bugs #
Please file feature requests and bugs in the issue tracker.
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.