easyimg_utils 0.6.3 → 0.6.4

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: f68eb15dfa8aa18281bb8b71b6ad4ac8e0da01c5da5424d981388cfdee8cae7f
4
- data.tar.gz: 10d4a0d5ad92f28723c9b4d2b025952723b8566d8cc9418e0e11191c70a407fe
3
+ metadata.gz: e12a8d7ad03689334172c8068730efef5acd22474b4f3b3a0d0f73994fa6f0c3
4
+ data.tar.gz: a2e24819dc0efd620fa16797286034f0cce333d1ef360eb6bb2e6a4b106ca36e
5
5
  SHA512:
6
- metadata.gz: c900ec2015da02a1eb2178feb88418792f19c8b806d84700931e8efa7cbdfef3cfe1144154d25b04c5fd4696e29fd4864d153a4906c8d637e57c50d08e7eca64
7
- data.tar.gz: c1bdfcc930995773ffb921ad88d261d37a91c356a21accd1f18ffbcf4997ecd7d288b2d7fd70a42e54a5f9df6195e4f78e95097281749b15b61601485a16a7a3
6
+ metadata.gz: 2d5acd5bfef69e8cec1dc304f92e440070be9412d189fee2ce6d6c2b884593d9776b1bf04978dd572d62aea372fc0f636c6bf68c5dfd5338dcafbb9742647620
7
+ data.tar.gz: 4ea3afa5a48559a84d38e7806cf7ab27b3827ffcd1f6d2ef9cfbe0240f0d06e71987e9b2ef9316a2b510f8584ad605c67aa0512e41bd973c745d9c82ede407b1
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
data/lib/easyimg_utils.rb CHANGED
@@ -56,7 +56,7 @@ class EasyImgUtils
56
56
  * animate Creates an animated gif e.g. animate('/tmp/a%d.png', '/tmp/b.gif')
57
57
  * blur # e.g. blur(x: 231, y: 123, w: 85, h: 85)
58
58
  * capture_screen # takes a screenshot of the desktop
59
- * calc_resize # e.g. EasyImgUtils.calc_resize '1449x1932', '640x480' #=> 480x640
59
+ * calc_resize # e.g. calc_resize '640x480' #=> 640x491
60
60
  * center_crop # crops from the centre of an image. Usage center_crop(width, height)
61
61
  * composite # overlay a smaller image on top of an image
62
62
  * contrast # changes the intensity between lighter and darker elements
@@ -91,12 +91,13 @@ class EasyImgUtils
91
91
  #
92
92
  def self.calc_resize(s, s2)
93
93
 
94
- a = s.split('x',2).map(&:to_i).sort
95
- a2 = s2.split('x',2).map(&:to_i).sort
96
-
97
- factor = a2.last / a.last.to_f
98
-
99
- a.map {|x| (x * factor).to_i}.join('x')
94
+ a = s.split('x',2).map(&:to_i)
95
+ a2 = s2.split('x',2).map(&:to_i)
96
+ i = a.index a.max
97
+
98
+ factor = a2[i] / a[i].to_f
99
+
100
+ s3 = a.map {|x| (x * factor).round}.join('x')
100
101
 
101
102
  end
102
103
 
@@ -184,6 +185,12 @@ class EasyImgUtils
184
185
  end
185
186
  end
186
187
 
188
+ # calculates the new geometry after a resize
189
+ #
190
+ def calc_resize(geometry)
191
+ EasyImgUtils.calc_resize(info()[:geometry], geometry)
192
+ end
193
+
187
194
  def capture_screen(quality: nil)
188
195
 
189
196
  # defaults (silent=false, frame=false, descend=false,
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: easyimg_utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.3
4
+ version: 0.6.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
metadata.gz.sig CHANGED
Binary file