blurhash

Pure Crystal implementation of BlurHash algorithm blurhash image placeholder
0.1.1 Latest release released

blurhash.cr CI Releases License

A pure Crystal implementation of Blurhash. The API is stable, however the hashing function in either direction may not be.

Blurhash is an algorithm written by Dag Ågren for Wolt (woltapp/blurhash) that encodes an image into a short (~20-30 byte) ASCII string. When you decode the string back into an image, you get a gradient of colors that represent the original image. This can be useful for scenarios where you want an image placeholder before loading, or even to censor the contents of an image à la Mastodon.

Currently supports PNG and JPEG file types.

Installation

Library

  1. Add the dependency to your shard.yml:

    dependencies:
      blurhash:
        github: Sija/blurhash.cr
    
  2. Run shards install

CLI

  1. Run shards build --release

Usage

Library

require "blurhash"

puts Blurhash.encode(
  x_components: 4,
  y_components: 3,
  path: Path["foo.png"]
)

CLI

$ ./bin/blurhash 4 3 foo.png

Contributing

  1. Fork it (https://github.com/Sija/blurhash.cr/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors

blurhash:
  github: Sija/blurhash.cr
  version: ~> 0.1.1
License MIT
Crystal ~> 1.6

Authors

Dependencies 2

  • stumpy_jpeg master
    {'branch' => 'master', 'github' => 'stumpycr/stumpy_jpeg'}
  • stumpy_png master
    {'branch' => 'master', 'github' => 'stumpycr/stumpy_png'}

Development Dependencies 1

  • ameba ~> 1.6.0
    {'github' => 'crystal-ameba/ameba', 'version' => '~> 1.6.0'}

Dependents 0

Last synced .
search fire star recently