-- Leo's gemini proxy

-- Connecting to jsreed5.org:1965...

-- Connected

-- Sending request

-- Meta line: 20 text/gemini

My Microblogging Script and Avatar Generation

2022-01-20


---


The most recent update to my microblogging script implements avatar support and generates a unique user ID when creating a new timeline file. The ID is simply a UUID, and "avatar support" means an avatar file is displayed in the header. If the user does not specify an avatar file, however, the script generates an avatar based on the ID.


I implemented this feature in Bash by using `bc` to convert the hexadecimal UUID to base 6, keeping the smallest 36 digits of the converted number, building an SVG file containing 36 squares in a 6x6 grid, and coloring each square based on the digits of the base-6 number.


This process does not generate a unique avatar for each UUID. More than 10^28 color combinations are possible, but that number is still about 11 orders of magnitude smaller than the number of possible UUIDs. Regardless, those numbers are sufficiently large that I think a collision is highly doubtful. One would be much more likely to get a UUID that generates only five colors--a chance of about 1 in 1000.


I had actually originally intended to generate PNG files instead of SVG. Most Markdown viewers don't display SVG files properly, and due to the large amount of repeated information in the avatars, compressed PNGs tend to be around 350 bytes in size. I haven't given up on this endeavor, and I'm currently learning how the DEFLATE compression algorithm works. Since the space of possible PNGs is limited, I hope to find properties of the algorithm that I could abuse to generate compressed data directly. It's been a fun exercise so far.


For my own purposes, I consider the script to be functionally complete. The only big item on my to-do list is to make the script portable and POSIX-compliant. At that point I'll probably consider it complete and bump the version number to 1.0.


---


Up One Level

Home


[Last updated: 2022-01-20]

-- Response ended

-- Page fetched on Thu Mar 28 14:42:01 2024