tcgif

package module
v0.0.0-...-b2e88bb Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2022 License: MIT Imports: 4 Imported by: 0

README

tcgif

Go Reference Go Report Card

Trueclor Gif Generator

Why?

Just for kicks. I saw a similar demo many years back and was curious how hard it would be to reproduce.

How?

Gifs have a limited pallet of 255 colors, but that limit is per frame. Gifs also use transparency as a naive compression method such that the previous frame can show through. By utilizing this, we can in fact get 16 million colors in a single Gif!

todo

  • Less naive backfill. Track if the current backfilled color would be closer than a new one.

Samples

Description Image
No Backfill, Unsorted
tcgif -backfill=false -sort=false orig.jpg
Lenna, No Backfill, No Sort
No Backfill, Sorted By Popularity
tcgif -backfill=false orig.jpg
Lenna, No Backfill
Backfilled
tcgif orig.jpg
Lenna, Backfilled
Original Original

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GIFMaker

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

GIFMaker is a struct used to create a "Truecolor GIF" from an image

func NewGIFMaker

func NewGIFMaker(opts ...Option) *GIFMaker

NewGIFMaker creates a new GIFMaker with the specified options

func (*GIFMaker) MakeGIF

func (gm *GIFMaker) MakeGIF(img image.Image) (*gif.GIF, error)

MakeGIF creates a "Truecolor GIF" from the given image using the given options

type Option

type Option func(*GIFMaker)

Option is a function passed to NewGIFMaker to modify the behavior of GIFMaker

func WithBackfill

func WithBackfill(backfill bool) Option

WithBackfill sets whether the GIF will be backfilled preemptively with the closest color in the palette.

func WithFinalDelay

func WithFinalDelay(delay int) Option

WithFinalDelay sets the delay for the final frame of the GIF in 100ths of a second - default is 300

func WithFrameDelay

func WithFrameDelay(delay int) Option

WithFrameDelay sets the delay for each frame in the GIF in 100ths of a second excluding the final frame which is determined by WithFinalDelay

func WithFrameLimit

func WithFrameLimit(limit uint) Option

WithFrameLimit sets the maximum number of frames to be included in the GIF

func WithPopularitySort

func WithPopularitySort(popsort bool) Option

WithPopularitySort sets whether the total palette is sorted by popularity

Disabling this option will result in the palette being sorted by the order in which the colors were found to the image. This can improve performance but may result in a less visually pleasing GIF

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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