blurhash 0.1.6 → 0.1.8
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 -4
- 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 +1 -4
- data/lib/blurhash/version.rb +1 -1
- data/lib/blurhash.rb +5 -11
- metadata +3 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 07712bc76961884962616ca6f121e3494f12e1d88f480f6b30557edb6b999019
|
4
|
+
data.tar.gz: 86488722517bdf4913fafddeba721b1ac03177ec1b734609634475cd9136d875
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 44bfe3fea7b2a9ad4f59d9d6437d093256ccfa1bd002fea0aac0fb95c71106b4534f90a9ff67e08c5f62b171eef7f997d2912a2c9435b54da1beeb5cfd6fe5a3
|
7
|
+
data.tar.gz: 8034dd5a8c647858918a0d49c75bddc7dafdb5456d1e0374510e5a4fa2dd3177e7a88fa22412c28001067eceb707947bc851c9679c0c5a57e9aaa6b9e755bdab
|
@@ -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,11 +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
|
-
ruby-version:
|
19
|
-
|
18
|
+
ruby-version: '3.0'
|
20
19
|
- name: Publish to RubyGems
|
21
20
|
run: |
|
22
21
|
mkdir -p $HOME/.gem
|
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.8)
|
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,14 @@
|
|
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
|
-
|
11
|
-
|
8
|
+
raise 'Pixels array has wrong size' if pixels.size != width * height * 3
|
9
|
+
|
10
|
+
p = pixels.pack("C#{pixels.size}")
|
11
|
+
return Unstable.blurHashForPixels(x_comp, y_comp, width, height, p)
|
12
12
|
end
|
13
13
|
|
14
14
|
def self.components(str)
|
@@ -21,12 +21,6 @@ module Blurhash
|
|
21
21
|
[x_comp, y_comp]
|
22
22
|
end
|
23
23
|
|
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
24
|
module Base83
|
31
25
|
DIGIT_CHARACTERS = %w(
|
32
26
|
0 1 2 3 4 5 6 7 8 9
|
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.8
|
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: 2024-09-26 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
|
@@ -126,7 +112,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
126
112
|
- !ruby/object:Gem::Version
|
127
113
|
version: '0'
|
128
114
|
requirements: []
|
129
|
-
rubygems_version: 3.
|
115
|
+
rubygems_version: 3.5.16
|
130
116
|
signing_key:
|
131
117
|
specification_version: 4
|
132
118
|
summary: Encode an image as a small string that can saved in the database and used
|