insano_image_resizer 0.4.3 → 0.4.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -179,6 +179,28 @@ module InsanoImageResizer
179
179
  quality_extension = ":#{quality}"
180
180
  end
181
181
 
182
+ # find the EXIF values
183
+ orientation = 0
184
+ begin
185
+ orientation = EXIFR::JPEG.new(input_path).orientation.to_i
186
+ rescue
187
+ orientation = 0
188
+ end
189
+
190
+ if orientation == 3 || orientation == 6 || orientation == 8
191
+ o_transform = []
192
+ if orientation == 3
193
+ run("#{@vips_path} im_rot180 '#{input_path}' '#{output_path}#{quality_extension}'")
194
+ elsif orientation == 6
195
+ run("#{@vips_path} im_rot90 '#{input_path}' '#{output_path}#{quality_extension}'")
196
+ elsif orientation == 8
197
+ run("#{@vips_path} im_rot270 '#{input_path}' '#{output_path}#{quality_extension}'")
198
+ end
199
+ FileUtils.rm(input_path)
200
+ FileUtils.mv(output_path, input_path)
201
+ run("mogrify -strip #{output_path}")
202
+ end
203
+
182
204
  if (transform[:scale] < 0.5)
183
205
  # If we're shrinking the image by more than a factor of two, let's do a two-pass operation. The reason we do this
184
206
  # is that the interpolators, such as bilinear and bicubic, don't produce very good results when scaling an image
@@ -208,28 +230,6 @@ module InsanoImageResizer
208
230
  run("#{@vips_path} im_affine '#{input_path}' '#{output_path}#{quality_extension}' #{transform[:scale]} 0 0 #{transform[:scale]} 0 0 #{transform[:x]} #{transform[:y]} #{transform[:w]} #{transform[:h]}")
209
231
  end
210
232
 
211
- # find the EXIF values
212
- orientation = 0
213
- begin
214
- orientation = EXIFR::JPEG.new(input_path).orientation.to_i
215
- rescue
216
- orientation = 0
217
- end
218
-
219
- if orientation == 3 || orientation == 6 || orientation == 8
220
- FileUtils.mv(output_path, intermediate_path)
221
- o_transform = []
222
- if orientation == 3
223
- run("#{@vips_path} im_rot180 '#{intermediate_path}' '#{output_path}#{quality_extension}'")
224
- elsif orientation == 6
225
- run("#{@vips_path} im_rot90 '#{intermediate_path}' '#{output_path}#{quality_extension}'")
226
- elsif orientation == 8
227
- run("#{@vips_path} im_rot270 '#{intermediate_path}' '#{output_path}#{quality_extension}'")
228
- end
229
- FileUtils.rm(intermediate_path)
230
- run("mogrify -strip #{output_path}")
231
- end
232
-
233
233
  FileUtils.rm(input_path)
234
234
  return output_path
235
235
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: insano_image_resizer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3
4
+ version: 0.4.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: