Open source library for generating identicons.
Open source library for generating identicons.
Include the Jdenticon library somewhere on your page. Jdenticon is served from jsDelivr in this example.
<script src="https://cdn.jsdelivr.net/npm/jdenticon@3.2.0/dist/jdenticon.min.js" async integrity="sha384-yBhgDqxM50qJV5JPdayci8wCfooqvhFYbIKhv0hTtLvfeeyJMJCscRfFNKIxt43M" crossorigin="anonymous"> </script>
Add an empty inline <svg>
element where you want to render an identicon. Use the data-jdenticon-value
attribute to specify that an identicon should be rendered. user127
below is just an example of a value.
<svg data-jdenticon-value="user127" width="80" height="80"> Fallback text or image for browsers not supporting inline svg. </svg>
Refresh the page and voila!
See get started or the documentation for more examples.
Create an empty directory and install the Jdenticon NPM package.
npm install jdenticon
Save the following code as test.js
in the directory you created above.
const jdenticon = require("jdenticon"); const fs = require("fs"); const value = "icon value"; const size = 200; const png = jdenticon.toPng(value, size); fs.writeFileSync("./testicon.png", png);
Run the test file and open testicon.png
in the working directory.
node ./test.js
See get started or the documentation for more examples.
Install the Jdenticon Composer package.
composer require jdenticon/jdenticon
Use the Identicon class to create identicons.
<?php include_once("vendor/autoload.php"); $icon = new \Jdenticon\Identicon(); $icon->setValue('Value to be hashed'); $icon->setSize(100); $icon->displayImage();
See get started or the documentation for more examples.
Install the Jdenticon.AspNetCore NuGet package.
PM> Install-Package Jdenticon.AspNetCore
Call UseJdenticon
in your Startup.cs
. Put the call right above UseStaticFiles
.
using Jdenticon.AspNetCore; /* ... */ public class Startup { /* ... */ public void Configure(IApplicationBuilder app, IHostingEnvironment env) { /* ... */ app.UseJdenticon(); app.UseStaticFiles(); app.UseMvc(); /* ... */ } }
Add the following lines to your _ViewImports.cshtml
.
@using Jdenticon.AspNetCore
@addTagHelper "*, Jdenticon.AspNetCore"
Render icons on a page by using any of the following examples:
@{ var myIconValue = "jdenticon"; } Icon: <img identicon-value="myIconValue" width="100" height="100" alt="Identicon" /> Icon: @Html.Identicon(myIconValue, size: 100, alt: "Icon") Icon: <img src="@Url.Identicon(myIconValue, size: 100)" alt="Icon" width="100" height="100" />
See get started or the documentation for more examples.
Install the Jdenticon.AspNet.Mvc NuGet package.
PM> Install-Package Jdenticon.AspNet.Mvc
Now you can render icons on any page by using the following code:
@using Jdenticon.AspNet.Mvc; <div> Icon: @Html.Identicon("Value to be hashed", size: 100, alt: "Icon") Icon: <img src="@Url.Identicon("Value to be hashed", size: 100)" alt="Icon" width="100" height="100" /> </div>
See get started or the documentation for more examples.
Install the Jdenticon-net NuGet package.
PM> Install-Package Jdenticon-net
Use the Identicon class to create identicons.
using Jdenticon; class Program { static void Main() { Identicon .FromValue("string to hash", size: 160) .SaveAsPng("test.png"); } }
See get started or the documentation for more examples.
Browser client-side | Version |
---|---|
Chrome | 7+ |
Safari | 5+ |
Internet Explorer | 9+ |
Firefox | 4+ |
Microsoft Edge | 1+ |
Opera | 11+ |
Web apps | Version |
---|---|
PHP | 5.3+ |
ASP.NET Core | 1.0+ |
ASP.NET MVC | 4.0+ |
ASP.NET WebApi | 4.0+ |
ASP.NET WebForms | 2.0+ |
General framework | Version |
---|---|
Node.js | 6.4.0+ |
.NET | 5.0+ |
.NET Framework | 2.0+ |
.NET Core | 1.0+ |
Windows Forms | 4.0+ |
WPF | 4.0+ |
Jdenticon is released under the terms of the MIT license.
Copyright (c) 2014-2022 Daniel Mester Pirttijärvi
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.