pura-image 0.2.2 → 0.2.3
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/lib/pura/image/operations.rb +4 -4
- data/lib/pura/image/railtie.rb +29 -31
- data/lib/pura/image/version.rb +1 -1
- data/pura-image.gemspec +3 -4
- data/test/fixtures/test_64x64.jpg +0 -0
- metadata +4 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a6561b3b8ec72933d8b01613638ae8e767e3948c402831bf8f401c9985525990
|
|
4
|
+
data.tar.gz: 386ef6ed67ed028cb82e630859826b7c4d43689c93923b96141febd65b0f0cfd
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 82d791ee984e2d7d014ac2a3f62c8cbfa9ad59135b2a06c0c10d2ca86ae401c57ac271520a1828a590f251a1f8e8bc51748dd8e09b41d766dbe9aad00c3c6b8b
|
|
7
|
+
data.tar.gz: 65cd7a61332dd414f53f3f12366c23844292b955ac5e032675871af36e68c5a96de54c7d84d2c40df26680768d0e794b8e8c977295fec53cf5e634c5292211b6
|
|
@@ -19,7 +19,7 @@ module Pura
|
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
def grayscale
|
|
22
|
-
new_pixels = String.new(encoding: Encoding::BINARY
|
|
22
|
+
new_pixels = String.new(encoding: Encoding::BINARY)
|
|
23
23
|
i = 0
|
|
24
24
|
size = @pixels.bytesize
|
|
25
25
|
while i < size
|
|
@@ -98,7 +98,7 @@ module Pura
|
|
|
98
98
|
def rotate90
|
|
99
99
|
new_w = @height
|
|
100
100
|
new_h = @width
|
|
101
|
-
new_pixels = String.new(encoding: Encoding::BINARY
|
|
101
|
+
new_pixels = String.new(encoding: Encoding::BINARY)
|
|
102
102
|
|
|
103
103
|
new_h.times do |y|
|
|
104
104
|
new_w.times do |x|
|
|
@@ -111,7 +111,7 @@ module Pura
|
|
|
111
111
|
end
|
|
112
112
|
|
|
113
113
|
def rotate180
|
|
114
|
-
new_pixels = String.new(encoding: Encoding::BINARY
|
|
114
|
+
new_pixels = String.new(encoding: Encoding::BINARY)
|
|
115
115
|
(@height - 1).downto(0) do |y|
|
|
116
116
|
(@width - 1).downto(0) do |x|
|
|
117
117
|
offset = ((y * @width) + x) * 3
|
|
@@ -124,7 +124,7 @@ module Pura
|
|
|
124
124
|
def rotate270
|
|
125
125
|
new_w = @height
|
|
126
126
|
new_h = @width
|
|
127
|
-
new_pixels = String.new(encoding: Encoding::BINARY
|
|
127
|
+
new_pixels = String.new(encoding: Encoding::BINARY)
|
|
128
128
|
|
|
129
129
|
new_h.times do |y|
|
|
130
130
|
new_w.times do |x|
|
data/lib/pura/image/railtie.rb
CHANGED
|
@@ -1,50 +1,48 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
# Only define railtie if Rails is available
|
|
4
|
+
if defined?(Rails)
|
|
4
5
|
require "rails/railtie"
|
|
5
|
-
rescue LoadError
|
|
6
|
-
# Rails is not available, skip railtie functionality
|
|
7
|
-
return
|
|
8
|
-
end
|
|
9
6
|
|
|
10
|
-
module Pura
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
7
|
+
module Pura
|
|
8
|
+
module Image
|
|
9
|
+
class Railtie < Rails::Railtie
|
|
10
|
+
initializer "pura_image.set_variant_processor", before: "active_storage.configs" do |app|
|
|
11
|
+
app.config.active_storage.variant_processor = :pura
|
|
12
|
+
end
|
|
16
13
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
initializer "pura_image.patch_active_storage_variation" do
|
|
15
|
+
ActiveSupport.on_load(:active_storage_blob) do
|
|
16
|
+
require "image_processing/pura"
|
|
20
17
|
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
variation_patch = Module.new do
|
|
19
|
+
private
|
|
23
20
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
21
|
+
def transformer
|
|
22
|
+
if ActiveStorage.variant_processor == :pura && ActiveStorage.variant_transformer.nil?
|
|
23
|
+
@pura_transformer ||= begin
|
|
24
|
+
klass = Class.new(ActiveStorage::Transformers::ImageProcessingTransformer) do
|
|
25
|
+
private
|
|
29
26
|
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
def processor
|
|
28
|
+
ImageProcessing::Pura
|
|
29
|
+
end
|
|
32
30
|
end
|
|
33
|
-
end
|
|
34
31
|
|
|
35
|
-
|
|
32
|
+
klass.new(transformations.except(:format))
|
|
33
|
+
end
|
|
34
|
+
else
|
|
35
|
+
super
|
|
36
36
|
end
|
|
37
|
-
else
|
|
38
|
-
super
|
|
39
37
|
end
|
|
40
38
|
end
|
|
41
|
-
end
|
|
42
39
|
|
|
43
|
-
|
|
44
|
-
|
|
40
|
+
unless ActiveStorage::Variation.ancestors.include?(variation_patch)
|
|
41
|
+
ActiveStorage::Variation.prepend(variation_patch)
|
|
42
|
+
end
|
|
45
43
|
end
|
|
46
44
|
end
|
|
47
45
|
end
|
|
48
46
|
end
|
|
49
47
|
end
|
|
50
|
-
end
|
|
48
|
+
end
|
data/lib/pura/image/version.rb
CHANGED
data/pura-image.gemspec
CHANGED
|
@@ -13,12 +13,12 @@ Gem::Specification.new do |spec|
|
|
|
13
13
|
"with image_processing gem compatible API for Rails Active Storage."
|
|
14
14
|
spec.homepage = "https://github.com/komagata/pura-image"
|
|
15
15
|
spec.license = "MIT"
|
|
16
|
-
spec.required_ruby_version = ">= 3.
|
|
16
|
+
spec.required_ruby_version = ">= 3.2.0"
|
|
17
17
|
|
|
18
18
|
spec.metadata["homepage_uri"] = spec.homepage
|
|
19
19
|
spec.metadata["source_code_uri"] = spec.homepage
|
|
20
20
|
|
|
21
|
-
spec.files = Dir["lib/**/*.rb"] + ["pura-image.gemspec", "Gemfile", "Rakefile", "README.md", "LICENSE"]
|
|
21
|
+
spec.files = Dir["lib/**/*.rb"] + ["test/fixtures/test_64x64.jpg"] + ["pura-image.gemspec", "Gemfile", "Rakefile", "README.md", "LICENSE"]
|
|
22
22
|
|
|
23
23
|
spec.add_dependency "pura-jpeg", "~> 0.1"
|
|
24
24
|
spec.add_dependency "pura-png", "~> 0.1"
|
|
@@ -26,8 +26,7 @@ Gem::Specification.new do |spec|
|
|
|
26
26
|
spec.add_dependency "pura-gif", "~> 0.1"
|
|
27
27
|
spec.add_dependency "pura-tiff", "~> 0.1"
|
|
28
28
|
spec.add_dependency "pura-ico", "~> 0.1"
|
|
29
|
-
|
|
30
|
-
spec.add_development_dependency "image_processing", "~> 1.2"
|
|
29
|
+
spec.add_dependency "image_processing", "~> 1.2"
|
|
31
30
|
spec.add_development_dependency "minitest", "~> 5.0"
|
|
32
31
|
spec.add_development_dependency "rake", "~> 13.0"
|
|
33
32
|
end
|
|
Binary file
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: pura-image
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- komagata
|
|
@@ -100,7 +100,7 @@ dependencies:
|
|
|
100
100
|
- - "~>"
|
|
101
101
|
- !ruby/object:Gem::Version
|
|
102
102
|
version: '1.2'
|
|
103
|
-
type: :
|
|
103
|
+
type: :runtime
|
|
104
104
|
prerelease: false
|
|
105
105
|
version_requirements: !ruby/object:Gem::Requirement
|
|
106
106
|
requirements:
|
|
@@ -154,6 +154,7 @@ files:
|
|
|
154
154
|
- lib/pura/image/railtie.rb
|
|
155
155
|
- lib/pura/image/version.rb
|
|
156
156
|
- pura-image.gemspec
|
|
157
|
+
- test/fixtures/test_64x64.jpg
|
|
157
158
|
homepage: https://github.com/komagata/pura-image
|
|
158
159
|
licenses:
|
|
159
160
|
- MIT
|
|
@@ -167,7 +168,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
167
168
|
requirements:
|
|
168
169
|
- - ">="
|
|
169
170
|
- !ruby/object:Gem::Version
|
|
170
|
-
version: 3.
|
|
171
|
+
version: 3.2.0
|
|
171
172
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
172
173
|
requirements:
|
|
173
174
|
- - ">="
|