pix

package module
v0.0.0-...-838a8da Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2026 License: MIT Imports: 14 Imported by: 0

README

Pixlate

Turn photos into abstract art.

https://github.com/user-attachments/assets/3f3885c3-b7c4-4240-9bb9-1df03461941f

Installation

Recommended (modules-aware, Go 1.18+):

go install github.com/arnabjena007/pixlate/cmd/pix@latest

This installs the pix binary into your GOBIN (or $HOME/go/bin by default). Make sure that directory is in your PATH.

Build from source:

git clone https://github.com/arnabjena007/Pixlate.git
cd Pixlate
go build ./cmd/pix
# then run:
./pix -in picture.jpg

Usage

Run it like so (minimal):

pix -in picture.jpg

Run with output, size, or generate multiple variations:

pix -in picture.jpg -out pix.output.png -width 800 -height 800
pix -in picture.jpg -sweep
pix -in picture.jpg -variations 4

Flags

The command supports the following flags (see pix -h for detailed help):

  • -in (required): input image path or URL
  • -out: output image path
  • -width, -height: dimensions of the output
  • -white-percent, -colorsort, -random, -reverse
  • -sweep, -random-seed, -variations
  • -compress: png compression level
  • -seeds: seed positions (e.g. "x y x y ...")

Notes

  • The README previously recommended go get -u ...; modern Go modules usage prefers go install ...@latest for installing binaries. go get for installing binaries is deprecated in newer Go versions.
  • Recommend using Go 1.18+ for best compatibility with module behavior.
  • If you need any help updating the README further or opening a PR with code fixes (I found a couple of small issues in cmd/pix/main.go), I can prepare that for you.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewNeighbors

func NewNeighbors(w, h int) neighbors

func Place

func Place(colors []SampledColor, opts Options) error

func SortBySimilarity

func SortBySimilarity(colors []SampledColor, opts SortOptions)

Types

type Canvas

type Canvas struct {
	// contains filtered or unexported fields
}

A canvas represents a specific pixel-placed drawing

func NewCanvas

func NewCanvas(w, h int, seed int64) *Canvas

func (*Canvas) ImageData

func (c *Canvas) ImageData() []uint8

func (*Canvas) Place

func (c *Canvas) Place(x SampledColor)

func (*Canvas) PlaceAt

func (c *Canvas) PlaceAt(code MortonCode, pos Pos)

func (*Canvas) PlaceSeed

func (c *Canvas) PlaceSeed(color SampledColor, x, y int)

func (*Canvas) PlaceSeeds

func (c *Canvas) PlaceSeeds(colors []SampledColor, xys ...int) ([]SampledColor, error)

func (*Canvas) Reset

func (c *Canvas) Reset()

func (*Canvas) SaveImage

func (c *Canvas) SaveImage(path string, compressionLevel png.CompressionLevel) error

type Color

type Color struct {
	// contains filtered or unexported fields
}

Color represents a color in linear RGB or OkLab

type Handle

type Handle uint32

type ImageColor

type ImageColor struct {
	X, Y    int
	R, G, B uint8
}

func LoadImage

func LoadImage(path string) ([]ImageColor, error)

Returns `ImageColor`s from the source in row major order.

type MortonCode

type MortonCode uint32

type Options

type Options struct {
	Width, Height    int
	RandomSeed       int64
	Sort             SortOptions
	Seeds            []int
	Output           string
	CompressionLevel png.CompressionLevel
}

type Pos

type Pos int32

Pos represents an (x, y index) pair as a single uint32 index into a (padded) array.

type SampledColor

type SampledColor struct {
	// contains filtered or unexported fields
}

Represents a color sample in the RGB and OkLab color spaces, along with its Morton and Hilbert codes.

func SampleColors

func SampleColors(src []ImageColor, nPixels int) []SampledColor

type SortOptions

type SortOptions struct {
	Image, Color, Random float64
	Reverse              bool
}

Directories

Path Synopsis
cmd
pix command

Jump to

Keyboard shortcuts

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