webp-ffi 0.1.4 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG.md +4 -0
- data/lib/webp/version.rb +1 -1
- data/lib/webp/webp.rb +12 -8
- data/spec/webp_ffi_spec.rb +8 -8
- metadata +3 -3
data/CHANGELOG.md
CHANGED
data/lib/webp/version.rb
CHANGED
data/lib/webp/webp.rb
CHANGED
@@ -29,18 +29,18 @@ module WebP
|
|
29
29
|
|
30
30
|
# encode
|
31
31
|
def encode(input_file, output_file, options = {})
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
32
|
+
unless 0 == (encode_res = C.webp_encode(input_file, output_file, init_options_object(options).encode_pointer))
|
33
|
+
raise EncoderError, ENCODER_ERRORS[encode_res - 1]
|
34
|
+
end
|
35
|
+
true
|
36
36
|
end
|
37
37
|
|
38
38
|
# decode
|
39
39
|
def decode(input_file, output_file, options = {})
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
40
|
+
unless 0 == (decode_res = C.webp_decode(input_file, output_file, init_options_object(options).decode_pointer))
|
41
|
+
raise DecoderError, DECODER_ERRORS[decode_res - 1]
|
42
|
+
end
|
43
|
+
true
|
44
44
|
end
|
45
45
|
|
46
46
|
private
|
@@ -53,5 +53,9 @@ module WebP
|
|
53
53
|
pointers
|
54
54
|
end
|
55
55
|
|
56
|
+
def init_options_object(options)
|
57
|
+
Options.new options
|
58
|
+
end
|
59
|
+
|
56
60
|
end
|
57
61
|
end
|
data/spec/webp_ffi_spec.rb
CHANGED
@@ -36,9 +36,9 @@ describe WebP do
|
|
36
36
|
end
|
37
37
|
after :all do
|
38
38
|
@out_dir = File.expand_path(File.join(File.dirname(__FILE__), "../tmp/"))
|
39
|
-
|
40
|
-
|
41
|
-
|
39
|
+
Dir["#{@out_dir}/*{.png,.webp}"].each do |file|
|
40
|
+
File.delete(file) rescue nil
|
41
|
+
end
|
42
42
|
end
|
43
43
|
|
44
44
|
it "calculate plus 100 by test_c (verify C)" do
|
@@ -117,7 +117,7 @@ describe WebP do
|
|
117
117
|
it "#{image}.png image" do
|
118
118
|
in_filename = File.expand_path(File.join(File.dirname(__FILE__), "factories/#{image}.png"))
|
119
119
|
out_filename = File.expand_path(File.join(@out_dir, "#{image}.invpng.webp"))
|
120
|
-
expect { WebP.encode(in_filename, out_filename, crop_w: 30000) }.to raise_error WebP::EncoderError
|
120
|
+
expect { WebP.encode(in_filename, out_filename, crop_w: 30000) }.to raise_error WebP::EncoderError, /crop/i
|
121
121
|
end
|
122
122
|
end
|
123
123
|
end
|
@@ -161,16 +161,16 @@ describe WebP do
|
|
161
161
|
it "#{image}.png image" do
|
162
162
|
in_filename = File.expand_path(File.join(File.dirname(__FILE__), "factories/#{image}.png"))
|
163
163
|
out_filename = File.expand_path(File.join(@out_dir, "#{image}.invpng.webp"))
|
164
|
-
expect { WebP.decode(in_filename, out_filename) }.to raise_error WebP::DecoderError
|
164
|
+
expect { WebP.decode(in_filename, out_filename) }.to raise_error WebP::DecoderError, /invalid webp/i
|
165
165
|
end
|
166
166
|
end
|
167
167
|
end
|
168
168
|
context "raise DecoderError on invalid options" do
|
169
169
|
factories[:png].each do |image|
|
170
170
|
it "#{image}.png image" do
|
171
|
-
in_filename = File.expand_path(File.join(File.dirname(__FILE__), "factories/#{image}.
|
172
|
-
out_filename = File.expand_path(File.join(@out_dir, "#{image}.
|
173
|
-
expect { WebP.decode(in_filename, out_filename, crop_w: 30000) }.to raise_error WebP::DecoderError
|
171
|
+
in_filename = File.expand_path(File.join(File.dirname(__FILE__), "factories/#{image}.webp"))
|
172
|
+
out_filename = File.expand_path(File.join(@out_dir, "#{image}.png"))
|
173
|
+
expect { WebP.decode(in_filename, out_filename, crop_w: 30000) }.to raise_error WebP::DecoderError, /decoding failed/i
|
174
174
|
end
|
175
175
|
end
|
176
176
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: webp-ffi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -149,7 +149,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
149
149
|
version: '0'
|
150
150
|
segments:
|
151
151
|
- 0
|
152
|
-
hash: -
|
152
|
+
hash: -4206358326221874067
|
153
153
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
154
154
|
none: false
|
155
155
|
requirements:
|
@@ -158,7 +158,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
158
158
|
version: '0'
|
159
159
|
segments:
|
160
160
|
- 0
|
161
|
-
hash: -
|
161
|
+
hash: -4206358326221874067
|
162
162
|
requirements: []
|
163
163
|
rubyforge_project:
|
164
164
|
rubygems_version: 1.8.25
|