neofiles 2.0.1 → 2.0.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 +2 -13
- data/lib/neofiles/version.rb +1 -1
- metadata +18 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 270d63f7c55f16dd7bc9899c7fe4f0c0ced9fbd3
|
4
|
+
data.tar.gz: af060e4083f09b0493566075f3ea34d6d17f225b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4bca497d608747f6f563cf6421a816251157b9d4736ae88d021cd5f5718fcb7139288d2127e1cb328cf3045c06b5caf40634b83f79b088e7455496134de9b5a6
|
7
|
+
data.tar.gz: 33a681aedf0cb58571f7cb97ca9fe90e3d51dc4e100adbd117d16f37640edca738f5ff75a30132d1fe0b5df36f6d49428028e18e0206488af3cf4cf67b8f814e
|
data/lib/neofiles.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'neofiles/engine'
|
2
|
+
require 'aspect_ratio'
|
2
3
|
|
3
4
|
module Neofiles
|
4
5
|
# Attach Neofiles specific routes in your routes.rb file:
|
@@ -34,8 +35,6 @@ module Neofiles
|
|
34
35
|
# width, height - max width and height after resize
|
35
36
|
# resize_options - {crop: '1'/'0'}, @see Neofiles::ImagesController#show
|
36
37
|
#
|
37
|
-
# Can call ImageMagick.
|
38
|
-
#
|
39
38
|
def resized_image_dimensions(image_file, width, height, resize_options)
|
40
39
|
# dimensions are equal to requested ones if cropping
|
41
40
|
return width, height if crop_requested? resize_options
|
@@ -58,17 +57,7 @@ module Neofiles
|
|
58
57
|
# image fits into requested dimensions, no resizing will occur
|
59
58
|
return image_file_width, image_file_height if image_file_width <= width && image_file_height <= height
|
60
59
|
|
61
|
-
|
62
|
-
command = MiniMagick::CommandBuilder.new(:convert) # convert input file...
|
63
|
-
command.size([image_file_width, image_file_height].join 'x') # with the given dimensions...
|
64
|
-
command.xc('white') # and filled with whites...
|
65
|
-
command.resize([width, height].join 'x') # to fit in the given rectangle...
|
66
|
-
command.push('info:-') # return info about the resulting file
|
67
|
-
|
68
|
-
# ... and send it to ImageMagick
|
69
|
-
# the result will be: xc:white XC 54x100 54x100+0+0 16-bit DirectClass 0.070u 0:00.119
|
70
|
-
# extract dimensions and return them as array of integers
|
71
|
-
MiniMagick::Image.new(nil, nil).run(command).match(/ (\d+)x(\d+) /).values_at(1, 2).map(&:to_i)
|
60
|
+
AspectRatio.resize(image_file_width, image_file_height, width, height).map(&:to_i)
|
72
61
|
|
73
62
|
rescue
|
74
63
|
nil
|
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.2
|
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-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -86,14 +86,28 @@ dependencies:
|
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
89
|
+
version: '3'
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
96
|
+
version: '3'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: aspect_ratio
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
97
111
|
description: 'Library for managing files: creating & storing, linking to file owners,
|
98
112
|
serving files from MongoDB'
|
99
113
|
email:
|