blurhash 0.1.5 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/gempush.yml +3 -16
- data/CHANGELOG.md +9 -0
- data/Gemfile.lock +2 -4
- data/Rakefile +1 -2
- data/blurhash.gemspec +0 -2
- data/ext/blurhash/encode.c +20 -0
- data/ext/blurhash/extconf.rb +2 -1
- data/lib/blurhash/version.rb +1 -1
- data/lib/blurhash.rb +4 -12
- metadata +4 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8b20f7dc194fc64dd01eb87018cf0b5d8ea946df2d8cef51b1b9af5a9a959a6e
|
4
|
+
data.tar.gz: 2f918982c095b65fe40d4b9c21d93375cd20ab7fe046369b494daea34966220d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 75960b20bab150322ff70bdac7a971583feacb3462e11b60f6cf9214631bb2b41fb47f64397b0ffbf1e044a5743d4706b6a70aa0ec2464bb6b9afd391c0893bf
|
7
|
+
data.tar.gz: bc3218e7b8da39367702976b208505b603ef0cd765783ba00c4f9c2713cbe95f92204b87fb8cfee10449b49a7f06cb5e70b229ecdc5261b3bca0caf26a9b350f
|
@@ -1,6 +1,7 @@
|
|
1
1
|
name: Ruby Gem
|
2
2
|
|
3
3
|
on:
|
4
|
+
workflow_dispatch:
|
4
5
|
push:
|
5
6
|
tags:
|
6
7
|
- v*
|
@@ -12,23 +13,9 @@ jobs:
|
|
12
13
|
|
13
14
|
steps:
|
14
15
|
- uses: actions/checkout@master
|
15
|
-
-
|
16
|
-
uses: actions/setup-ruby@v1
|
16
|
+
- uses: ruby/setup-ruby@v1.137.0
|
17
17
|
with:
|
18
|
-
version:
|
19
|
-
|
20
|
-
- name: Publish to GPR
|
21
|
-
run: |
|
22
|
-
mkdir -p $HOME/.gem
|
23
|
-
touch $HOME/.gem/credentials
|
24
|
-
chmod 0600 $HOME/.gem/credentials
|
25
|
-
printf -- "---\n:github: Bearer ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
|
26
|
-
gem build *.gemspec
|
27
|
-
gem push --KEY github --host https://rubygems.pkg.github.com/${OWNER} *.gem
|
28
|
-
env:
|
29
|
-
GEM_HOST_API_KEY: ${{secrets.GPR_AUTH_TOKEN}}
|
30
|
-
OWNER: Gargron
|
31
|
-
|
18
|
+
ruby-version: '3.0'
|
32
19
|
- name: Publish to RubyGems
|
33
20
|
run: |
|
34
21
|
mkdir -p $HOME/.gem
|
data/CHANGELOG.md
ADDED
data/Gemfile.lock
CHANGED
@@ -1,14 +1,12 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
blurhash (0.1.
|
5
|
-
ffi (~> 1.14)
|
4
|
+
blurhash (0.1.7)
|
6
5
|
|
7
6
|
GEM
|
8
7
|
remote: https://rubygems.org/
|
9
8
|
specs:
|
10
9
|
diff-lcs (1.4.4)
|
11
|
-
ffi (1.14.2)
|
12
10
|
rake (13.0.3)
|
13
11
|
rake-compiler (1.1.1)
|
14
12
|
rake
|
@@ -37,4 +35,4 @@ DEPENDENCIES
|
|
37
35
|
rspec (~> 3.0)
|
38
36
|
|
39
37
|
BUNDLED WITH
|
40
|
-
2.
|
38
|
+
2.3.23
|
data/Rakefile
CHANGED
data/blurhash.gemspec
CHANGED
@@ -21,8 +21,6 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.require_paths = ['lib']
|
22
22
|
spec.extensions = ['ext/blurhash/extconf.rb']
|
23
23
|
|
24
|
-
spec.add_dependency 'ffi', '~> 1.14'
|
25
|
-
|
26
24
|
spec.add_development_dependency 'bundler', '~> 2.0'
|
27
25
|
spec.add_development_dependency 'rake', '~> 13.0'
|
28
26
|
spec.add_development_dependency 'rake-compiler'
|
data/ext/blurhash/encode.c
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
#include <string.h>
|
4
4
|
#include <math.h>
|
5
|
+
#include <ruby.h>
|
5
6
|
|
6
7
|
#ifndef M_PI
|
7
8
|
#define M_PI 3.14159265358979323846
|
@@ -135,3 +136,22 @@ static char *encode_int(int value, int length, char *destination) {
|
|
135
136
|
}
|
136
137
|
return destination;
|
137
138
|
}
|
139
|
+
|
140
|
+
VALUE rb_blur_hash_for_pixels(VALUE m, VALUE x_comp, VALUE y_comp, VALUE width, VALUE height, VALUE p)
|
141
|
+
{
|
142
|
+
const char * buf = blurHashForPixels(NUM2INT(x_comp),
|
143
|
+
NUM2INT(y_comp),
|
144
|
+
NUM2INT(width),
|
145
|
+
NUM2INT(height),
|
146
|
+
(uint8_t *)StringValuePtr(p),
|
147
|
+
NUM2INT(width) * 3);
|
148
|
+
|
149
|
+
return rb_str_new2(buf);
|
150
|
+
}
|
151
|
+
|
152
|
+
void Init_blurhash_ext()
|
153
|
+
{
|
154
|
+
VALUE mBlurhash = rb_define_module("Blurhash");
|
155
|
+
VALUE mUnstable = rb_define_module_under(mBlurhash, "Unstable");
|
156
|
+
rb_define_singleton_method(mUnstable, "blurHashForPixels", rb_blur_hash_for_pixels, 5);
|
157
|
+
}
|
data/ext/blurhash/extconf.rb
CHANGED
data/lib/blurhash/version.rb
CHANGED
data/lib/blurhash.rb
CHANGED
@@ -1,14 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'blurhash/version'
|
4
|
-
require '
|
4
|
+
require 'blurhash_ext'
|
5
5
|
|
6
6
|
module Blurhash
|
7
7
|
def self.encode(width, height, pixels, x_comp: 4, y_comp: 3)
|
8
|
-
|
9
|
-
|
10
|
-
return Unstable.blurHashForPixels(x_comp, y_comp, width, height, p, width * 3)
|
11
|
-
end
|
8
|
+
p = pixels.pack("C#{pixels.size}")
|
9
|
+
return Unstable.blurHashForPixels(x_comp, y_comp, width, height, p)
|
12
10
|
end
|
13
11
|
|
14
12
|
def self.components(str)
|
@@ -21,12 +19,6 @@ module Blurhash
|
|
21
19
|
[x_comp, y_comp]
|
22
20
|
end
|
23
21
|
|
24
|
-
module Unstable
|
25
|
-
extend FFI::Library
|
26
|
-
ffi_lib File.join(File.expand_path(File.dirname(__FILE__)), '..', 'ext', 'blurhash', 'encode.' + RbConfig::CONFIG['DLEXT'])
|
27
|
-
attach_function :blurHashForPixels, %i(int int int int pointer size_t), :string
|
28
|
-
end
|
29
|
-
|
30
22
|
module Base83
|
31
23
|
DIGIT_CHARACTERS = %w(
|
32
24
|
0 1 2 3 4 5 6 7 8 9
|
@@ -35,7 +27,7 @@ module Blurhash
|
|
35
27
|
U V W X Y Z a b c d
|
36
28
|
e f g h i j k l m n
|
37
29
|
o p q r s t u v w x
|
38
|
-
y z # $ % * +
|
30
|
+
y z # $ % * + , - .
|
39
31
|
: ; = ? @ [ ] ^ _ {
|
40
32
|
| } ~
|
41
33
|
).freeze
|
metadata
CHANGED
@@ -1,29 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blurhash
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eugen Rochko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-02-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: ffi
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '1.14'
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "~>"
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '1.14'
|
27
13
|
- !ruby/object:Gem::Dependency
|
28
14
|
name: bundler
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|
@@ -92,6 +78,7 @@ files:
|
|
92
78
|
- ".gitignore"
|
93
79
|
- ".rspec"
|
94
80
|
- ".travis.yml"
|
81
|
+
- CHANGELOG.md
|
95
82
|
- CODE_OF_CONDUCT.md
|
96
83
|
- Gemfile
|
97
84
|
- Gemfile.lock
|
@@ -125,7 +112,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
125
112
|
- !ruby/object:Gem::Version
|
126
113
|
version: '0'
|
127
114
|
requirements: []
|
128
|
-
rubygems_version: 3.
|
115
|
+
rubygems_version: 3.2.33
|
129
116
|
signing_key:
|
130
117
|
specification_version: 4
|
131
118
|
summary: Encode an image as a small string that can saved in the database and used
|