Code Monkey home page Code Monkey logo

boring-avatars-service's Introduction

How to use Boring Avatars service

To generate a custom avatar just embed the following URL https://source.boringavatars.com/ and append a variant, size and a username to generate a custom avatar.

Variants

You can use one of the variants marble, beam, pixel, sunset, ring or bauhaus.

https://source.boringavatars.com/beam

Avatar using marble variant

Custom size

https://source.boringavatars.com/marble/40

Avatar of 120px

https://source.boringavatars.com/marble/160

Avatar of 120px

Custom colors

You can pass an array of colors using the parameter color

https://source.boringavatars.com/marble/120/Maria%20Mitchell?colors=264653,2a9d8f,e9c46a,f4a261,e76f51

Avatar for Maria Mitchell

Square avatars

Use the parameter square to get square-shaped avatars.

https://source.boringavatars.com/marble/120/Maria%20Mitchell?square

Square avatar for Maria Mitchell

Name

You can use a username, email or any random text to generate a unique avatar.

https://source.boringavatars.com/marble/120/Maria%20Mitchell

Avatar for Maria Mitchell

Random avatar

If you just want to use random avatars without providing usernames, you can use the root endpoint. You will receive an svg image with a 80*80px size using the marble variant.

https://source.boringavatars.com/

Random avatar

boring-avatars-service's People

Contributors

josepmartins avatar stephenarra avatar vieron avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

boring-avatars-service's Issues

[Feature]: Make this a standalone Library

Dear BoringDesigners @josepmartins ,

thanks for this awesome service, i really like it. I would like to use this service in my standalone application - however, i would like to create / generate the avatars on my own (i.e., without making an HTTP GET call to your service).

Would it be possible to have a dedicated npm library to generate the avatars myself? i.e., something like this:

const svg = generateAvatar('marble', { ... });
const avatar = svg.toString();

All the best and thanks for your help,
Johannes

Increase max-age when set name.

Is your feature request related to a problem? Please describe.

I've seen you set cache-control: s-max-age=1:
https://github.com/hihayk/boring-avatars-service/blob/1cf355b12ec0aa3b2be284641da32ec1105b55ab/api/index.js#L38

But it only lasts for a second, so I experienced a lot of cache misses.

From what I can see, the boring avatar is the same if we specify name.
So the cache-control for when the user sends name should be high.

Describe the solution you'd like

Increase the cache control to something like a day or a week.
In express, is something like:

// only cache if name is passed.
if (req.query.name || req.params.name) {
  // ref: https://vercel.com/docs/concepts/functions/serverless-functions/edge-caching#recommended-cache-control
  res.setHeader('Cache-Control', 'max-age=0, s-maxage=86400');
} else {
  res.setHeader('Cache-control', 'max-age=0, s-max-age=1');
}

Avatar from service does not match output from React library with identical params

The avatars generated from the react library and the service using identical arguments do not match.

Example to reproduce

React library

Input
import Avatar from "boring-avatars";

<Avatar
  size={40}
  name="Maria Mitchell"
  variant="marble"
  colors={["#264653", "#2a9d8f", "#e9c46a", "#f4a261", "#e76f51"]}
/>;
Output

Maria Mitchell-react

Service

Input

https://source.boringavatars.com/marble/40/Maria%20Mitchell?colors=264653,2a9d8f,e9c46a,f4a261,e76f51

Output

Maria Mitchell-service

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.