Re:Ugly Avatar
by Menu_Overview on Monday March 25, 2024 @03:03PM
(#39820091)
You'll need a library that can render to some 2D-context that can then be converted to PNG.
JS is probably where you should look. You might be able to find a good PHP drawing library but I've never come across that in my work. Lots of image converting libraries out there (usually just a wrapper around ImageMagik), but "drawing images" usually a client-side thing and you'll find more support for it.
In JS, you'll draw the image to a `<canvas>` element, which can then be downloaded as a PNG. You could go the SVG route, too, depending on the art style. Canvas is the safer bet.
If you want to deterministically generate avatars for your users, you're looking for "identicons". Googling that will yield several libraries for any common language.
Re:Ugly Avatar
by doublerabbit on Monday March 25, 2024 @03:02PM
(#39820080)
PHP is nice with GD or ImageMagick.
Make a circle.png
Use GD to overlay colour over the radius of the circle
Apply facial details
Then finally anything extra
Re:Ugly Avatar
by hiccuphippo on Monday March 25, 2024 @01:09PM
(#39818783)
You could generate svg.
Or in Javascript?
I don't want to have to hit any APIs.