brandkit

package module
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 28, 2026 License: MIT Imports: 12 Imported by: 0

README

BrandKit

Build Status Lint Status Go Report Card Docs Visualization License

A Go toolkit for processing brand icons — analyzing, verifying, and converting SVG files. Use it as a CLI tool or as a library in your own Go programs.

Installation

CLI
go install github.com/grokify/brandkit/cmd/svg@latest
Library
go get github.com/grokify/brandkit

CLI Usage

# Convert icon colors to white on transparent background
brandkit white icon_orig.svg -o icon_white.svg

# Convert to a specific color
brandkit convert icon.svg -o output.svg --color ff5500

# Remove background and convert
brandkit convert icon.svg -o output.svg --color ffffff --remove-background --include-stroke

# Full pipeline: convert, center, verify
brandkit process icon.svg -o output.svg --color ffffff --center --strict

# Analyze SVG geometry (centering, padding)
brandkit analyze brands/

# Verify SVGs are pure vector (no embedded raster data)
brandkit verify brands/

Library Usage

Color Conversion
import "github.com/grokify/brandkit/svg/convert"

result, err := convert.SVG("input.svg", "output.svg", convert.Options{
    Color:            "ffffff",
    RemoveBackground: true,
    IncludeStroke:    true,
    PreserveMasks:    true,
})
Verification
import "github.com/grokify/brandkit/svg/verify"

result, err := verify.SVG("icon.svg")
if result.IsSuccess() {
    fmt.Println("Pure vector SVG")
}
Analysis
import "github.com/grokify/brandkit/svg/analyze"

result, err := analyze.SVG("icon.svg")
fmt.Printf("Padding: L:%.1f%% R:%.1f%% T:%.1f%% B:%.1f%%\n",
    result.PaddingLeft, result.PaddingRight,
    result.PaddingTop, result.PaddingBottom)
SVG Types
import "github.com/grokify/brandkit/svg"

// Parse and work with SVG paths
commands := svg.ParsePath("M 0 0 L 100 0 L 100 100 Z")
bounds := svg.CalculatePathBounds("M 10 10 L 90 90")

// ViewBox parsing
vb, _ := svg.ParseViewBox("0 0 100 100")

Packages

Package Description
svg Shared SVG types: BoundingBox, ViewBox, path parsing, file utilities
svg/analyze Geometry analysis: centering, padding, viewBox suggestions
svg/convert Color conversion, background removal, mask preservation
svg/verify Pure vector validation, embedded data detection

Brand Assets

The brands/ directory contains SVG icons for 36 brands with standardized variants:

  • icon_orig.svg — Original source icon
  • icon_white.svg — White on transparent background
  • icon_color.svg — Color variant (select brands)

Development

make build       # Build CLI binary
make test        # Run tests
make lint        # Run golangci-lint
make white       # Process all brands to white icons
make verify      # Verify all brand SVGs are pure vector
make analyze     # Analyze all brands for centering issues
make build-all   # Cross-platform builds

License

MIT

Documentation

Overview

Package brandkit provides embedded brand icons.

Icons are embedded at compile time and can be retrieved by brand name. Each brand has three variants: color, white (for dark backgrounds), and original.

Example:

svg, err := brandkit.GetIconWhite("aws")
if err != nil {
    log.Fatal(err)
}
// svg contains the white AWS icon SVG bytes

Package brandkit provides embedded brand icons and SVG processing utilities.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetIcon

func GetIcon(brand string, variant IconVariant) ([]byte, error)

GetIcon retrieves an icon by brand name and variant. Returns the SVG content as bytes.

func GetIconColor

func GetIconColor(brand string) ([]byte, error)

GetIconColor retrieves the full color icon.

func GetIconOrig

func GetIconOrig(brand string) ([]byte, error)

GetIconOrig retrieves the original unmodified icon.

func GetIconWhite

func GetIconWhite(brand string) ([]byte, error)

GetIconWhite retrieves the white variant icon for dark backgrounds.

func IconExists

func IconExists(brand string) bool

IconExists checks if a brand icon exists.

func ListIcons

func ListIcons() ([]string, error)

ListIcons returns all available brand names.

func NormalizeIconName

func NormalizeIconName(name string) string

NormalizeIconName converts common aliases to brandkit names. For example, "golang" -> "go", "postgresql" -> "postgres".

Types

type IconVariant

type IconVariant string

IconVariant represents the icon color variant.

const (
	// IconVariantWhite is a white foreground icon for dark backgrounds.
	IconVariantWhite IconVariant = "white"
	// IconVariantColor is the full color icon.
	IconVariantColor IconVariant = "color"
	// IconVariantOrig is the original unmodified icon.
	IconVariantOrig IconVariant = "orig"
)

type ProcessResult

type ProcessResult struct {
	InputPath         string
	OutputPath        string
	BackgroundRemoved bool
	ColorConverted    bool
	TargetColor       string
	Centered          bool
	SuggestedViewBox  string
	Verified          bool
	VectorElements    []string
	SecurityScanned   bool
	SecurityThreats   []security.Threat
}

ProcessResult contains the result of a processing operation.

func ProcessColor

func ProcessColor(inputPath, outputPath string) (*ProcessResult, error)

ProcessColor creates a centered color icon on transparent background. It removes background elements, centers the content, verifies the result is pure vector while preserving original colors, and performs security scanning.

Equivalent to CLI: brandkit color <input> -o <output>

func ProcessWhite

func ProcessWhite(inputPath, outputPath string) (*ProcessResult, error)

ProcessWhite creates a white icon on transparent background. It removes background elements, converts all colors to white, centers the content, verifies the result is pure vector, and performs security scanning.

Equivalent to CLI: brandkit white <input> -o <output>

Directories

Path Synopsis
cmd
svg command
brandkit is a CLI tool for brand icon processing: analyzing, verifying, and converting SVG icons.
brandkit is a CLI tool for brand icon processing: analyzing, verifying, and converting SVG icons.
svg
Package svg provides shared types and utilities for SVG processing.
Package svg provides shared types and utilities for SVG processing.
analyze
Package analyze provides SVG analysis for centering and padding.
Package analyze provides SVG analysis for centering and padding.
convert
Package convert provides SVG color conversion functionality.
Package convert provides SVG color conversion functionality.
security
Package security provides SVG security scanning to detect and remove malicious elements.
Package security provides SVG security scanning to detect and remove malicious elements.
verify
Package verify validates SVG files are pure vector images.
Package verify validates SVG files are pure vector images.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL