blurhash
Version, currently 0.1.12 versions
- 0.1.1latestMar 4, 2024
- 0.1.0not indexedMar 4, 2024
github.com/Sija/blurhash.cr
A pure Crystal implementation of BlurHash algorithm
27 stars
0 dependents
License: MIT
Installation
# Add this to your shard.yml
dependencies:
blurhash:
github: Sija/blurhash.cr
version: ~> 0.1.1Then run:
shards installshard.yml
- Crystal
~> 1.6- License
- MIT
- Author
- Sijawusz Pur Rahnama <sija@sija.pl>
- Target
blurhashfrom src/cli.cr
Dependencies
Runtime Dependencies
- stumpy_png*github: stumpycr/stumpy_png, branch: master
- stumpy_jpeg*github: stumpycr/stumpy_jpeg, branch: master
Development Dependencies
- ameba~> 1.6.0github: crystal-ameba/amebadev
README
# blurhash.cr [](https://github.com/Sija/blurhash.cr/actions/workflows/ci.yml) [](https://github.com/Sija/blurhash.cr/releases) [](https://github.com/Sija/blurhash.cr/blob/master/LICENSE)
A pure Crystal implementation of [Blurhash](https://github.com/woltapp/blurhash). The API is stable, however the hashing function in either direction may not be.
Blurhash is an algorithm written by [Dag Ågren](https://github.com/DagAgren) for [Wolt (woltapp/blurhash)](https://github.com/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](https://blog.joinmastodon.org/2019/05/improving-support-for-adult-content-on-mastodon/).
Currently supports `PNG` and `JPEG` file types.
## Installation
### Library
1. Add the dependency to your `shard.yml`:
```yaml
dependencies:
blurhash:
github: Sija/blurhash.cr
```
2. Run `shards install`
### CLI
1. Run `shards build --release`
## Usage
### Library
```crystal
require "blurhash"
puts Blurhash.encode(
x_components: 4,
y_components: 3,
path: Path["foo.png"]
)
```
### CLI
```console
$ ./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
- [Sijawusz Pur Rahnama](https://github.com/Sija) - creator and maintainer
Documentation
Built from the current release. The first visit to a release nobody has asked for starts its build.
Links
This release
- Version
0.1.1- Tagged
- Mar 4, 2024
- Commit
f78014804cee- Crystal
~> 1.6- Indexed
- yes
Dependents
No indexed shard depends on this one yet.
Repository
github.com/Sija/blurhash.cr
Metadata
- Created
- Aug 12, 2026
- Updated
- Aug 12, 2026
- Synced
- Aug 12, 2026
- Versions
- 2