image_optimizer 1.7.0 → 1.7.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ad635514a39378a2f01e3dd15515cf9433b341bd
4
- data.tar.gz: 3612dc1b7da6cd2e19603f5c82c8a8e259ccd0a9
3
+ metadata.gz: 9e281c990b3a3ffffdd7580f24d1ef8ef05b6639
4
+ data.tar.gz: 62ee860019a6a691f4b3a11971c6f744d0de09e3
5
5
  SHA512:
6
- metadata.gz: 59de349a631136309aa0d97942c49ffb76ca39c249187e91850dd949471c23a16bd85b3e4fef1c0c6ada72f442f01d86c58ce6b75efc68449f83a8dcb5cc4027
7
- data.tar.gz: 16d02acc88a30773dbed18dc3f7594faa26004dbc8bcfb9491237fd9b737cc8b73efd427f26b482e4518e8c56e710a676384a7fbf30c9cf4a8315416e6db07b6
6
+ metadata.gz: 4fbe361fb4ed757d209e7c4510679a918167603d25685d8b44c4b5d843c57df8fa845d479f6a79fef232fc9c689bab7ce491c1562b79e6154141cb3649a911aa
7
+ data.tar.gz: df8240f7998a0fe82e465032392f7ec2ed2a159602a8c647cb87493b460b0ed4802b77922c1ec1b1ba9f2d03e4bd28c877860458dad699aca352866b9f88acaf
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
data/CHANGELOG.md ADDED
@@ -0,0 +1,2 @@
1
+ ## [1.7.1](https://github.com/jtescher/image_optimizer/releases/tag/v1.7.1) 2017-11-29
2
+ * Fix PNGQuantOptimizer `Unrecognised option` error - https://github.com/jtescher/image_optimizer/issues/17
data/README.md CHANGED
@@ -4,14 +4,10 @@ This gem allows you to simply optimize images via jpegoptim or OptiPNG.
4
4
 
5
5
  Tested against ruby 2.0.x, 2.1.x, 2.2.x, 2.3.x, and ruby-head
6
6
 
7
- [![Build Status](https://secure.travis-ci.org/jtescher/image_optimizer.png)]
8
- (http://travis-ci.org/jtescher/image_optimizer)
9
- [![Dependency Status](https://gemnasium.com/jtescher/image_optimizer.png)]
10
- (https://gemnasium.com/jtescher/image_optimizer)
11
- [![Code Climate](https://codeclimate.com/github/jtescher/image_optimizer.png)]
12
- (https://codeclimate.com/github/jtescher/image_optimizer)
13
- [![Coverage Status](https://coveralls.io/repos/jtescher/image_optimizer/badge.png)]
14
- (https://coveralls.io/r/jtescher/image_optimizer)
7
+ [![Build Status](https://secure.travis-ci.org/jtescher/image_optimizer.png)](http://travis-ci.org/jtescher/image_optimizer)
8
+ [![Dependency Status](https://gemnasium.com/jtescher/image_optimizer.png)](https://gemnasium.com/jtescher/image_optimizer)
9
+ [![Maintainability](https://api.codeclimate.com/v1/badges/31aa4c1b98a4c31433a3/maintainability)](https://codeclimate.com/github/jtescher/image_optimizer/maintainability)
10
+ [![Coverage Status](https://coveralls.io/repos/jtescher/image_optimizer/badge.png)](https://coveralls.io/r/jtescher/image_optimizer)
15
11
  [![Gem Version](https://badge.fury.io/rb/image_optimizer.png)](http://badge.fury.io/rb/image_optimizer)
16
12
 
17
13
  ## Installation
@@ -24,7 +20,7 @@ Tested against ruby 2.0.x, 2.1.x, 2.2.x, 2.3.x, and ruby-head
24
20
 
25
21
  3. Gifsicle, which can be installed from [www.lcdf.org/gifsicle/](https://www.lcdf.org/gifsicle/)
26
22
 
27
- 4. Pngquant, which can be installed from [pngquant.org]https://pngquant.org/
23
+ 4. Pngquant, which can be installed from [pngquant.org](https://pngquant.org/)
28
24
 
29
25
  Or install the utilities via homebrew:
30
26
 
@@ -40,7 +36,7 @@ And then execute:
40
36
 
41
37
  ```bash
42
38
  $ bundle
43
- ```
39
+ ```
44
40
 
45
41
  Or install it yourself as:
46
42
  ```bash
@@ -93,6 +89,12 @@ Default is false.
93
89
  ImageOptimizer.new('path/to/file.jpg', quiet: true).optimize
94
90
  ```
95
91
 
92
+ You can also enable quiet mode globally:
93
+
94
+ ```ruby
95
+ ImageOptimizer.quiet = true
96
+ ```
97
+
96
98
  ##### Lossy JPEG optimization
97
99
 
98
100
  Pass an optional `quality` parameter to target a specific lossy JPG quality level (0-100), default is lossless
data/certs/jtescher.pem CHANGED
@@ -1,7 +1,7 @@
1
1
  -----BEGIN CERTIFICATE-----
2
2
  MIIDdDCCAlygAwIBAgIBATANBgkqhkiG9w0BAQUFADBAMRIwEAYDVQQDDAlqYXRl
3
3
  c2NoZXIxFTATBgoJkiaJk/IsZAEZFgVnbWFpbDETMBEGCgmSJomT8ixkARkWA2Nv
4
- bTAeFw0xNjA5MjYxNzU4NTRaFw0xNzA5MjYxNzU4NTRaMEAxEjAQBgNVBAMMCWph
4
+ bTAeFw0xNzExMjkyMjEzNDJaFw0xODExMjkyMjEzNDJaMEAxEjAQBgNVBAMMCWph
5
5
  dGVzY2hlcjEVMBMGCgmSJomT8ixkARkWBWdtYWlsMRMwEQYKCZImiZPyLGQBGRYD
6
6
  Y29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA7ptCQvN739Rjos4e
7
7
  G2Y8uGCQxpBoXozU36PXLtR5ws7aly1QV0zRc1cy7nKnOSnXn7dEfbLGZS6/87pM
@@ -12,10 +12,10 @@ Ryd/QG0BcvkSHph/ZDlgfZ1V/lzWWq+mZOt/U+t6cVITSET5XDzHkeZ0BodGyAMr
12
12
  lZpggQIDAQABo3kwdzAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQU
13
13
  QLcGxzEu2F2XI+3tIWSu8KqAFrkwHgYDVR0RBBcwFYETamF0ZXNjaGVyQGdtYWls
14
14
  LmNvbTAeBgNVHRIEFzAVgRNqYXRlc2NoZXJAZ21haWwuY29tMA0GCSqGSIb3DQEB
15
- BQUAA4IBAQCh9hDqN3lZw0PLVkXVcnwnl3KAjJfwCwk1okeuJ+IeQSfRLPp2ECLn
16
- j87oXZPcBukPB0/zTHcF/eBPIGvOedqVhp9SEar51dXLdiCe+deXx/bI3YMRdTGH
17
- 6NtqR6hWjm+hzBthxDsKhmQRczJ+5FNzAoW+pzf7ouKGfeFiFPwvAMolzsi2T+O/
18
- AmsZcBYVI8HbrnuoQI30XfdhNoRrKhoMyzAyVdWX9xQW56TWUO+o8iXBKjOxX2C5
19
- 8lVFrLvGNGPCLQmEf498hBYT99EVYiuiI0F7YlTmBdzL1uwTMk5le/b0NguYdSJ7
20
- qKlUP9usSwMVc+qmaOg1EYfPGYvt63qS
15
+ BQUAA4IBAQBWRgAR+mfc834XIrCK8/Ack7tAqN6sGfBZEWIm1/KVIcxL+NbaqNRR
16
+ DnY2LTppxj50MQe+O3CLdjK7qVktjf/dFdL4lBT1l3kgn8V5/YBjFQOy/8/ReKe3
17
+ oKD7BUdCvH/Iu2WSG8VIajN1hkiSDStY8sNzPwv1IFrsdn38ruTWHHpACajIg3EP
18
+ GleOnRUhEar/TQHxJmMQYrao78Gzq/b6VhQgv5up/vvs0WHUETBx7PTmoyW1Krqm
19
+ QwZpjX6ObAC8UUVzMUl9zs9rGj05QmK5Se0ZfFZYzfO71Z8Kx7vpePbGco/fzPvk
20
+ 15Xsz7dTwTgNTPwj2HLuCxQjiUskbdzv
21
21
  -----END CERTIFICATE-----
@@ -0,0 +1 @@
1
+ dc5be3d00db746d52012b8f61e8c7cc546538180fbbd043bee18e466dccb5454c2e7675d37f2db91ba3db7b513dc7f5a33ed9953c182b5d22035031ed1bc99f2
@@ -9,6 +9,15 @@ require 'image_optimizer/pngquant_optimizer'
9
9
  class ImageOptimizer
10
10
  include Shell
11
11
 
12
+ # Allow the +quiet+ flag to be set globally.
13
+ @@quiet = false
14
+ def self.quiet
15
+ @@quiet
16
+ end
17
+ def self.quiet=(value)
18
+ @@quiet = value
19
+ end
20
+
12
21
  attr_reader :path, :options
13
22
  def initialize(path, options = {})
14
23
  @path = path
@@ -40,5 +40,9 @@ class ImageOptimizer
40
40
  ENV["#{bin_name.upcase}_BIN"] || which(bin_name)
41
41
  end
42
42
 
43
+ def quiet?
44
+ options[:quiet] || ImageOptimizer.quiet
45
+ end
46
+
43
47
  end
44
48
  end
@@ -6,7 +6,7 @@ class ImageOptimizer
6
6
  def command_options
7
7
  flags = ['-f', '--strip-all', '--all-progressive']
8
8
  flags << max_quantity if (0..100).include?(options[:quality])
9
- flags << quiet if options[:quiet]
9
+ flags << quiet if quiet?
10
10
  flags << path
11
11
  end
12
12
 
@@ -6,7 +6,7 @@ class ImageOptimizer
6
6
  def command_options
7
7
  flags = %W[-o#{level}]
8
8
  flags << strip_metadata if strip_metadata?
9
- flags << quiet if options[:quiet]
9
+ flags << quiet if quiet?
10
10
  flags << path
11
11
  end
12
12
 
@@ -3,6 +3,10 @@ class ImageOptimizer
3
3
 
4
4
  private
5
5
 
6
+ def perform_optimizations
7
+ system("#{optimizer_bin} #{command_options.join(' ')}")
8
+ end
9
+
6
10
  def command_options
7
11
  flags = ['--skip-if-larger', '--speed 1',
8
12
  '--force', '--verbose', '--ext .png']
@@ -1,3 +1,3 @@
1
1
  class ImageOptimizer
2
- VERSION = '1.7.0'
2
+ VERSION = '1.7.1'
3
3
  end
@@ -53,6 +53,17 @@ describe ImageOptimizer::JPEGOptimizer do
53
53
  subject
54
54
  end
55
55
  end
56
+
57
+ context 'with global quiet mode enabled' do
58
+ before { ImageOptimizer.quiet = true }
59
+ after { ImageOptimizer.quiet = false }
60
+
61
+ it 'sets quiet parameter on the command line' do
62
+ optimizer_options = %w[-f --strip-all --all-progressive --quiet /path/to/file.jpg]
63
+ expect(jpeg_optimizer).to receive(:system).with('/usr/local/bin/jpegoptim', *optimizer_options)
64
+ subject
65
+ end
66
+ end
56
67
  end
57
68
 
58
69
  context 'optimizing utility is not installed' do
@@ -66,4 +77,4 @@ describe ImageOptimizer::JPEGOptimizer do
66
77
  end
67
78
  end
68
79
  end
69
- end
80
+ end
@@ -40,6 +40,16 @@ describe ImageOptimizer::PNGOptimizer do
40
40
  end
41
41
  end
42
42
 
43
+ context 'with global quiet mode enabled' do
44
+ before { ImageOptimizer.quiet = true }
45
+ after { ImageOptimizer.quiet = false }
46
+
47
+ it 'sets quiet parameter on the command line' do
48
+ expect(png_optimizer).to receive(:system).with('/usr/local/bin/optipng', '-o7', '-strip all', '-quiet', '/path/to/file.png')
49
+ subject
50
+ end
51
+ end
52
+
43
53
  context 'without optimization parameter' do
44
54
  it 'optimizes the png with level 7 optimization' do
45
55
  expect(png_optimizer).to receive(:system).with('/usr/local/bin/optipng', '-o7', '-strip all', '/path/to/file.png')
@@ -13,8 +13,8 @@ describe ImageOptimizer::PNGQuantOptimizer do
13
13
  end
14
14
 
15
15
  it 'optimizes the png' do
16
- optimizer_options = %w[--skip-if-larger --speed\ 1 --force --verbose --ext\ .png --quality\ 100 /path/to/file.png]
17
- expect(pngquant_optimizer).to receive(:system).with('/usr/local/bin/pngquant', *optimizer_options)
16
+ expected_cmd = "/usr/local/bin/pngquant --skip-if-larger --speed\ 1 --force --verbose --ext\ .png --quality\ 100 /path/to/file.png"
17
+ expect(pngquant_optimizer).to receive(:system).with(expected_cmd)
18
18
  subject
19
19
  end
20
20
 
@@ -28,18 +28,18 @@ describe ImageOptimizer::PNGQuantOptimizer do
28
28
  end
29
29
 
30
30
  it 'should optimize using the given path' do
31
- optimizer_options = %w[--skip-if-larger --speed\ 1 --force --verbose --ext\ .png --quality\ 100 /path/to/file.png]
32
- expect(pngquant_optimizer).to receive(:system).with(image_pngquant_bin_path, *optimizer_options)
31
+ expected_cmd = "#{image_pngquant_bin_path} --skip-if-larger --speed\ 1 --force --verbose --ext\ .png --quality\ 100 /path/to/file.png"
32
+ expect(pngquant_optimizer).to receive(:system).with(expected_cmd)
33
33
  subject
34
34
  end
35
35
  end
36
36
 
37
37
  context 'with quality parameter' do
38
- let(:options) { { :quality => 100 } }
38
+ let(:options) { { :quality => 99 } }
39
39
 
40
40
  it 'optimizes the png with the quality' do
41
- optimizer_options = %w[--skip-if-larger --speed\ 1 --force --verbose --ext\ .png --quality\ 100 /path/to/file.png]
42
- expect(pngquant_optimizer).to receive(:system).with('/usr/local/bin/pngquant', *optimizer_options)
41
+ expected_cmd = "/usr/local/bin/pngquant --skip-if-larger --speed\ 1 --force --verbose --ext\ .png --quality\ 99 /path/to/file.png"
42
+ expect(pngquant_optimizer).to receive(:system).with(expected_cmd)
43
43
  subject
44
44
  end
45
45
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: image_optimizer
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.0
4
+ version: 1.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julian Tescher
@@ -12,7 +12,7 @@ cert_chain:
12
12
  -----BEGIN CERTIFICATE-----
13
13
  MIIDdDCCAlygAwIBAgIBATANBgkqhkiG9w0BAQUFADBAMRIwEAYDVQQDDAlqYXRl
14
14
  c2NoZXIxFTATBgoJkiaJk/IsZAEZFgVnbWFpbDETMBEGCgmSJomT8ixkARkWA2Nv
15
- bTAeFw0xNjA5MjYxNzU4NTRaFw0xNzA5MjYxNzU4NTRaMEAxEjAQBgNVBAMMCWph
15
+ bTAeFw0xNzExMjkyMjEzNDJaFw0xODExMjkyMjEzNDJaMEAxEjAQBgNVBAMMCWph
16
16
  dGVzY2hlcjEVMBMGCgmSJomT8ixkARkWBWdtYWlsMRMwEQYKCZImiZPyLGQBGRYD
17
17
  Y29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA7ptCQvN739Rjos4e
18
18
  G2Y8uGCQxpBoXozU36PXLtR5ws7aly1QV0zRc1cy7nKnOSnXn7dEfbLGZS6/87pM
@@ -23,14 +23,14 @@ cert_chain:
23
23
  lZpggQIDAQABo3kwdzAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQU
24
24
  QLcGxzEu2F2XI+3tIWSu8KqAFrkwHgYDVR0RBBcwFYETamF0ZXNjaGVyQGdtYWls
25
25
  LmNvbTAeBgNVHRIEFzAVgRNqYXRlc2NoZXJAZ21haWwuY29tMA0GCSqGSIb3DQEB
26
- BQUAA4IBAQCh9hDqN3lZw0PLVkXVcnwnl3KAjJfwCwk1okeuJ+IeQSfRLPp2ECLn
27
- j87oXZPcBukPB0/zTHcF/eBPIGvOedqVhp9SEar51dXLdiCe+deXx/bI3YMRdTGH
28
- 6NtqR6hWjm+hzBthxDsKhmQRczJ+5FNzAoW+pzf7ouKGfeFiFPwvAMolzsi2T+O/
29
- AmsZcBYVI8HbrnuoQI30XfdhNoRrKhoMyzAyVdWX9xQW56TWUO+o8iXBKjOxX2C5
30
- 8lVFrLvGNGPCLQmEf498hBYT99EVYiuiI0F7YlTmBdzL1uwTMk5le/b0NguYdSJ7
31
- qKlUP9usSwMVc+qmaOg1EYfPGYvt63qS
26
+ BQUAA4IBAQBWRgAR+mfc834XIrCK8/Ack7tAqN6sGfBZEWIm1/KVIcxL+NbaqNRR
27
+ DnY2LTppxj50MQe+O3CLdjK7qVktjf/dFdL4lBT1l3kgn8V5/YBjFQOy/8/ReKe3
28
+ oKD7BUdCvH/Iu2WSG8VIajN1hkiSDStY8sNzPwv1IFrsdn38ruTWHHpACajIg3EP
29
+ GleOnRUhEar/TQHxJmMQYrao78Gzq/b6VhQgv5up/vvs0WHUETBx7PTmoyW1Krqm
30
+ QwZpjX6ObAC8UUVzMUl9zs9rGj05QmK5Se0ZfFZYzfO71Z8Kx7vpePbGco/fzPvk
31
+ 15Xsz7dTwTgNTPwj2HLuCxQjiUskbdzv
32
32
  -----END CERTIFICATE-----
33
- date: 2016-11-15 00:00:00.000000000 Z
33
+ date: 2017-11-29 00:00:00.000000000 Z
34
34
  dependencies:
35
35
  - !ruby/object:Gem::Dependency
36
36
  name: rspec
@@ -111,6 +111,7 @@ extra_rdoc_files: []
111
111
  files:
112
112
  - ".gitignore"
113
113
  - ".travis.yml"
114
+ - CHANGELOG.md
114
115
  - Gemfile
115
116
  - LICENSE.txt
116
117
  - README.md
@@ -128,6 +129,7 @@ files:
128
129
  - checksum/image_optimizer-1.6.0.gem.sha512
129
130
  - checksum/image_optimizer-1.6.1.gem.sha512
130
131
  - checksum/image_optimizer-1.7.0.gem.sha512
132
+ - checksum/image_optimizer-1.7.1.gem.sha512
131
133
  - image_optimizer.gemspec
132
134
  - lib/image_optimizer.rb
133
135
  - lib/image_optimizer/gif_optimizer.rb
@@ -165,7 +167,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
165
167
  version: '0'
166
168
  requirements: []
167
169
  rubyforge_project:
168
- rubygems_version: 2.5.1
170
+ rubygems_version: 2.6.14
169
171
  signing_key:
170
172
  specification_version: 4
171
173
  summary: Simply optimize images via jpegoptim or OptiPNG or Gifsicle
metadata.gz.sig CHANGED
Binary file