Skip to content

SergeiSadov/blurhash

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

blurhash Go Report Card license Build Status codecov

BlurHash encoder and decoder in GO

This is basically a port of the Wolt TypeScript version of the Blurhash alorithm implementation

At the moment works with png, jpg, gif formats

Usage as a library

Just import package using go get:

go get -u github.com/sergeysadov/blurhash

For encoding use:

img, err := utils.GetImg(componentX, componentY, path)
if err != nil {
//handle error
}

hash, _ := blurhash.Encode(img)

For decoding use:

pixels, err := blurhash.Decode(blurHash, width, height, 0)
if err != nil {
//handle error
}

nrgba := image.NewRGBA(image.Rect(0, 0, width, height))
nrgba.Pix = pixels

out, err := os.Create(resultPath)
if err != nil {
//handler error
}

defer out.Close()

if err := png.Encode(out, nrgba); err != nil {
//handle error
}

Usage as a tool

To build encoder use

	 $ make encoder
	 $ ./blurhash-encoder -xComponents 4 -yComponents 3 -path resources/pic.png
	 LaJR8MVu8_~po#smR+a~xaoLWCRj

To build decoder use

	 $ make decoder
	 $ ./blurhash-decoder -width 32 -height 32 -hash LaJR8MVu8_~po#smR+a~xaoLWCRj -result result.png
	 LaJR8MVu8_~po#smR+a~xaoLWCRj

TODO List

  • Other image formats
  • Benchmarks
  • Performance optimization

Licence

This project is licensed under the MIT License

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors