neofiles 1.2.1 → 1.2.2
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 +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5e933a90f0875b8daf85f331a22fb6625f671dbb
|
4
|
+
data.tar.gz: 73851322957bfc79951825f9b2f588e0bec9875b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b593c8017570ccca9615a6ca2820b2a3181f8e7fb79fdcffc090d0c684e38f078e6484017937603c06643bf7fd2ddeb8c0c3ad4ea05a78a96b9e5cc551705679
|
7
|
+
data.tar.gz: 1cdb3f6e73c224040a4cb1f36db92fd4cf13e4b35e47dba8db8efa95252ff724e1c88c2502cbab41e19979482556876c6d86666021688d55113bf13f145d77a7
|
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