Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,9 @@ Worker has no options
* `:max_colors` — Maximum number of colors to use *(defaults to `256`)*
* `:quality` — min..max - don't save below min, use less colors below max (both in range `0..100`; in yaml - `!ruby/range 0..100`), ignored in default/lossless mode *(defaults to `100..100`, `0..100` in lossy mode)*
* `:speed` — speed/quality trade-off: `1` - slow, `3` - default, `11` - fast & rough *(defaults to `3`)*
* `:floyd` - Set dithering level using fractional number between 0 (none) and 1 (full, the default)
* `:nofs` - Disable Floyd-Steinberg dithering *(defaults to `false`)*
* `:strip` - Remove optional chunks (metadata) from PNG files *(defaults to `false`)*

### svgo:
* `:disable_plugins` — List of plugins to disable *(defaults to `[]`)*
Expand Down
22 changes: 21 additions & 1 deletion lib/image_optim/worker/pngquant.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,22 @@ class Pngquant < Worker
OptionHelpers.limit_with_range(v.to_i, 1..11)
end

# NOFS_OPTION =
option(:nofs, false, 'Disable Floyd-Steinberg dithering') do |v|
v ? '--nofs' : ''
end

# FLOYD_OPTION =
option(:floyd, false, 'Set dithering level using fractional number '\
'between 0 (none) and 1 (full, the default)') do |v|
v ? "--floyd=#{v}" : ''
end

# STRIP_OPTION =
option(:strip, false, 'Remove optional chunks (metadata) from PNG files') do |v|
v ? '--strip' : ''
end

def run_order
-2
end
Expand All @@ -57,10 +73,14 @@ def optimize(src, dst, options = {})
--output=#{dst}
--skip-if-larger
--force
#{nofs}
#{floyd}
#{strip}
#{max_colors}
--
#{src}
]
].reject(&:empty?)

execute(:pngquant, args, options) && optimized?(src, dst)
end
end
Expand Down