Skip to content

setanarut/apng

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GoDoc

apng

Fast APNG encoder. Very fast APNG encoding with parallel (Goroutines) computation.

Installation

go get github.com/setanarut/apng

20 frames animation encoding benchmark

Image Size kettek setanarut
125x125 173 ms 43 ms
250x250 655 ms 153 ms
500x500 2542 ms 565 ms
1000x1000 10174 ms 2213 ms
2000x2000 40745 ms 8831 ms
bench

Example

package main

import (
	"image"
	"image/color"
	"math/rand/v2"

	"github.com/setanarut/apng"
)

func main() {
	frames := make([]image.Image, 8)
	for i := range 8 {
		frames[i] = generateNoiseImage(600, 200)
	}
	apng.Save("out.png", frames, 7)
}

func generateNoiseImage(width, height int) *image.RGBA {
	img := image.NewRGBA(image.Rect(0, 0, width, height))
	for y := range height {
		for x := range width {
			col := noisePalette[rand.IntN(4)]
			img.SetRGBA(x, y, col)
		}
	}
	return img
}

var noisePalette = []color.RGBA{
	{R: 0, G: 0, B: 0, A: 255},   // Black
	{R: 255, G: 0, B: 0, A: 255}, // Red
	{R: 0, G: 255, B: 0, A: 255}, // Green
	{R: 0, G: 0, B: 255, A: 255}, // Blue
}

out

About

Fast APNG encoder in Go

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages