neofiles 2.0.2 → 2.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/neofiles.rb +13 -0
- data/lib/neofiles/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3f6ec307c4477940ecef8bae9e9570b039f39d73
|
4
|
+
data.tar.gz: 521539112e2ba08f737ba2f5d607f7553ff701f8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 238f66b03f241411390c4093cc07e88c4a32147f5ac3863c7ae8f95715946717b11d9a465ed8d0db12fdc98723f23104caf969c9427d59a30d4998458a315ad1
|
7
|
+
data.tar.gz: a636696003ff1755839fde63650b788b2eedeeb0b97f0226a303d7f62260e87bd1235605db39e45051ffec498691f7d9df969f9ba8e8c21eeccf64f3ffb84021
|
data/lib/neofiles.rb
CHANGED
@@ -57,6 +57,19 @@ module Neofiles
|
|
57
57
|
# image fits into requested dimensions, no resizing will occur
|
58
58
|
return image_file_width, image_file_height if image_file_width <= width && image_file_height <= height
|
59
59
|
|
60
|
+
in_aspect = 1.0 * image_file_width / image_file_height
|
61
|
+
out_aspect = 1.0 * width / height
|
62
|
+
|
63
|
+
if in_aspect > out_aspect
|
64
|
+
# If image is more "flat", the output width will always be equal to the requested width,
|
65
|
+
# and the output height will be less than the requested height
|
66
|
+
height = nil
|
67
|
+
else
|
68
|
+
# If input image is more "stretched" vertically or its aspect ratio is equal to output aspect ratio,
|
69
|
+
# the output height will be equal to the requested height, and the output width will be less than or equal to the requested width
|
70
|
+
width = nil
|
71
|
+
end
|
72
|
+
|
60
73
|
AspectRatio.resize(image_file_width, image_file_height, width, height).map(&:to_i)
|
61
74
|
|
62
75
|
rescue
|
data/lib/neofiles/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: neofiles
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Konanykhin Ilya
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-10-
|
11
|
+
date: 2018-10-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|