Class: WebP::Options
- Inherits:
-
Object
- Object
- WebP::Options
- Defined in:
- lib/webp/options.rb
Instance Method Summary collapse
- #decode_pointer ⇒ Object
- #encode_pointer ⇒ Object
-
#initialize(options) ⇒ Options
constructor
A new instance of Options.
Constructor Details
#initialize(options) ⇒ Options
Returns a new instance of Options.
4 5 6 |
# File 'lib/webp/options.rb', line 4 def initialize() @user_options = end |
Instance Method Details
#decode_pointer ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/webp/options.rb', line 26 def decode_pointer = FFI::MemoryPointer.new :char, C::FfiWebpDecodeConfig.size, false = C::FfiWebpDecodeConfig.new decode_default() # options if @user_options[:output_format] && [:png, :pam, :ppm, :pgm, :bmp, :tiff, :yuv, :alpha_plane_only].include?(@user_options[:output_format]) [:output_format] = C::OutputFileFormat[@user_options[:output_format]] end [:bypass_filtering, :no_fancy_upsampling, :use_threads].each do |key| [key] = 1 if @user_options[key] && true == @user_options[key] end [:crop_x, :crop_y, :crop_w, :crop_h, :resize_w, :resize_h].each do |key| [key] = @user_options[key] if @user_options[key] end end |
#encode_pointer ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/webp/options.rb', line 8 def encode_pointer = FFI::MemoryPointer.new :char, C::FfiWebpEncodeConfig.size, false = C::FfiWebpEncodeConfig.new [:lossless, :near_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| [key] = @user_options[key] ? @user_options[key] : -1 end encode_default() [:quality, :crop_x, :crop_y, :crop_w, :crop_h, :resize_w, :resize_h].each do |key| [key] = @user_options[key] if @user_options[key] end end |