easyimg_utils 0.7.3 → 0.7.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: 2b1dfaea58127ef88f5b78e46e00146d925b9cc9e05c7c8836d9d934a9cb87b5
4
- data.tar.gz: d54061b87a0864110935762bfcd8558552fdaf0e925b3446aa1c22667a8ef41f
3
+ metadata.gz: 491f7066a8af2e40049a6986c894498d507d99b2b02caf4321f59abb25a05dd1
4
+ data.tar.gz: e6d42410ed62a4a0829c648b5622b28845930fa18853202e6ac507d0e7e34186
5
5
  SHA512:
6
- metadata.gz: c66d8a62d782f4a1535df8351984c05701c6bfb0868cc42c266983054de86b70dc1238888108aa0492bd689d27b3485058fee7c1fe57175c495bc4bcad884c92
7
- data.tar.gz: c1ddf021ed6e85154dc13d3b1dbcc59c47d8bac8066acbd8502d5f4704aa7296b3d713e0b9171c796e6bbe4e4530684d1e3c8d1bfe83c73aac055535cb6e6304
6
+ metadata.gz: 57a595c6b1b171e44600bcdd043a36f90ce89453fc5d57e40fd8016a5f6518be8753c247bd613b2e5318ee6db05ababb9735a0c47b928775b96a4ef5bd99dac0
7
+ data.tar.gz: aa6f56c7307732c2f4f93f2298d32d0e2de8d164a2cee099f5ebdc18e433bccb162e43c5b3bd2e4ad9d2c87d0398c131531d10dcceb8099bbce4873d19d5fd19
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
data/lib/easyimg_utils.rb CHANGED
@@ -94,20 +94,35 @@ class EasyImgUtils
94
94
 
95
95
  # e.g. calc_resize '1449x1932', '640x480' #=> 480x640
96
96
  # e.g. calc_resize '518x1024', '*518x500' #=> "518x1024"
97
- # the asterisk denotes a guaranteed the image will be resized using x or y
97
+ # the asterisk denotes a guarantee the image will be resized to a
98
+ # minimum size on either dimension
98
99
  #
99
- def self.calc_resize(geometry, new_geometry, force: false)
100
+ # e.g. calc_resize '1920x1088', '*518x*500' #=> "882x500"
101
+ # 2 asterisks denotes a guaranteed minumum size on both dimensions
102
+ #
103
+ def self.calc_resize(geometry, new_geometry)
100
104
 
101
105
  xy = geometry.split('x',2)
102
106
  xy2 = new_geometry.split('x',2)
103
107
 
104
108
  # find any locked geometry which guarantees the resize on either x or y
105
- lock = xy2.find {|x| x =~ /^\*/}
109
+ locks = xy2.select {|x| x =~ /^\*/}
106
110
 
107
111
  a = xy.map {|x| x[/\d+/].to_i}
108
112
  a2 = xy2.map {|x| x[/\d+/].to_i}
113
+
114
+ i = if locks.length > 1 then
109
115
 
110
- i = lock ? a2.index(lock[1..-1].to_i) : a.index(a.max)
116
+ a.index(a.min)
117
+
118
+ elsif locks.any?
119
+
120
+ lock = locks.first
121
+ a2.index(lock[1..-1].to_i)
122
+
123
+ else
124
+ a.index(a.max)
125
+ end
111
126
 
112
127
  factor = a2[i] / a[i].to_f
113
128
 
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.7.3
4
+ version: 0.7.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -35,7 +35,7 @@ cert_chain:
35
35
  KY48n99T12IOioQ4ghCO1L/UAg2taLOcZbMv4WpV1p9bXKhnrow81zeogZjjiNGS
36
36
  OmTAjCfyGFPC/1eXnSV5Smv8
37
37
  -----END CERTIFICATE-----
38
- date: 2021-03-24 00:00:00.000000000 Z
38
+ date: 2021-03-30 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: rmagick
metadata.gz.sig CHANGED
Binary file