Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add libvips example to readme #27

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,25 @@ Or install it yourself as:

## Usage

To generate the blurhash string from an image file, you need to read in the image pixel data yourself, for example with RMagick:
To generate the blurhash string from an image file, you need to read in the image pixel data yourself, for example with RMagick or libvips:

```ruby
# example with rmagick
require 'blurhash'
require 'rmagick'

image = Magick::ImageList.new('foo.png')

puts Blurhash.encode(image.columns, image.rows, image.export_pixels)


# example with libvips
require 'blurhash'
require 'ruby-vips'

image = Vips::Image.new_from_file('foo.png', access: :sequential)

puts Blurhash.encode(image.width, image.height, image.to_a.flatten)
```

To display the visual component once you have the blurhash string, you need another library in JavaScript, Swift, Kotlin and so on. Fore more information, see [the original blurhash repository](https://github.com/woltapp/blurhash).
Expand Down