snapimage 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
@@ -120,7 +120,10 @@ module SnapImage
|
|
120
120
|
width: @request.json["crop_width"],
|
121
121
|
height: @request.json["crop_height"]
|
122
122
|
}
|
123
|
-
|
123
|
+
cropped_image = image.crop(crop[:x], crop[:y], crop[:width], crop[:height])
|
124
|
+
# Release memory.
|
125
|
+
image.destroy!
|
126
|
+
image = cropped_image
|
124
127
|
end
|
125
128
|
|
126
129
|
# Resize.
|
@@ -131,21 +134,34 @@ module SnapImage
|
|
131
134
|
if width && height
|
132
135
|
# When both width and height are specified, resize without
|
133
136
|
# maintaining the aspect ratio.
|
134
|
-
|
137
|
+
resized_image = image.resize(width, height, false)
|
135
138
|
else
|
136
139
|
# When only one of width/height is specified, set the other to the
|
137
140
|
# max and maintain the aspect ratio.
|
138
|
-
|
141
|
+
resized_image = image.resize(width || @config["max_width"], height || @config["max_height"])
|
139
142
|
end
|
143
|
+
# Release memeory.
|
144
|
+
image.destroy!
|
145
|
+
image = resized_image
|
140
146
|
end
|
141
147
|
|
142
148
|
# Resize to fit.
|
143
149
|
resized_to_fit = resize_to_fit?(image)
|
144
|
-
|
150
|
+
if resized_to_fit
|
151
|
+
resized_image = image.resize(get_max_width, get_max_height)
|
152
|
+
# Release memeory.
|
153
|
+
image.destroy!
|
154
|
+
image = resized_image
|
155
|
+
end
|
145
156
|
|
146
157
|
# Sharpen.
|
147
158
|
sharpened = sharpen?
|
148
|
-
|
159
|
+
if sharpened
|
160
|
+
sharpened_image = image.sharpen
|
161
|
+
# Release memeory.
|
162
|
+
image.destroy!
|
163
|
+
image = sharpened_image
|
164
|
+
end
|
149
165
|
|
150
166
|
# Get the dimensions at the end.
|
151
167
|
if cropped || resized || resized_to_fit || sharpened
|
@@ -102,6 +102,8 @@ module SnapImage
|
|
102
102
|
resized_image = image.resize([image.width, @config["max_width"]].min, [image.height, @config["max_height"]].min)
|
103
103
|
# Generate a new name.
|
104
104
|
resized_name = SnapImage::ImageNameUtils.get_resized_image_name(name, resized_image.width, resized_image.height)
|
105
|
+
# Release memory.
|
106
|
+
image.destroy!
|
105
107
|
end
|
106
108
|
{ image: resized_image || image, name: resized_name || name }
|
107
109
|
end
|
data/lib/snapimage/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: snapimage
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -222,7 +222,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
222
222
|
version: '0'
|
223
223
|
segments:
|
224
224
|
- 0
|
225
|
-
hash:
|
225
|
+
hash: 1856855700602355455
|
226
226
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
227
227
|
none: false
|
228
228
|
requirements:
|
@@ -231,7 +231,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
231
231
|
version: '0'
|
232
232
|
segments:
|
233
233
|
- 0
|
234
|
-
hash:
|
234
|
+
hash: 1856855700602355455
|
235
235
|
requirements: []
|
236
236
|
rubyforge_project:
|
237
237
|
rubygems_version: 1.8.23
|