insano_image_resizer 0.3.6 → 0.3.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -8,6 +8,10 @@ module InsanoImageResizer
8
8
  include Shell
9
9
  include Loggable
10
10
 
11
+ def initialize(options = {vips_path: "vips"})
12
+ @vips_path = options[:vips_path]
13
+ end
14
+
11
15
  def process(input_path, viewport_size = {}, interest_point = {}, quality = 60)
12
16
  input_properties = fetch_image_properties(input_path)
13
17
  input_has_alpha = (input_properties[:bands] == 4)
@@ -25,9 +29,9 @@ module InsanoImageResizer
25
29
  # There's actually some extra metadata we ignore here, but this seems to be
26
30
  # the only way to get width and height from VIPS.
27
31
  result = {}
28
- result[:w] = run("/usr/local/bin/vips im_header_int Xsize '#{input_path}'").to_f
29
- result[:h] = run("/usr/local/bin/vips im_header_int Ysize '#{input_path}'").to_f
30
- result[:bands] = run("/usr/local/bin/vips im_header_int Bands '#{input_path}'").to_f
32
+ result[:w] = run("#{@vips_path} im_header_int Xsize '#{input_path}'").to_f
33
+ result[:h] = run("#{@vips_path} im_header_int Ysize '#{input_path}'").to_f
34
+ result[:bands] = run("#{@vips_path} im_header_int Bands '#{input_path}'").to_f
31
35
  return result
32
36
  end
33
37
 
@@ -197,12 +201,12 @@ module InsanoImageResizer
197
201
  end
198
202
  intermediate_path = input_path[0..-4]+"_shrunk." + output_extension
199
203
 
200
- run("/usr/local/bin/vips im_shrink '#{input_path}' '#{intermediate_path}#{quality_extension}' #{shrink_factor} #{shrink_factor}")
201
- run("/usr/local/bin/vips im_affine '#{intermediate_path}' '#{output_path}#{quality_extension}' #{transform[:scale]} 0 0 #{transform[:scale]} 0 0 #{transform[:x]} #{transform[:y]} #{transform[:w]} #{transform[:h]}")
204
+ run("#{@vips_path} im_shrink '#{input_path}' '#{intermediate_path}#{quality_extension}' #{shrink_factor} #{shrink_factor}")
205
+ run("#{@vips_path} im_affine '#{intermediate_path}' '#{output_path}#{quality_extension}' #{transform[:scale]} 0 0 #{transform[:scale]} 0 0 #{transform[:x]} #{transform[:y]} #{transform[:w]} #{transform[:h]}")
202
206
  FileUtils.rm(intermediate_path)
203
207
 
204
208
  else
205
- run("/usr/local/bin/vips 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
+ 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]}")
206
210
 
207
211
  end
208
212
 
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.3.6
4
+ version: 0.3.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: