blurhash_ruby 0.0.16 → 0.0.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +2 -1
- data/README.md +5 -0
- data/benchmark.rb +20 -20
- data/blurhash_ruby.gemspec +3 -3
- data/lib/blurhash_ruby.rb +2 -2
- data/run.sh +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b40c782c4055a1b76b0ed61815b21f7c80f09efe273941f060ba3d5a31334bdb
|
4
|
+
data.tar.gz: f8d9dfc16837e1ddc3107e9cbb4225a6823135398bdab614e287d938d01c0e1c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 57c14816776f8a18d3b3512c3844585b1239bbce0411c162457126222a975b21c56638f986b7c84d1a8cf18b7e5edf6ed6df28fa8738eccb1196a84ba4560a45
|
7
|
+
data.tar.gz: 43692a7e68101214dc7a12020c9a8b5eb0050c98fbc9e7448bb79709657fd4c7d7a9176e526106c0df5b597fb6ec72789cb83f568ed3ca0cdf14cd8dd54e2151
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -31,8 +31,13 @@ BlurhashRuby.encode_image('https://cdn.pixabay.com/photo/2018/01/14/23/12/nature
|
|
31
31
|
_480.jpg')
|
32
32
|
# => "LMCFqys-0gIp-os,NHNI={s,R+I;"
|
33
33
|
|
34
|
+
# If you want to store shorter string in db and prepend data:image/png;base64, later
|
34
35
|
BlurhashRuby.decode_blurhash('LHB3~nxvjYax0Mo#o#t7-cayWBWE')
|
35
36
|
# => "iVBORw0KGgoAAAANSUhEUgAAAAQAAAACCAYAAAB/qH1jAAAALElEQVR4XmMMSUj///3bB4YfX18xfP/xkYGFjdmQ4S8bA8Pv/z8ZOFl/MgAANdoP6+z0zPQAAAAASUVORK5CYII="
|
37
|
+
|
38
|
+
# IF you want to directly generate data:image/png;base64, image - Useful for decoding on fly
|
39
|
+
BlurhashRuby.decode_blurhash('LHB3~nxvjYax0Mo#o#t7-cayWBWE', as_img: true)
|
40
|
+
# => "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAACCAYAAAB/qH1jAAAALElEQVR4XmMMSUj///3bB4YfX18xfP/xkYGFjdmQ4S8bA8Pv/z8ZOFl/MgAANdoP6+z0zPQAAAAASUVORK5CYII="
|
36
41
|
```
|
37
42
|
|
38
43
|
### Contributing
|
data/benchmark.rb
CHANGED
@@ -1,21 +1,21 @@
|
|
1
|
-
require 'benchmark'
|
2
|
-
require 'blurhash_ruby'
|
3
|
-
require 'blurhash'
|
4
|
-
require 'rmagick'
|
1
|
+
#require 'benchmark'
|
2
|
+
#require 'blurhash_ruby'
|
3
|
+
#require 'blurhash'
|
4
|
+
#require 'rmagick'
|
5
5
|
|
6
|
-
Benchmark.bm do |x|
|
7
|
-
x.report {
|
8
|
-
BlurhashRuby.encode_image('https://twilio-cms-prod.s3.amazonaws.com/images/MSjyG8qNtcrbONBpWKztYRJqSpr4R2M6K83KXW4dj05n5.width-1616.png')
|
9
|
-
}
|
10
|
-
end
|
11
|
-
|
12
|
-
Benchmark.bm do |x|
|
13
|
-
x.report {
|
14
|
-
image_url = 'https://twilio-cms-prod.s3.amazonaws.com/images/MSjyG8qNtcrbONBpWKztYRJqSpr4R2M6K83KXW4dj05n5.width-1616.png'
|
15
|
-
filename = 'in.png'
|
16
|
-
File.write filename, URI.open(image_url).read
|
17
|
-
file_path = Dir.pwd + "/#{filename}"
|
18
|
-
image = Magick::ImageList.new(file_path)
|
19
|
-
Blurhash.encode(image.columns, image.rows, image.export_pixels)
|
20
|
-
}
|
21
|
-
end
|
6
|
+
#Benchmark.bm do |x|
|
7
|
+
# x.report {
|
8
|
+
# BlurhashRuby.encode_image('https://twilio-cms-prod.s3.amazonaws.com/images/MSjyG8qNtcrbONBpWKztYRJqSpr4R2M6K83KXW4dj05n5.width-1616.png')
|
9
|
+
# }
|
10
|
+
#end
|
11
|
+
#
|
12
|
+
#Benchmark.bm do |x|
|
13
|
+
# x.report {
|
14
|
+
# image_url = 'https://twilio-cms-prod.s3.amazonaws.com/images/MSjyG8qNtcrbONBpWKztYRJqSpr4R2M6K83KXW4dj05n5.width-1616.png'
|
15
|
+
# filename = 'in.png'
|
16
|
+
# File.write filename, URI.open(image_url).read
|
17
|
+
# file_path = Dir.pwd + "/#{filename}"
|
18
|
+
# image = Magick::ImageList.new(file_path)
|
19
|
+
# Blurhash.encode(image.columns, image.rows, image.export_pixels)
|
20
|
+
# }
|
21
|
+
#end
|
data/blurhash_ruby.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'blurhash_ruby'
|
3
|
-
s.version = '0.0.
|
3
|
+
s.version = '0.0.17'
|
4
4
|
s.summary = "A fast blurhash encoder/decoder gem!"
|
5
5
|
s.description = "A fast blurhash encoder/decoder gem."
|
6
6
|
s.authors = ["Rabin Poudyal"]
|
@@ -8,7 +8,7 @@ Gem::Specification.new do |s|
|
|
8
8
|
s.files = `git ls-files`.split("\n")
|
9
9
|
s.require_paths = %w(lib)
|
10
10
|
s.homepage =
|
11
|
-
'https://
|
11
|
+
'https://github.com/trip101/ruby-blurhash'
|
12
12
|
s.license = 'MIT'
|
13
13
|
s.extensions = %w[ext/blurhash_decoder/extconf.rb ext/blurhash_encoder/extconf.rb]
|
14
|
-
end
|
14
|
+
end
|
data/lib/blurhash_ruby.rb
CHANGED
@@ -9,7 +9,7 @@ class BlurhashRuby
|
|
9
9
|
extend DECODER
|
10
10
|
extend ENCODER
|
11
11
|
|
12
|
-
def self.encode_image(image_url, x_comp
|
12
|
+
def self.encode_image(image_url, x_comp: 4, y_comp: 3)
|
13
13
|
# Usage: BlurhashRuby.encode_image('https://cdn.pixabay.com/photo/2018/01/14/23/12/nature-3082832__480.jpg')
|
14
14
|
filename = 'in.png'
|
15
15
|
File.write filename, URI.open(image_url).read
|
@@ -17,7 +17,7 @@ class BlurhashRuby
|
|
17
17
|
encode(file_path, x_comp, y_comp)
|
18
18
|
end
|
19
19
|
|
20
|
-
def self.decode_blurhash(blurhash, height
|
20
|
+
def self.decode_blurhash(blurhash, height: 2, width: 4, punch: 1, as_img: false)
|
21
21
|
# Usage: BlurhashRuby.decode_blurhash('LHB3~nxvjYax0Mo#o#t7-cayWBWE')
|
22
22
|
filename = 'out.png'
|
23
23
|
file_path = Dir.pwd + "/#{filename}"
|
data/run.sh
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blurhash_ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.17
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rabin Poudyal
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-02-
|
11
|
+
date: 2022-02-16 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A fast blurhash encoder/decoder gem.
|
14
14
|
email: rabin@trip101.com
|
@@ -38,7 +38,7 @@ files:
|
|
38
38
|
- ext/common.h
|
39
39
|
- lib/blurhash_ruby.rb
|
40
40
|
- run.sh
|
41
|
-
homepage: https://
|
41
|
+
homepage: https://github.com/trip101/ruby-blurhash
|
42
42
|
licenses:
|
43
43
|
- MIT
|
44
44
|
metadata: {}
|