active_analysis 0.3.0 → 0.3.1
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d9bd54c9d6b6579f5419244bdce0170c10889efc633d363b2a9be8129335b0bf
|
4
|
+
data.tar.gz: bea8aa7a1e0f5c8d716c6d9eb2c3d253f5a1be3cb461484c16b5e281f47cd6bd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 402b15df181ac8bc2f583e70d9f856d7b7a9271493883a5ee9b7998aa890cb15c771f68e5be12028b4bfca29bf2514886fd09d841106cba88bed50975067dedb
|
7
|
+
data.tar.gz: f35aa5ac09d2f3294512541733f38d5fa649c82994c685d26d92f9dd94f6f6e15a83fda66affae7553b7028fb1878542586242d524124f8afa6a8d226052e52a
|
data/CHANGELOG.md
CHANGED
@@ -15,7 +15,7 @@ module ActiveAnalysis
|
|
15
15
|
loop do
|
16
16
|
new_quality = quality - 5
|
17
17
|
dssim = calculate_dssim(new_quality)
|
18
|
-
break if dssim > 0.001 || quality
|
18
|
+
break if dssim > 0.001 || quality < 55
|
19
19
|
quality = new_quality
|
20
20
|
end
|
21
21
|
|
@@ -26,24 +26,27 @@ module ActiveAnalysis
|
|
26
26
|
|
27
27
|
def calculate_dssim(quality)
|
28
28
|
image_with_quality(quality) do |image|
|
29
|
-
dssim = `dssim #{
|
29
|
+
dssim = `dssim #{filepath} #{image.path}`
|
30
30
|
Float dssim.split.first
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
34
|
def image_with_quality(quality)
|
35
|
-
extname = File.extname(
|
36
|
-
basename = File.basename(
|
35
|
+
extname = File.extname(filepath)
|
36
|
+
basename = File.basename(filepath, extname)
|
37
37
|
|
38
38
|
Tempfile.create(["#{basename}_#{quality}", extname]) do |tempfile|
|
39
|
-
processor.apply(saver: { format: "jpg", quality: quality }).call(
|
39
|
+
processor.apply(saver: { format: "jpg", quality: quality }).call(filepath, destination: tempfile.path)
|
40
40
|
yield tempfile
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
|
+
def filepath
|
45
|
+
ActiveAnalysis.image_library == :vips ? file.filename : file.path
|
46
|
+
end
|
47
|
+
|
44
48
|
def processor
|
45
49
|
ActiveAnalysis.image_library == :vips ? ::ImageProcessing::Vips : ::ImageProcessing::MiniMagick
|
46
50
|
end
|
47
51
|
end
|
48
52
|
end
|
49
|
-
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_analysis
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Breno Gazzola
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-06-
|
11
|
+
date: 2021-06-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activestorage
|