image_optim 0.27.1 → 0.28.0
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 -2
- data/CHANGELOG.markdown +6 -0
- data/CONTRIBUTING.markdown +4 -1
- data/README.markdown +3 -2
- data/image_optim.gemspec +3 -3
- data/lib/image_optim/bin_resolver/bin.rb +1 -0
- data/lib/image_optim/config.rb +3 -3
- data/lib/image_optim/runner/option_parser.rb +2 -0
- data/lib/image_optim/worker/jpegoptim.rb +6 -4
- data/lib/image_optim/worker/jpegrecompress.rb +15 -0
- data/lib/image_optim/worker/pngquant.rb +1 -0
- data/script/update_worker_options_in_readme +1 -1
- data/spec/image_optim/cache_spec.rb +1 -1
- data/spec/image_optim/worker/jpegrecompress_spec.rb +32 -0
- metadata +8 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 818160db3036f1fd4305077d943e59991aebe5fb1023b3c7e46db02e63c5fb37
|
4
|
+
data.tar.gz: 76c76ec43a5c05b9e35de21757928ec8793709a3db27e8a982cc46612f8d491e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f30e6f493be6ff4e98407bb611d8fd868733af14da078b225b6708c7f6aabaa41d00b08e82c3801c788bd70c4d7278ee91a186a3dc54bc7bdcc16e685d27c7a8
|
7
|
+
data.tar.gz: b3402efe19eeb298518cfeb117f38c7aca1e0bbabe68313663107269d3ab87f8900f238db182042377adb5ebc12f69dd133ee5c922fcbde54c4b647bc9efa836
|
data/.travis.yml
CHANGED
@@ -7,7 +7,6 @@ cache:
|
|
7
7
|
- $(npm root)
|
8
8
|
- ~/bin
|
9
9
|
rvm:
|
10
|
-
- '1.8.7-p374'
|
11
10
|
- '1.9.3-p551'
|
12
11
|
- '2.0.0-p648'
|
13
12
|
- '2.1.10'
|
@@ -16,7 +15,7 @@ rvm:
|
|
16
15
|
- '2.4.10'
|
17
16
|
- '2.5.8'
|
18
17
|
- '2.6.6'
|
19
|
-
- '2.7.
|
18
|
+
- '2.7.2'
|
20
19
|
- 'jruby-9.2.11.1'
|
21
20
|
script:
|
22
21
|
- bundle exec image_optim --info
|
data/CHANGELOG.markdown
CHANGED
@@ -2,6 +2,12 @@
|
|
2
2
|
|
3
3
|
## unreleased
|
4
4
|
|
5
|
+
## v0.28.0 (2020-12-18)
|
6
|
+
|
7
|
+
* Fix and update list of markers in jpegoptim worker: allow to pass `com` instead of incorrect `comments` and add missing `xmp` and `none` [#188](https://github.com/toy/image_optim/issues/188) [@toy](https://github.com/toy)
|
8
|
+
* Add `--skip-if-larger` flag to pngquant worker. The pngquant worker already does this, but this will make it fail faster. [#125](https://github.com/toy/image_optim/pull/125) [#181](https://github.com/toy/image_optim/pull/181) [@iggant](https://github.com/iggant) [@oblakeerickson](https://github.com/oblakeerickson)
|
9
|
+
* Add `method` option for jpegrecompress, default to `ssim` [#102](https://github.com/toy/image_optim/issues/102) [#103](https://github.com/toy/image_optim/pull/103) [#182](https://github.com/toy/image_optim/pull/182) [@ramiroaraujo](https://github.com/ramiroaraujo) [@oblakeerickson](https://github.com/oblakeerickson)
|
10
|
+
|
5
11
|
## v0.27.1 (2020-09-30)
|
6
12
|
|
7
13
|
* Fixed atomic replacement for case when equal `File::Stat#dev` doesn't mean that file can be linked [#180](https://github.com/toy/image_optim/issues/180) [@toy](https://github.com/toy)
|
data/CONTRIBUTING.markdown
CHANGED
@@ -2,7 +2,10 @@
|
|
2
2
|
|
3
3
|
* Create topic/feature branch: `git checkout -b awesome-changes`
|
4
4
|
* Commit…
|
5
|
-
* Add entry at the top of [ChangeLog](CHANGELOG.markdown)
|
5
|
+
* Add an entry at the top (after ## unreleased) of [ChangeLog](CHANGELOG.markdown), include:
|
6
|
+
* Issues (`[#123](https://github.com/toy/image_optim/issues/123)`)
|
7
|
+
* Pull requests (`[#123](https://github.com/toy/image_optim/pull/123)`)
|
8
|
+
* Authors (`[@octocat](https://github.com/octocat)`)
|
6
9
|
* Run tests: `bundle exec rspec`
|
7
10
|
* Check code style: `bundle exec rubocop`
|
8
11
|
* Rebase on master and squash commits to logical units
|
data/README.markdown
CHANGED
@@ -60,7 +60,7 @@ With version:
|
|
60
60
|
|
61
61
|
<!---<update-version>-->
|
62
62
|
```ruby
|
63
|
-
gem 'image_optim', '~> 0.
|
63
|
+
gem 'image_optim', '~> 0.28'
|
64
64
|
```
|
65
65
|
<!---</update-version>-->
|
66
66
|
|
@@ -310,12 +310,13 @@ Worker has no options
|
|
310
310
|
|
311
311
|
### jpegoptim:
|
312
312
|
* `:allow_lossy` — Allow limiting maximum quality *(defaults to `false`)*
|
313
|
-
* `:strip` — List of
|
313
|
+
* `:strip` — List of markers to strip: `:com`, `:exif`, `:iptc`, `:icc`, `:xmp`, `:none` or `:all` *(defaults to `:all`)*
|
314
314
|
* `:max_quality` — Maximum image quality factor `0`..`100`, ignored in default/lossless mode *(defaults to `100`)*
|
315
315
|
|
316
316
|
### jpegrecompress:
|
317
317
|
* `:allow_lossy` — Allow worker, it is always lossy *(defaults to `false`)*
|
318
318
|
* `:quality` — JPEG quality preset: `0` - low, `1` - medium, `2` - high, `3` - veryhigh *(defaults to `3`)*
|
319
|
+
* `:method` — Comparison Metric: `mpe` - Mean pixel error, `ssim` - Structural similarity, `ms-ssim` - Multi-scale structural similarity (slow!), `smallfry` - Linear-weighted BBCQ-like (may be patented) *(defaults to ssim)*
|
319
320
|
|
320
321
|
### jpegtran:
|
321
322
|
* `:copy_chunks` — Copy all chunks *(defaults to `false`)*
|
data/image_optim.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = 'image_optim'
|
5
|
-
s.version = '0.
|
5
|
+
s.version = '0.28.0'
|
6
6
|
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, pngcrush, pngout, pngquant, svgo)}
|
7
7
|
s.homepage = "https://github.com/toy/#{s.name}"
|
8
8
|
s.authors = ['Ivan Kuchin']
|
@@ -33,7 +33,7 @@ EOF
|
|
33
33
|
|
34
34
|
s.add_development_dependency 'image_optim_pack', '~> 0.2', '>= 0.2.2'
|
35
35
|
s.add_development_dependency 'rspec', '~> 3.0'
|
36
|
-
if RUBY_VERSION >= '2.
|
37
|
-
s.add_development_dependency 'rubocop', '~>
|
36
|
+
if RUBY_VERSION >= '2.4' && !Gem.win_platform? && !defined?(JRUBY_VERSION)
|
37
|
+
s.add_development_dependency 'rubocop', '~> 1.0'
|
38
38
|
end
|
39
39
|
end
|
data/lib/image_optim/config.rb
CHANGED
@@ -197,10 +197,10 @@ class ImageOptim
|
|
197
197
|
when /darwin9/
|
198
198
|
Cmd.capture 'hwprefs cpu_count'
|
199
199
|
when /darwin/
|
200
|
-
if (Cmd.capture 'which hwprefs')
|
201
|
-
Cmd.capture 'hwprefs thread_count'
|
202
|
-
else
|
200
|
+
if (Cmd.capture 'which hwprefs') == ''
|
203
201
|
Cmd.capture 'sysctl -n hw.ncpu'
|
202
|
+
else
|
203
|
+
Cmd.capture 'hwprefs thread_count'
|
204
204
|
end
|
205
205
|
when /linux/
|
206
206
|
Cmd.capture 'grep -c processor /proc/cpuinfo'
|
@@ -11,14 +11,16 @@ class ImageOptim
|
|
11
11
|
option(:allow_lossy, false, 'Allow limiting maximum quality'){ |v| !!v }
|
12
12
|
|
13
13
|
STRIP_OPTION =
|
14
|
-
option(:strip, :all, Array, 'List of
|
15
|
-
'`:
|
14
|
+
option(:strip, :all, Array, 'List of markers to strip: '\
|
15
|
+
'`:com`, '\
|
16
16
|
'`:exif`, '\
|
17
17
|
'`:iptc`, '\
|
18
|
-
'`:icc
|
18
|
+
'`:icc`, '\
|
19
|
+
'`:xmp`, '\
|
20
|
+
'`:none` or '\
|
19
21
|
'`:all`') do |v|
|
20
22
|
values = Array(v).map(&:to_s)
|
21
|
-
known_values = %w[
|
23
|
+
known_values = %w[com exif iptc icc xmp none all]
|
22
24
|
unknown_values = values - known_values
|
23
25
|
unless unknown_values.empty?
|
24
26
|
warn "Unknown markers for jpegoptim: #{unknown_values.join(', ')}"
|
@@ -26,6 +26,20 @@ class ImageOptim
|
|
26
26
|
OptionHelpers.limit_with_range(v.to_i, 0...QUALITY_NAMES.length)
|
27
27
|
end
|
28
28
|
|
29
|
+
METHOD_OPTION =
|
30
|
+
option(:method, 'ssim', 'Comparison Metric: '\
|
31
|
+
'`mpe` - Mean pixel error, '\
|
32
|
+
'`ssim` - Structural similarity, '\
|
33
|
+
'`ms-ssim` - Multi-scale structural similarity (slow!), '\
|
34
|
+
'`smallfry` - Linear-weighted BBCQ-like (may be patented)') do |v, opt_def|
|
35
|
+
if %w[mpe ssim ms-ssim smallfry].include? v
|
36
|
+
v
|
37
|
+
else
|
38
|
+
warn "Unknown method for jpegrecompress: #{v}"
|
39
|
+
opt_def.default
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
29
43
|
def used_bins
|
30
44
|
[:'jpeg-recompress']
|
31
45
|
end
|
@@ -38,6 +52,7 @@ class ImageOptim
|
|
38
52
|
def optimize(src, dst)
|
39
53
|
args = %W[
|
40
54
|
--quality #{QUALITY_NAMES[quality]}
|
55
|
+
--method #{method}
|
41
56
|
--no-copy
|
42
57
|
#{src}
|
43
58
|
#{dst}
|
@@ -18,7 +18,7 @@ def write_worker_options(io, klass)
|
|
18
18
|
klass.option_definitions.each do |option_definition|
|
19
19
|
line = "* `:#{option_definition.name}` — #{option_definition.description}"
|
20
20
|
unless line['(defaults']
|
21
|
-
line
|
21
|
+
line += " *(defaults to #{option_definition.default_description})*"
|
22
22
|
end
|
23
23
|
io.puts line
|
24
24
|
end
|
@@ -102,7 +102,7 @@ describe ImageOptim::Cache do
|
|
102
102
|
expect(FileUtils).not_to receive(:mv)
|
103
103
|
expect(File).not_to receive(:rename)
|
104
104
|
|
105
|
-
expect(cache.fetch(original){}).to eq(cached)
|
105
|
+
expect(cache.fetch(original){ nil }).to eq(cached)
|
106
106
|
end
|
107
107
|
|
108
108
|
it 'returns nil when file is already optimized' do
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
require 'image_optim/worker/jpegrecompress'
|
5
|
+
|
6
|
+
describe ImageOptim::Worker::Jpegrecompress do
|
7
|
+
describe 'method value' do
|
8
|
+
let(:subject){ described_class.new(ImageOptim.new, method).method }
|
9
|
+
|
10
|
+
context 'default' do
|
11
|
+
let(:method){ {} }
|
12
|
+
|
13
|
+
it{ is_expected.to eq('ssim') }
|
14
|
+
end
|
15
|
+
|
16
|
+
context 'uses default when invalid' do
|
17
|
+
let(:method){ {:method => 'invalid'} }
|
18
|
+
|
19
|
+
it 'warns and keeps default' do
|
20
|
+
expect_any_instance_of(described_class).
|
21
|
+
to receive(:warn).with('Unknown method for jpegrecompress: invalid')
|
22
|
+
is_expected.to eq('ssim')
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
context 'can use a valid option' do
|
27
|
+
let(:method){ {:method => 'smallfry'} }
|
28
|
+
|
29
|
+
it{ is_expected.to eq('smallfry') }
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: image_optim
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.28.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ivan Kuchin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-12-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fspath
|
@@ -138,20 +138,14 @@ dependencies:
|
|
138
138
|
requirements:
|
139
139
|
- - "~>"
|
140
140
|
- !ruby/object:Gem::Version
|
141
|
-
version: '0
|
142
|
-
- - "!="
|
143
|
-
- !ruby/object:Gem::Version
|
144
|
-
version: 0.78.0
|
141
|
+
version: '1.0'
|
145
142
|
type: :development
|
146
143
|
prerelease: false
|
147
144
|
version_requirements: !ruby/object:Gem::Requirement
|
148
145
|
requirements:
|
149
146
|
- - "~>"
|
150
147
|
- !ruby/object:Gem::Version
|
151
|
-
version: '0
|
152
|
-
- - "!="
|
153
|
-
- !ruby/object:Gem::Version
|
154
|
-
version: 0.78.0
|
148
|
+
version: '1.0'
|
155
149
|
description:
|
156
150
|
email:
|
157
151
|
executables:
|
@@ -230,6 +224,7 @@ files:
|
|
230
224
|
- spec/image_optim/runner/glob_helpers_spec.rb
|
231
225
|
- spec/image_optim/runner/option_parser_spec.rb
|
232
226
|
- spec/image_optim/space_spec.rb
|
227
|
+
- spec/image_optim/worker/jpegrecompress_spec.rb
|
233
228
|
- spec/image_optim/worker/optipng_spec.rb
|
234
229
|
- spec/image_optim/worker/pngquant_spec.rb
|
235
230
|
- spec/image_optim/worker_spec.rb
|
@@ -269,7 +264,7 @@ licenses:
|
|
269
264
|
metadata:
|
270
265
|
bug_tracker_uri: https://github.com/toy/image_optim/issues
|
271
266
|
changelog_uri: https://github.com/toy/image_optim/blob/master/CHANGELOG.markdown
|
272
|
-
documentation_uri: https://www.rubydoc.info/gems/image_optim/0.
|
267
|
+
documentation_uri: https://www.rubydoc.info/gems/image_optim/0.28.0
|
273
268
|
source_code_uri: https://github.com/toy/image_optim
|
274
269
|
post_install_message: |
|
275
270
|
Rails image assets optimization is extracted into image_optim_rails gem
|
@@ -288,7 +283,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
288
283
|
- !ruby/object:Gem::Version
|
289
284
|
version: '0'
|
290
285
|
requirements: []
|
291
|
-
rubygems_version: 3.1.
|
286
|
+
rubygems_version: 3.1.5
|
292
287
|
signing_key:
|
293
288
|
specification_version: 4
|
294
289
|
summary: Command line tool and ruby interface to optimize (lossless compress, optionally
|
@@ -313,6 +308,7 @@ test_files:
|
|
313
308
|
- spec/image_optim/runner/glob_helpers_spec.rb
|
314
309
|
- spec/image_optim/runner/option_parser_spec.rb
|
315
310
|
- spec/image_optim/space_spec.rb
|
311
|
+
- spec/image_optim/worker/jpegrecompress_spec.rb
|
316
312
|
- spec/image_optim/worker/optipng_spec.rb
|
317
313
|
- spec/image_optim/worker/pngquant_spec.rb
|
318
314
|
- spec/image_optim/worker_spec.rb
|