diff --git a/CHANGELOG.md b/CHANGELOG.md index 6e64ebe..adeb707 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## v0.2.1 + +* Fix output for bmp, tiff and yuv + ## v0.2.0 * Checked and fixed for webp 0.4.0 diff --git a/lib/webp/options.rb b/lib/webp/options.rb index 3ca17fa..0b512fe 100644 --- a/lib/webp/options.rb +++ b/lib/webp/options.rb @@ -1,59 +1,59 @@ module WebP class Options - + def initialize(options) @user_options = options end - + def encode_pointer options_pointer = FFI::MemoryPointer.new :char, C::FfiWebpEncodeConfig.size, false options_struct = C::FfiWebpEncodeConfig.new options_pointer - [:lossless, :method, :target_size, :target_PSNR, :segments, - :sns_strength, :filter_strength, :filter_sharpness, - :filter_type, :autofilter, :alpha_compression, :alpha_filtering, - :alpha_quality, :pass, :show_compressed, :preprocessing, :partitions, + [:lossless, :method, :target_size, :target_PSNR, :segments, + :sns_strength, :filter_strength, :filter_sharpness, + :filter_type, :autofilter, :alpha_compression, :alpha_filtering, + :alpha_quality, :pass, :show_compressed, :preprocessing, :partitions, :partition_limit, :width, :height].each do |key| options_struct[key] = @user_options[key] ? @user_options[key] : -1 end encode_default(options_struct) - [:quality, :crop_x, :crop_y, :crop_w, + [:quality, :crop_x, :crop_y, :crop_w, :crop_h, :resize_w, :resize_h].each do |key| options_struct[key] = @user_options[key] if @user_options[key] end options_pointer end - + def decode_pointer options_pointer = FFI::MemoryPointer.new :char, C::FfiWebpDecodeConfig.size, false options_struct = C::FfiWebpDecodeConfig.new options_pointer decode_default(options_struct) # options - if @user_options[:output_format] && [:png, :pam, :ppm, :pgm, :alpha_plane_only].include?(@user_options[:output_format]) + if @user_options[:output_format] && [:png, :pam, :ppm, :pgm, :bmp, :tiff, :yuv, :alpha_plane_only].include?(@user_options[:output_format]) options_struct[:output_format] = C::OutputFileFormat[@user_options[:output_format]] end [:bypass_filtering, :no_fancy_upsampling, :use_threads].each do |key| options_struct[key] = 1 if @user_options[key] && true == @user_options[key] end - [:crop_x, :crop_y, :crop_w, + [:crop_x, :crop_y, :crop_w, :crop_h, :resize_w, :resize_h].each do |key| options_struct[key] = @user_options[key] if @user_options[key] end options_pointer end - + private def encode_default(options_struct) options_struct[:quality] = 100 similar_default(options_struct) end - + def decode_default(options_struct) # default format is png options_struct[:output_format] = C::OutputFileFormat[:png] similar_default(options_struct) end - + def similar_default(options_struct) options_struct[:crop_x] = options_struct[:crop_y] = 0 options_struct[:crop_w] = options_struct[:crop_h] = 0 diff --git a/lib/webp/version.rb b/lib/webp/version.rb index 14b347c..d78c1c1 100644 --- a/lib/webp/version.rb +++ b/lib/webp/version.rb @@ -1,3 +1,3 @@ module WebP - VERSION = "0.2.0" + VERSION = "0.2.1" end