scene7-wrapper 0.3.2 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/scene7/crop.rb +9 -6
- data/scene7-wrapper.gemspec +1 -1
- data/spec/scene7/crop_spec.rb +1 -1
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.3
|
data/lib/scene7/crop.rb
CHANGED
@@ -7,18 +7,21 @@ module Scene7
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def self.format_url_params(params)
|
10
|
-
|
10
|
+
require 'cgi' unless defined?(CGI) && defined?(CGI::escape)
|
11
|
+
|
12
|
+
basic = "scl=#{params.delete(:scale_factor)}&crop=#{params.delete(:x).round},#{params.delete(:y).round},#{params.delete(:width).round},#{params.delete(:height).round}&qlt=#{params.delete(:quality)}"
|
13
|
+
basic << params.map {|k, v| "#{k}=#{CGI.escape(v.to_s)}" }.join('&')
|
11
14
|
end
|
12
15
|
|
13
16
|
def self.convert_params_from_scale_first(orig_params, additional_params = {})
|
14
17
|
{}.tap do |params|
|
15
18
|
scale_factor = orig_params[:scale_factor].to_f
|
16
19
|
params[:scale_factor] = 1.0 / scale_factor
|
17
|
-
params[:height] = orig_params[:height].to_f / scale_factor
|
18
|
-
params[:width] = orig_params[:width].to_f / scale_factor
|
19
|
-
params[:x] = orig_params[:x].to_f / scale_factor
|
20
|
-
params[:y] = orig_params[:y].to_f / scale_factor
|
21
|
-
params[:quality] = orig_params[:quality]
|
20
|
+
params[:height] = (orig_params[:height].to_f / scale_factor).round
|
21
|
+
params[:width] = (orig_params[:width].to_f / scale_factor).round
|
22
|
+
params[:x] = (orig_params[:x].to_f / scale_factor).round
|
23
|
+
params[:y] = (orig_params[:y].to_f / scale_factor).round
|
24
|
+
params[:quality] = orig_params[:quality] || 95
|
22
25
|
end.merge!(additional_params)
|
23
26
|
end
|
24
27
|
end
|
data/scene7-wrapper.gemspec
CHANGED
data/spec/scene7/crop_spec.rb
CHANGED
@@ -13,7 +13,7 @@ describe Scene7::Crop do
|
|
13
13
|
} }
|
14
14
|
|
15
15
|
it 'includes the scale and scale factor and defaults the quality to 95' do
|
16
|
-
subject.format_url_params(params).should == "scl=0.5&crop=50,100,250,150&qlt=
|
16
|
+
subject.format_url_params(params).should == "scl=0.5&crop=50,100,250,150&qlt="
|
17
17
|
end
|
18
18
|
|
19
19
|
context "when quality is specified" do
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scene7-wrapper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 3
|
10
|
+
version: 0.3.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Brian Rose
|