active_analysis 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 75cde4e32a958cb79b87b7c333a4cb39fb3bd6be937c00bb4c8cd2e2012741b2
4
- data.tar.gz: 1729529848f522024d7ce5774dab64344b7efe70358ab832793fa992e6bc6c2a
3
+ metadata.gz: d9bd54c9d6b6579f5419244bdce0170c10889efc633d363b2a9be8129335b0bf
4
+ data.tar.gz: bea8aa7a1e0f5c8d716c6d9eb2c3d253f5a1be3cb461484c16b5e281f47cd6bd
5
5
  SHA512:
6
- metadata.gz: 1a9ccbaeb56aad39604101559f9ec0909d551d315714ccf5b3313be824aa6a46138a67bb96404e426864bc7868e971890a76c4e95279bc0967571128e87d1975
7
- data.tar.gz: 7b43f43265abaa0adb94b4722b1cf26cb74a9d20de9b103b0a706df906960dd7ec2c5f5f701572d75a05503b1058c41c50c9baf2b97bde3b5728d272b661de7a
6
+ metadata.gz: 402b15df181ac8bc2f583e70d9f856d7b7a9271493883a5ee9b7998aa890cb15c771f68e5be12028b4bfca29bf2514886fd09d841106cba88bed50975067dedb
7
+ data.tar.gz: f35aa5ac09d2f3294512541733f38d5fa649c82994c685d26d92f9dd94f6f6e15a83fda66affae7553b7028fb1878542586242d524124f8afa6a8d226052e52a
data/CHANGELOG.md CHANGED
@@ -1,6 +1,10 @@
1
1
  ## [Unreleased]
2
2
 
3
- ## [0.2] - 2021-05-01
3
+ ## [0.3] - 2021-06-17
4
+
5
+ - Added addons feature
6
+
7
+ ## [0.2] - 2021-06-01
4
8
 
5
9
  - Added `opaque` metadata value to images
6
10
 
@@ -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 <= 50
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 #{file.path} #{image.path}`
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(file.path)
36
- basename = File.basename(file.path, extname)
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(file.path, destination: tempfile.path)
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
-
@@ -9,7 +9,7 @@ module ActiveAnalysis
9
9
  module VERSION
10
10
  MAJOR = 0
11
11
  MINOR = 3
12
- TINY = 0
12
+ TINY = 1
13
13
  PRE = nil
14
14
 
15
15
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
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.0
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-17 00:00:00.000000000 Z
11
+ date: 2021-06-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activestorage