From 63a42379112f2e1956d6e6cd46f2e8522f6f2516 Mon Sep 17 00:00:00 2001 From: Dirceu Pauka Junior Date: Wed, 13 Oct 2021 22:10:17 -0300 Subject: [PATCH 1/7] New Version --- image_optim.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/image_optim.gemspec b/image_optim.gemspec index e4cb9ee6..6a849b44 100644 --- a/image_optim.gemspec +++ b/image_optim.gemspec @@ -2,7 +2,7 @@ Gem::Specification.new do |s| s.name = 'image_optim' - s.version = '0.31.0' + s.version = '0.32.0' s.summary = %q{Command line tool and ruby interface to optimize (lossless compress, optionally lossy) jpeg, png, gif and svg images using external utilities (advpng, gifsicle, jhead, jpeg-recompress, jpegoptim, jpegrescan, jpegtran, optipng, oxipng, pngcrush, pngout, pngquant, svgo)} s.homepage = "https://github.com/toy/#{s.name}" s.authors = ['Ivan Kuchin'] From ac57b1771c4a41c27568b9c82357618afb7f516e Mon Sep 17 00:00:00 2001 From: Dirceu Pauka Junior Date: Wed, 13 Oct 2021 22:10:30 -0300 Subject: [PATCH 2/7] Add More Options --- lib/image_optim/worker/pngquant.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/image_optim/worker/pngquant.rb b/lib/image_optim/worker/pngquant.rb index f69e2870..51c10f76 100644 --- a/lib/image_optim/worker/pngquant.rb +++ b/lib/image_optim/worker/pngquant.rb @@ -46,6 +46,17 @@ class Pngquant < Worker OptionHelpers.limit_with_range(v.to_i, 1..11) end + option(:nofs, false, 'Disable Floyd-Steinberg dithering') do |v| + v ? '--nofs' : '' + end + option(:floyd, false, 'Set dithering level using fractional number '\ + 'between 0 (none) and 1 (full, the default)') do |v| + v ? "--floyd=#{v}" : '' + end + option(:strip, false, 'Remove optional chunks (metadata) from PNG files') do |v| + v ? '--strip' : '' + end + def run_order -2 end @@ -57,6 +68,9 @@ def optimize(src, dst, options = {}) --output=#{dst} --skip-if-larger --force + #{nofs} + #{floyd} + #{strip} #{max_colors} -- #{src} From 3f0d01d3cbb643338e617b3567360a87513acdf9 Mon Sep 17 00:00:00 2001 From: Dirceu Pauka Junior Date: Wed, 13 Oct 2021 22:35:26 -0300 Subject: [PATCH 3/7] Update README --- README.markdown | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.markdown b/README.markdown index bb8bd0fa..50486407 100644 --- a/README.markdown +++ b/README.markdown @@ -353,6 +353,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* +* `:strip` - Remove optional chunks (metadata) from PNG files* ### svgo: * `:disable_plugins` — List of plugins to disable *(defaults to `[]`)* From bb210dfc365efaea2967652447f04a524f10fcb3 Mon Sep 17 00:00:00 2001 From: Dirceu Pauka Junior Date: Wed, 13 Oct 2021 22:36:26 -0300 Subject: [PATCH 4/7] Fix Typo In README Update --- README.markdown | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.markdown b/README.markdown index 50486407..5ba6aa6b 100644 --- a/README.markdown +++ b/README.markdown @@ -353,9 +353,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* -* `:strip` - Remove optional chunks (metadata) from PNG files* +* `:floyd` - Set dithering level using fractional number between 0 (none) and 1 (full, the default) +* `:nofs` - Disable Floyd-Steinberg dithering +* `:strip` - Remove optional chunks (metadata) from PNG files ### svgo: * `:disable_plugins` — List of plugins to disable *(defaults to `[]`)* From 217788418c02456709307af7802de4b6610c34b1 Mon Sep 17 00:00:00 2001 From: Dirceu Pauka Junior Date: Wed, 13 Oct 2021 22:39:44 -0300 Subject: [PATCH 5/7] Add Default To New Options --- README.markdown | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.markdown b/README.markdown index 5ba6aa6b..bd94c5c3 100644 --- a/README.markdown +++ b/README.markdown @@ -354,8 +354,8 @@ Worker has no options * `: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 -* `:strip` - Remove optional chunks (metadata) from PNG files +* `: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 `[]`)* From d406e614c9f9364e5cb92d99a97efe4d05ff60f6 Mon Sep 17 00:00:00 2001 From: Dirceu Pauka Junior Date: Fri, 15 Oct 2021 15:17:51 -0300 Subject: [PATCH 6/7] Fix Command Line Issue --- lib/image_optim/worker/pngquant.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/image_optim/worker/pngquant.rb b/lib/image_optim/worker/pngquant.rb index 51c10f76..bf29e4be 100644 --- a/lib/image_optim/worker/pngquant.rb +++ b/lib/image_optim/worker/pngquant.rb @@ -46,13 +46,18 @@ 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 @@ -74,7 +79,8 @@ def optimize(src, dst, options = {}) #{max_colors} -- #{src} - ] + ].reject(&:empty?) + execute(:pngquant, args, options) && optimized?(src, dst) end end From d590078fff50db16431bf62a59bb4008b51e0096 Mon Sep 17 00:00:00 2001 From: Dirceu Pauka Junior Date: Fri, 22 Oct 2021 18:41:02 -0300 Subject: [PATCH 7/7] Use Same Version As Master --- image_optim.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/image_optim.gemspec b/image_optim.gemspec index 6a849b44..40ef33e7 100644 --- a/image_optim.gemspec +++ b/image_optim.gemspec @@ -2,7 +2,7 @@ Gem::Specification.new do |s| s.name = 'image_optim' - s.version = '0.32.0' + s.version = '0.31.1' s.summary = %q{Command line tool and ruby interface to optimize (lossless compress, optionally lossy) jpeg, png, gif and svg images using external utilities (advpng, gifsicle, jhead, jpeg-recompress, jpegoptim, jpegrescan, jpegtran, optipng, oxipng, pngcrush, pngout, pngquant, svgo)} s.homepage = "https://github.com/toy/#{s.name}" s.authors = ['Ivan Kuchin']