shrine-blurhash 0.0.1 → 0.1.0
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/README.md +7 -1
- data/lib/shrine/plugins/blurhash.rb +9 -2
- data/shrine-blurhash.gemspec +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9f4650238faaadb15dffee5a1ac789edb8be01357bd46591d2cb4fbab32890d1
|
|
4
|
+
data.tar.gz: e1f9853635ccd673feacad7ab25d8a36a632ffeba564911c653e4fa32bb97039
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2ef4077470e95bed536756b304d175a9650bf34b2a2061cc6d8e731560cfdd2e5e5240600181b5a522f4fb454a2b943ad8a62d9314b0bc442663ffbe2ed0c969
|
|
7
|
+
data.tar.gz: 382ab14aef4378e3fa1797fa1937bf254efb052443b8a15f274e0e776cc5062e8f1c3019c47c4d85f070c6fe97d1f626ae1c56f5b0c03f609c44746a33d9aeb0
|
data/README.md
CHANGED
|
@@ -44,7 +44,7 @@ end
|
|
|
44
44
|
|
|
45
45
|
### ```components```
|
|
46
46
|
|
|
47
|
-
Type: `[components_x, components_y]`
|
|
47
|
+
Type: `[components_x, components_y]` or a `Proc`
|
|
48
48
|
Default: `[4, 3]`
|
|
49
49
|
|
|
50
50
|
```ruby
|
|
@@ -53,6 +53,12 @@ plugin :blurhash, components: [2, 2]
|
|
|
53
53
|
|
|
54
54
|
This allows you to customize the number of components on each axis for the Blurhash algorithm. The visual result will look like a grid of `X * Y` blurred colors.
|
|
55
55
|
|
|
56
|
+
You can also pass a proc which receive the width and height and calculate the components on-the-fly:
|
|
57
|
+
|
|
58
|
+
```ruby
|
|
59
|
+
plugin :blurhash, components: ->(width, height) { [width / 600, height / 600] }
|
|
60
|
+
```
|
|
61
|
+
|
|
56
62
|
### `resize_to`
|
|
57
63
|
|
|
58
64
|
Type: `Integer` or `nil`
|
|
@@ -46,8 +46,8 @@ class Shrine
|
|
|
46
46
|
blurhash = instrument_blurhash(io) do
|
|
47
47
|
pixels = extractor.call(*args)
|
|
48
48
|
|
|
49
|
-
|
|
50
|
-
::Blurhash.encode(pixels[:width], pixels[:height], pixels[:pixels], x_comp:
|
|
49
|
+
x_comp, y_comp = components_for(pixels[:width], pixels[:height])
|
|
50
|
+
::Blurhash.encode(pixels[:width], pixels[:height], pixels[:pixels], x_comp: x_comp, y_comp: y_comp)
|
|
51
51
|
end
|
|
52
52
|
|
|
53
53
|
io.rewind
|
|
@@ -73,6 +73,13 @@ class Shrine
|
|
|
73
73
|
|
|
74
74
|
private
|
|
75
75
|
|
|
76
|
+
def components_for(width, height)
|
|
77
|
+
if opts[:blurhash][:components].respond_to?(:call)
|
|
78
|
+
opts[:blurhash][:components].call(width, height)
|
|
79
|
+
else opts[:blurhash][:components]
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
76
83
|
# Sends a `blurhash.shrine` event for instrumentation plugin.
|
|
77
84
|
def instrument_blurhash(io, &block)
|
|
78
85
|
return yield unless respond_to?(:instrument)
|
data/shrine-blurhash.gemspec
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: shrine-blurhash
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0
|
|
4
|
+
version: 0.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Renaud Chaput
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2022-03-28 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: blurhash
|
|
@@ -80,7 +80,7 @@ dependencies:
|
|
|
80
80
|
- - ">="
|
|
81
81
|
- !ruby/object:Gem::Version
|
|
82
82
|
version: '0'
|
|
83
|
-
description:
|
|
83
|
+
description:
|
|
84
84
|
email:
|
|
85
85
|
- renchap@gmail.com
|
|
86
86
|
executables: []
|
|
@@ -94,7 +94,7 @@ homepage: https://github.com/renchap/shrine-blurhash
|
|
|
94
94
|
licenses:
|
|
95
95
|
- MIT
|
|
96
96
|
metadata: {}
|
|
97
|
-
post_install_message:
|
|
97
|
+
post_install_message:
|
|
98
98
|
rdoc_options: []
|
|
99
99
|
require_paths:
|
|
100
100
|
- lib
|
|
@@ -109,8 +109,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
109
109
|
- !ruby/object:Gem::Version
|
|
110
110
|
version: '0'
|
|
111
111
|
requirements: []
|
|
112
|
-
rubygems_version: 3.
|
|
113
|
-
signing_key:
|
|
112
|
+
rubygems_version: 3.3.7
|
|
113
|
+
signing_key:
|
|
114
114
|
specification_version: 4
|
|
115
115
|
summary: Shrine plugin to compute Blurhash on image attachments
|
|
116
116
|
test_files: []
|