blurhash

Version, currently 0.1.02 versions

github.com/Sija/blurhash.cr

A pure Crystal implementation of BlurHash algorithm

27 stars
0 dependents
License: MIT

Nothing has been indexed for 0.1.0 yet. The tag is recorded, its shard.yml has not been read, so the manifest and dependency list below are empty because they are unknown rather than because they are absent.

Installation

# Add this to your shard.yml
dependencies:
  blurhash:
    github: Sija/blurhash.cr
    version: ~> 0.1.0

Then run:

shards install

shard.yml

No shard.yml has been indexed for 0.1.0. You can read it on the repository.

Dependencies

Unknown: the shard.yml for this version has not been read yet.

README

This README is the one indexed from the repository at its latest ref, not from the tag for this version.

# blurhash.cr [![CI](https://github.com/Sija/blurhash.cr/actions/workflows/ci.yml/badge.svg)](https://github.com/Sija/blurhash.cr/actions/workflows/ci.yml) [![Releases](https://img.shields.io/github/release/Sija/blurhash.cr.svg)](https://github.com/Sija/blurhash.cr/releases) [![License](https://img.shields.io/github/license/Sija/blurhash.cr.svg)](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