insano_image_resizer 0.4.1 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,6 @@
1
1
  require 'yaml'
2
2
  require 'shellwords'
3
+ require 'exifr'
3
4
 
4
5
  module InsanoImageResizer
5
6
  class Processor
@@ -207,6 +208,27 @@ module InsanoImageResizer
207
208
  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]}")
208
209
  end
209
210
 
211
+ # find the EXIF values
212
+ orientation = 0
213
+ if input_path[-3..-1] == 'jpg'
214
+ orientation = EXIFR::JPEG.new(input_path).orientation.to_i
215
+ end
216
+ log.debug('Orientation flag: ' + orientation.to_s)
217
+
218
+ if orientation == 3 || orientation == 6 || orientation == 8
219
+ FileUtils.mv(output_path, intermediate_path)
220
+ o_transform = []
221
+ if orientation == 3
222
+ run("#{@vips_path} im_rot180 '#{intermediate_path}' '#{output_path}#{quality_extension}'")
223
+ elsif orientation == 6
224
+ run("#{@vips_path} im_rot90 '#{intermediate_path}' '#{output_path}#{quality_extension}'")
225
+ elsif orientation == 8
226
+ run("#{@vips_path} im_rot270 '#{intermediate_path}' '#{output_path}#{quality_extension}'")
227
+ end
228
+ FileUtils.rm(intermediate_path)
229
+ run("mogrify -strip #{output_path}")
230
+ end
231
+
210
232
  FileUtils.rm(input_path)
211
233
  return output_path
212
234
  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.1
4
+ version: 0.4.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: