Class: Blurhash
- Inherits:
-
Object
- Object
- Blurhash
- Defined in:
- lib/blurhash_ruby.rb
Class Method Summary collapse
- .decode(blurhash, height = 2, width = 4, punch = 1, as_img = false) ⇒ Object
- .encode(image_url, x_comp = 4, y_comp = 3) ⇒ Object
Class Method Details
.decode(blurhash, height = 2, width = 4, punch = 1, as_img = false) ⇒ Object
10 11 12 13 14 |
# File 'lib/blurhash_ruby.rb', line 10 def self.decode(blurhash, height = 2, width = 4, punch = 1, as_img = false) # Usage: Blurhash.decode('LHB3~nxvjYax0Mo#o#t7-cayWBWE') hash = BlurhashDecoder.new.decode_blurhash(blurhash, height, width, punch) as_img ? 'data:image/png;base64,' + hash : hash end |
.encode(image_url, x_comp = 4, y_comp = 3) ⇒ Object
5 6 7 8 |
# File 'lib/blurhash_ruby.rb', line 5 def self.encode(image_url, x_comp = 4, y_comp = 3) # Usage: Blurhash.encode('https://cdn.pixabay.com/photo/2018/01/14/23/12/nature-3082832__480.jpg') BlurhashEncoder.new.blurhash(image_url, x_comp, y_comp) end |