fraction / oasis

Free, open-source, peer-to-peer social application that helps you follow friends and discover new ones on Secure Scuttlebutt (SSB).
http://oasis-demo.fraction.io
GNU Affero General Public License v3.0
286 stars 42 forks source link

Profile pic generated from public key? #58

Open jasikpark opened 4 years ago

jasikpark commented 4 years ago

What's the problem you want to solved? Screen Shot 2020-01-16 at 10 20 54 PM

Is there a solution you'd like to recommend?

Could this profile pic be filled in with something like color-hash, using the public key as the hashed item?

https://github.com/zenozeng/color-hash https://zenozeng.github.io/color-hash/demo/

jasikpark commented 4 years ago

Also, the name field is null. Idk if that's purposeful, but I personally like the use of the first n characters of the public key as the defacto name.

christianbundy commented 4 years ago

Good idea! I'd love to merge this improvement. The only Big Decision to make is whether we want to use Sharp (which is an optional dependency because it's hard to build) or whether we want it to work for everyone. For example, if we took the first six bytes of someone's public key we could generate a 1x1 GIF with that hex color (which the browser would stretch for us). I sketched out a super quick example: https://github.com/christianbundy/hex-gif

const hexGif = require("hex-gif")

// We don't really need to write to the filesystem in Oasis.
const output = hexGif("#ff00ff")
require("fs").writeFileSync("out.gif", output)

out

^ It's hard to see, but I've uploaded the corresponding GIF above. (Link)

Also, the name field is null. Idk if that's purposeful, but I personally like the use of the first n characters of the public key as the defacto name.

Works for me!

christianbundy commented 4 years ago

Sharp (which is an optional dependency because it's hard to build)

Context: Sharp is only used to resize images, like profile images, before they're transferred to the browser. Lots of profile images are huge, so if we can resize them then we can avoid taking an 8 megapixel photo and resizing it to 40x40 pixels or whatever and holding that memory in the browser tab, but we can just fallback to the browser resizing if the npm install fails.