webp-ffi 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/CHANGELOG.md +4 -0
- data/lib/webp/options.rb +13 -13
- data/lib/webp/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7745e9bcd09baff6c5ffe977eaf00e2ff078a628
|
4
|
+
data.tar.gz: b948b1fa7ac70829b4ec1a95a19072aec525165f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 249cff2c45f5e988acedff8bd63226f8ad3ab845e97919281a4774b608ae17c16ba5451b3f8702de1bac5554c7bdfaf32ab82e69839ed92f96cb32a4223a1702
|
7
|
+
data.tar.gz: 17e4db3fd151581ade623b92d406f0c4477d4c0980255897ea8e9be660bad97562f8fa6952e2937e42029d58f03c0f79c11d559adf4666cbc02f3f95d29932c9
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/lib/webp/options.rb
CHANGED
@@ -1,59 +1,59 @@
|
|
1
1
|
module WebP
|
2
2
|
class Options
|
3
|
-
|
3
|
+
|
4
4
|
def initialize(options)
|
5
5
|
@user_options = options
|
6
6
|
end
|
7
|
-
|
7
|
+
|
8
8
|
def encode_pointer
|
9
9
|
options_pointer = FFI::MemoryPointer.new :char, C::FfiWebpEncodeConfig.size, false
|
10
10
|
options_struct = C::FfiWebpEncodeConfig.new options_pointer
|
11
|
-
[:lossless, :method, :target_size, :target_PSNR, :segments,
|
12
|
-
:sns_strength, :filter_strength, :filter_sharpness,
|
13
|
-
:filter_type, :autofilter, :alpha_compression, :alpha_filtering,
|
14
|
-
:alpha_quality, :pass, :show_compressed, :preprocessing, :partitions,
|
11
|
+
[:lossless, :method, :target_size, :target_PSNR, :segments,
|
12
|
+
:sns_strength, :filter_strength, :filter_sharpness,
|
13
|
+
:filter_type, :autofilter, :alpha_compression, :alpha_filtering,
|
14
|
+
:alpha_quality, :pass, :show_compressed, :preprocessing, :partitions,
|
15
15
|
:partition_limit, :width, :height].each do |key|
|
16
16
|
options_struct[key] = @user_options[key] ? @user_options[key] : -1
|
17
17
|
end
|
18
18
|
encode_default(options_struct)
|
19
|
-
[:quality, :crop_x, :crop_y, :crop_w,
|
19
|
+
[:quality, :crop_x, :crop_y, :crop_w,
|
20
20
|
:crop_h, :resize_w, :resize_h].each do |key|
|
21
21
|
options_struct[key] = @user_options[key] if @user_options[key]
|
22
22
|
end
|
23
23
|
options_pointer
|
24
24
|
end
|
25
|
-
|
25
|
+
|
26
26
|
def decode_pointer
|
27
27
|
options_pointer = FFI::MemoryPointer.new :char, C::FfiWebpDecodeConfig.size, false
|
28
28
|
options_struct = C::FfiWebpDecodeConfig.new options_pointer
|
29
29
|
decode_default(options_struct)
|
30
30
|
# options
|
31
|
-
if @user_options[:output_format] && [:png, :pam, :ppm, :pgm, :alpha_plane_only].include?(@user_options[:output_format])
|
31
|
+
if @user_options[:output_format] && [:png, :pam, :ppm, :pgm, :bmp, :tiff, :yuv, :alpha_plane_only].include?(@user_options[:output_format])
|
32
32
|
options_struct[:output_format] = C::OutputFileFormat[@user_options[:output_format]]
|
33
33
|
end
|
34
34
|
[:bypass_filtering, :no_fancy_upsampling, :use_threads].each do |key|
|
35
35
|
options_struct[key] = 1 if @user_options[key] && true == @user_options[key]
|
36
36
|
end
|
37
|
-
[:crop_x, :crop_y, :crop_w,
|
37
|
+
[:crop_x, :crop_y, :crop_w,
|
38
38
|
:crop_h, :resize_w, :resize_h].each do |key|
|
39
39
|
options_struct[key] = @user_options[key] if @user_options[key]
|
40
40
|
end
|
41
41
|
options_pointer
|
42
42
|
end
|
43
|
-
|
43
|
+
|
44
44
|
private
|
45
45
|
|
46
46
|
def encode_default(options_struct)
|
47
47
|
options_struct[:quality] = 100
|
48
48
|
similar_default(options_struct)
|
49
49
|
end
|
50
|
-
|
50
|
+
|
51
51
|
def decode_default(options_struct)
|
52
52
|
# default format is png
|
53
53
|
options_struct[:output_format] = C::OutputFileFormat[:png]
|
54
54
|
similar_default(options_struct)
|
55
55
|
end
|
56
|
-
|
56
|
+
|
57
57
|
def similar_default(options_struct)
|
58
58
|
options_struct[:crop_x] = options_struct[:crop_y] = 0
|
59
59
|
options_struct[:crop_w] = options_struct[:crop_h] = 0
|
data/lib/webp/version.rb
CHANGED