
Security News
New Website “Is It Really FOSS?” Tracks Transparency in Open Source Distribution Models
A new site reviews software projects to reveal if they’re truly FOSS, making complex licensing and distribution models easy to understand.
github.com/krzysztofmarciniak/256avatars
Used in:
A Go library for generating pixel-art style avatars. Provides functionality to create random and symmetric avatars, save and delete PNG files, and generate HTML tags for easy integration in web applications.
<img>
tags to embed avatars in web pages.go get github.com/krzysztofmarciniak/256avatars
package main
import (
"fmt"
"log"
"github.com/krzysztofmarciniak/256avatars/avatarlib"
)
func main() {
folder := "./avatars"
key := "user123"
keysym := "user1234"
width, height := 256, 256
scale := 4
ka, err := avatarlib.GenerateKeyAvatar(key, width, height)
if err != nil {
log.Fatal(err)
}
ksa, err := avatarlib.GenerateKeySymmetricAvatar(keysym, width, height)
if err != nil {
log.Fatal(err)
}
err = avatarlib.SaveAvatar(folder, ksa, scale)
if err != nil {
log.Fatal(err)
}
err = avatarlib.SaveAvatar(folder, ka, scale)
if err != nil {
log.Fatal(err)
}
path := avatarlib.GetAvatarPath(folder, key)
fmt.Println("Avatar saved to:", path)
sympath := avatarlib.GetAvatarPath(folder, keysym)
fmt.Println("Symmetric avatar saved to:", sympath)
imgTag := avatarlib.GetAvatarHTML("/avatars/", key, width*scale, height*scale)
fmt.Println("HTML tag:", imgTag)
imgTagSym := avatarlib.GetAvatarHTML("/avatars/", keysym, width*scale, height*scale)
fmt.Println("Symmetric HTML tag:", imgTagSym)
// Delete avatar files
// err = avatarlib.DeleteAvatar(folder, keysym)
// if err != nil {
// log.Fatal(err)
// }
// err = avatarlib.DeleteAvatar(folder, key)
// if err != nil {
// log.Fatal(err)
// }
}
GenerateAvatar(width, height int) (*Avatar, error)
Generates a random avatar of the specified size. Returns an error if dimensions are invalid.
GenerateSymmetric(width, height int) (*Avatar, error)
Generates a symmetric avatar (vertical mirror) of the specified size.
type Avatar struct {
Width int
Height int
Pixels []byte
}
Methods:
GetPixel(x, y int) bool
— Get pixel value (white = true, black = false)SetPixel(x, y int, val bool)
— Set pixel valueGenerateKeyAvatar(key string, width, height int) (*KeyAvatar, error)
Creates an avatar wrapped in a KeyAvatar with the given key.
GenerateKeySymmetricAvatar(key string, width, height int) (*KeyAvatar, error)
Creates a symmetric avatar wrapped in a KeyAvatar with the given key.
SaveAvatar(folder string, ka *KeyAvatar, scale int) error
Saves the avatar PNG to folder/.png at the specified scale, creating the folder if necessary.
GetAvatarPath(folder, key string) string
Returns the file path for the avatar PNG.
GetAvatarHTML(baseURL, key string, width, height int) string
Returns an HTML tag pointing to the avatar.
DeleteAvatar(folder, key string) error
Deletes the avatar file.
RenderPNG(a *Avatar, scale int) ([]byte, error)
Encodes the avatar into a scaled PNG byte slice.
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A new site reviews software projects to reveal if they’re truly FOSS, making complex licensing and distribution models easy to understand.
Security News
Astral unveils pyx, a Python-native package registry in beta, designed to speed installs, enhance security, and integrate deeply with uv.
Security News
The Latio podcast explores how static and runtime reachability help teams prioritize exploitable vulnerabilities and streamline AppSec workflows.