discourse_image_optim 0.24.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. checksums.yaml +7 -0
  2. data/.appveyor.yml +46 -0
  3. data/.gitignore +18 -0
  4. data/.rubocop.yml +110 -0
  5. data/.travis.yml +42 -0
  6. data/CHANGELOG.markdown +316 -0
  7. data/CONTRIBUTING.markdown +11 -0
  8. data/Gemfile +16 -0
  9. data/LICENSE.txt +20 -0
  10. data/README.markdown +358 -0
  11. data/Vagrantfile +38 -0
  12. data/bin/image_optim +28 -0
  13. data/image_optim.gemspec +34 -0
  14. data/lib/image_optim.rb +267 -0
  15. data/lib/image_optim/bin_resolver.rb +142 -0
  16. data/lib/image_optim/bin_resolver/bin.rb +115 -0
  17. data/lib/image_optim/bin_resolver/comparable_condition.rb +60 -0
  18. data/lib/image_optim/bin_resolver/error.rb +6 -0
  19. data/lib/image_optim/bin_resolver/simple_version.rb +31 -0
  20. data/lib/image_optim/cache.rb +72 -0
  21. data/lib/image_optim/cache_path.rb +16 -0
  22. data/lib/image_optim/cmd.rb +122 -0
  23. data/lib/image_optim/config.rb +219 -0
  24. data/lib/image_optim/configuration_error.rb +3 -0
  25. data/lib/image_optim/handler.rb +57 -0
  26. data/lib/image_optim/hash_helpers.rb +45 -0
  27. data/lib/image_optim/image_meta.rb +20 -0
  28. data/lib/image_optim/non_negative_integer_range.rb +11 -0
  29. data/lib/image_optim/optimized_path.rb +25 -0
  30. data/lib/image_optim/option_definition.rb +38 -0
  31. data/lib/image_optim/option_helpers.rb +17 -0
  32. data/lib/image_optim/path.rb +70 -0
  33. data/lib/image_optim/runner.rb +139 -0
  34. data/lib/image_optim/runner/glob_helpers.rb +45 -0
  35. data/lib/image_optim/runner/option_parser.rb +246 -0
  36. data/lib/image_optim/space.rb +29 -0
  37. data/lib/image_optim/true_false_nil.rb +16 -0
  38. data/lib/image_optim/worker.rb +170 -0
  39. data/lib/image_optim/worker/advpng.rb +37 -0
  40. data/lib/image_optim/worker/class_methods.rb +107 -0
  41. data/lib/image_optim/worker/gifsicle.rb +65 -0
  42. data/lib/image_optim/worker/jhead.rb +47 -0
  43. data/lib/image_optim/worker/jpegoptim.rb +63 -0
  44. data/lib/image_optim/worker/jpegrecompress.rb +49 -0
  45. data/lib/image_optim/worker/jpegtran.rb +48 -0
  46. data/lib/image_optim/worker/optipng.rb +53 -0
  47. data/lib/image_optim/worker/pngcrush.rb +56 -0
  48. data/lib/image_optim/worker/pngout.rb +40 -0
  49. data/lib/image_optim/worker/pngquant.rb +61 -0
  50. data/lib/image_optim/worker/svgo.rb +34 -0
  51. data/script/template/jquery-2.1.3.min.js +4 -0
  52. data/script/template/sortable-0.6.0.min.js +2 -0
  53. data/script/template/worker_analysis.erb +254 -0
  54. data/script/update_worker_options_in_readme +59 -0
  55. data/script/worker_analysis +589 -0
  56. data/spec/image_optim/bin_resolver/comparable_condition_spec.rb +37 -0
  57. data/spec/image_optim/bin_resolver/simple_version_spec.rb +65 -0
  58. data/spec/image_optim/bin_resolver_spec.rb +290 -0
  59. data/spec/image_optim/cache_path_spec.rb +57 -0
  60. data/spec/image_optim/cache_spec.rb +162 -0
  61. data/spec/image_optim/cmd_spec.rb +93 -0
  62. data/spec/image_optim/config_spec.rb +254 -0
  63. data/spec/image_optim/handler_spec.rb +90 -0
  64. data/spec/image_optim/hash_helpers_spec.rb +74 -0
  65. data/spec/image_optim/image_meta_spec.rb +61 -0
  66. data/spec/image_optim/optimized_path_spec.rb +58 -0
  67. data/spec/image_optim/option_definition_spec.rb +138 -0
  68. data/spec/image_optim/option_helpers_spec.rb +25 -0
  69. data/spec/image_optim/path_spec.rb +103 -0
  70. data/spec/image_optim/runner/glob_helpers_spec.rb +21 -0
  71. data/spec/image_optim/runner/option_parser_spec.rb +105 -0
  72. data/spec/image_optim/space_spec.rb +23 -0
  73. data/spec/image_optim/worker/optipng_spec.rb +102 -0
  74. data/spec/image_optim/worker/pngquant_spec.rb +67 -0
  75. data/spec/image_optim/worker_spec.rb +303 -0
  76. data/spec/image_optim_spec.rb +259 -0
  77. data/spec/images/broken_jpeg +1 -0
  78. data/spec/images/comparison.png +0 -0
  79. data/spec/images/decompressed.jpeg +0 -0
  80. data/spec/images/icecream.gif +0 -0
  81. data/spec/images/image.jpg +0 -0
  82. data/spec/images/invisiblepixels/generate +24 -0
  83. data/spec/images/invisiblepixels/image.png +0 -0
  84. data/spec/images/lena.jpg +0 -0
  85. data/spec/images/orient/0.jpg +0 -0
  86. data/spec/images/orient/1.jpg +0 -0
  87. data/spec/images/orient/2.jpg +0 -0
  88. data/spec/images/orient/3.jpg +0 -0
  89. data/spec/images/orient/4.jpg +0 -0
  90. data/spec/images/orient/5.jpg +0 -0
  91. data/spec/images/orient/6.jpg +0 -0
  92. data/spec/images/orient/7.jpg +0 -0
  93. data/spec/images/orient/8.jpg +0 -0
  94. data/spec/images/orient/generate +23 -0
  95. data/spec/images/orient/original.jpg +0 -0
  96. data/spec/images/quant/64.png +0 -0
  97. data/spec/images/quant/generate +25 -0
  98. data/spec/images/rails.png +0 -0
  99. data/spec/images/test.svg +3 -0
  100. data/spec/images/transparency1.png +0 -0
  101. data/spec/images/transparency2.png +0 -0
  102. data/spec/images/vergroessert.jpg +0 -0
  103. data/spec/spec_helper.rb +93 -0
  104. metadata +281 -0
@@ -0,0 +1,11 @@
1
+ # Contributing
2
+
3
+ * Create topic/feature branch: `git checkout -b awesome-changes`
4
+ * Commit…
5
+ * Add entry at the top of [ChangeLog](CHANGELOG.markdown)
6
+ * Run tests: `bundle exec rspec`
7
+ * Check code style: `bundle exec rubocop`
8
+ * Rebase on master and squash commits to logical units
9
+ * Push your branch: `git push origin awesome-changes`
10
+ * Create pull request
11
+ * Check if [travis is happy](https://travis-ci.org/toy/image_optim/pull_requests)
data/Gemfile ADDED
@@ -0,0 +1,16 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ if ENV['CODECLIMATE']
6
+ group :test do
7
+ gem 'simplecov'
8
+
9
+ gem 'codeclimate-test-reporter'
10
+ end
11
+ end
12
+
13
+ if RUBY_VERSION >= '2.0'
14
+ gem 'travis_check_rubies', '~> 0.2'
15
+ gem 'rainbow', '!= 2.2.1' # TODO: remove when sickill/rainbow#44 is resolved
16
+ end
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2012-2017 Ivan Kuchin
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,358 @@
1
+ [![Gem Version](https://img.shields.io/gem/v/image_optim.svg?style=flat)](https://rubygems.org/gems/image_optim)
2
+ [![Build Status](https://img.shields.io/travis/toy/image_optim/master.svg?style=flat)](https://travis-ci.org/toy/image_optim)
3
+ [![AppVeyor Status](https://img.shields.io/appveyor/ci/toy/image-optim/master.svg?style=flat&label=windows)](https://ci.appveyor.com/project/toy/image-optim)
4
+ [![Code Climate](https://img.shields.io/codeclimate/github/toy/image_optim.svg?style=flat)](https://codeclimate.com/github/toy/image_optim)
5
+ [![Code Climate Coverage](https://img.shields.io/codeclimate/coverage/github/toy/image_optim.svg?style=flat)](https://codeclimate.com/github/toy/image_optim)
6
+ [![Dependency Status](https://img.shields.io/gemnasium/toy/image_optim.svg?style=flat)](https://gemnasium.com/toy/image_optim)
7
+ [![Inch CI](https://inch-ci.org/github/toy/image_optim.svg?branch=master&style=flat)](https://inch-ci.org/github/toy/image_optim)
8
+
9
+ # image_optim
10
+
11
+ Optimize (lossless compress, optionally lossy) images (jpeg, png, gif, svg) using external utilities:
12
+
13
+ * [advpng](http://advancemame.sourceforge.net/doc-advpng.html) from [AdvanceCOMP](http://advancemame.sourceforge.net/comp-readme.html)
14
+ (will use [zopfli](https://code.google.com/p/zopfli/) on default/maximum level 4)
15
+ * [gifsicle](http://www.lcdf.org/gifsicle/)
16
+ * [jhead](http://www.sentex.net/~mwandel/jhead/)
17
+ * [jpegoptim](http://www.kokkonen.net/tjko/projects.html)
18
+ * [jpeg-recompress](https://github.com/danielgtaylor/jpeg-archive#jpeg-recompress)
19
+ * jpegtran from [Independent JPEG Group's JPEG library](http://www.ijg.org/)
20
+ * [optipng](http://optipng.sourceforge.net/)
21
+ * [pngcrush](http://pmt.sourceforge.net/pngcrush/)
22
+ * [pngout](http://www.advsys.net/ken/util/pngout.htm)
23
+ * [pngquant](http://pngquant.org/)
24
+ * [svgo](https://github.com/svg/svgo)
25
+
26
+ Based on [ImageOptim.app](http://imageoptim.com/).
27
+
28
+ Documentation for [latest version](http://rubydoc.info/gems/image_optim/frames) and [master](http://rubydoc.info/github/toy/image_optim/master/frames).
29
+
30
+ ## Gem installation
31
+
32
+ ```sh
33
+ gem install image_optim
34
+ ```
35
+
36
+ You may also want to install [`image_optim_pack`](https://github.com/toy/image_optim_pack) (see [Binaries pack](#binaries-pack)).
37
+
38
+ ```sh
39
+ gem install image_optim_pack
40
+ ```
41
+
42
+ ### Bundler
43
+
44
+ Add to your `Gemfile`:
45
+
46
+ ```ruby
47
+ gem 'image_optim'
48
+ ```
49
+
50
+ With `image_optim_pack`:
51
+
52
+ ```ruby
53
+ gem 'image_optim'
54
+ gem 'image_optim_pack'
55
+ ```
56
+
57
+ With version:
58
+
59
+ <!---<update-version>-->
60
+ ```ruby
61
+ gem 'image_optim', '~> 0.24'
62
+ ```
63
+ <!---</update-version>-->
64
+
65
+ If you want to check latest changes:
66
+
67
+ ```ruby
68
+ gem 'image_optim', :git => 'git://github.com/toy/image_optim.git'
69
+ ```
70
+
71
+ ## Binaries location
72
+
73
+ Simplest way for `image_optim` to locate binaries is to install them in common location present in `PATH` (see [Binaries installation](#binaries-installation)).
74
+
75
+ If you cannot install to common location, then install to custom one and add it to `PATH`.
76
+
77
+ Specify custom bin location using `XXX_BIN` environment variable (`JPEGOPTIM_BIN`, `OPTIPNG_BIN`, …).
78
+
79
+ Besides permanently setting environment variables in `~/.profile`, `~/.bash_profile`, `~/.bashrc`, `~/.zshrc`, … they can be set:
80
+
81
+ * before command:
82
+
83
+ `PATH="/custom/location:$PATH" image_optim *.jpg`
84
+
85
+ for example:
86
+
87
+ `PATH="/Applications/ImageOptim.app/Contents/MacOS:$PATH" image_optim *.jpg`
88
+
89
+ * inside script:
90
+
91
+ `ENV['PATH'] = "/custom/location:#{ENV['PATH']}"; ImageOptim.optimize_images([…])`
92
+
93
+ for example:
94
+
95
+ `ENV['PATH'] = "/Applications/ImageOptim.app/Contents/MacOS:#{ENV['PATH']}"; ImageOptim.optimize_images([…])`
96
+
97
+ ## Binaries installation
98
+
99
+ ### Binaries pack
100
+
101
+ Easiest way to get latest versions of most binaries for `image_optim` for Linux, Mac OS X, FreeBSD and OpenBSD is by installing [`image_optim_pack`](https://github.com/toy/image_optim_pack) gem.
102
+
103
+ Check installation instructions in [Gem installation](#gem-installation) section.
104
+
105
+ Pack doesn't include `pngout` and `svgo` binaries, their installation instructions are provided below.
106
+
107
+ ### Linux - Debian/Ubuntu
108
+
109
+ ```bash
110
+ sudo apt-get install -y advancecomp gifsicle jhead jpegoptim libjpeg-progs optipng pngcrush pngquant
111
+ ```
112
+
113
+ If you get an old version of `pngquant`, please check how to install up-to-date version or compile from source at [http://pngquant.org/](http://pngquant.org/).
114
+
115
+ ### Linux - RHEL/Fedora/Centos
116
+
117
+ ```bash
118
+ sudo yum install -y advancecomp gifsicle jhead libjpeg optipng pngquant
119
+ ```
120
+
121
+ You may also need to install `libjpeg-turbo-utils` instead of `libjpeg`:
122
+
123
+ ```bash
124
+ sudo yum install -y libjpeg-turbo-utils
125
+ ```
126
+
127
+ You will also need to install `jpegoptim` and `pngcrush` from source:
128
+
129
+ #### jpegoptim
130
+
131
+ Replace `X.Y.Z` with latest version number from http://www.kokkonen.net/tjko/projects.html#jpegoptim.
132
+
133
+ ```bash
134
+ JPEGOPTIM_VERSION=X.Y.Z
135
+ cd /tmp
136
+ curl -O http://www.kokkonen.net/tjko/src/jpegoptim-$JPEGOPTIM_VERSION.tar.gz
137
+ tar zxf jpegoptim-$JPEGOPTIM_VERSION.tar.gz
138
+ cd jpegoptim-$JPEGOPTIM_VERSION
139
+ ./configure && make && make install
140
+ ```
141
+
142
+ #### pngcrush
143
+
144
+ Replace `X.Y.Z` with latest version number from http://sourceforge.net/projects/pmt/files/pngcrush/.
145
+
146
+ ```bash
147
+ PNGCRUSH_VERSION=X.Y.Z
148
+ cd /tmp
149
+ curl -O http://iweb.dl.sourceforge.net/project/pmt/pngcrush/$PNGCRUSH_VERSION/pngcrush-$PNGCRUSH_VERSION.tar.gz
150
+ tar zxf pngcrush-$PNGCRUSH_VERSION.tar.gz
151
+ cd pngcrush-$PNGCRUSH_VERSION
152
+ make && cp -f pngcrush /usr/local/bin
153
+ ```
154
+
155
+ ### OS X: Macports
156
+
157
+ ```bash
158
+ sudo port install advancecomp gifsicle jhead jpegoptim jpeg optipng pngcrush pngquant
159
+ ```
160
+
161
+ ### OS X: Brew
162
+
163
+ ```bash
164
+ brew install advancecomp gifsicle jhead jpegoptim jpeg optipng pngcrush pngquant jonof/kenutils/pngout
165
+ ```
166
+
167
+ ### pngout installation (optional)
168
+
169
+ If you installed the dependencies via brew, pngout should be installed already. Otherwise, you can install `pngout` by downloading and installing the [binary versions](http://www.jonof.id.au/kenutils).
170
+
171
+ _Note: pngout is free to use even in commercial soft, but you can not redistribute, repackage or reuse it without consent and agreement of creator. [license](http://advsys.net/ken/utils.htm#pngoutkziplicense)_
172
+
173
+ ### svgo installation (optional)
174
+
175
+ `svgo` is available from NPM.
176
+
177
+ ```bash
178
+ npm install -g svgo
179
+ ```
180
+
181
+ ### jpeg-recompress installation (optional)
182
+
183
+ Download and install the `jpeg-recompress` binary from the [JPEG-Archive Releases](https://github.com/danielgtaylor/jpeg-archive/releases) page,
184
+ or follow the instructions to [build from source](https://github.com/danielgtaylor/jpeg-archive#building).
185
+
186
+ ## Usage
187
+
188
+ ### From shell
189
+
190
+ ```sh
191
+ image_optim *.{jpg,png,gif,svg}
192
+
193
+ image_optim -r .
194
+
195
+ image_optim -h
196
+ ```
197
+
198
+ ### From ruby
199
+
200
+ Initialize optimizer (or you can call optimization methods directly on `ImageOptim`):
201
+
202
+ ```ruby
203
+ image_optim = ImageOptim.new
204
+
205
+ image_optim = ImageOptim.new(:pngout => false)
206
+
207
+ image_optim = ImageOptim.new(:nice => 20)
208
+ ```
209
+
210
+ Optimize image getting temp path:
211
+
212
+ ```ruby
213
+ image_optim.optimize_image('a.png')
214
+ ```
215
+
216
+ Optimize image in place:
217
+
218
+ ```ruby
219
+ image_optim.optimize_image!('b.jpg')
220
+ ```
221
+
222
+ Optimize image data:
223
+
224
+ ```ruby
225
+ image_optim.optimize_image_data(data)
226
+ ```
227
+
228
+ Multiple images:
229
+
230
+ ```ruby
231
+ image_optim.optimize_images(Dir['*.png']) do |unoptimized, optimized|
232
+ if optimized
233
+ puts "#{unoptimized} => #{optimized}"
234
+ end
235
+ end
236
+
237
+ image_optim.optimize_images!(Dir['*.*'])
238
+
239
+ image_optim.optimize_images_data(datas)
240
+ ```
241
+
242
+ ### From rails
243
+
244
+ Rails image assets optimization is extracted into [image\_optim\_rails gem](https://github.com/toy/image_optim_rails).
245
+
246
+ ## Configuration
247
+
248
+ Configuration in YAML format will be read and prepended to options from two paths:
249
+
250
+ * `$XDG_CONFIG_HOME/image_optim.yml` (by default `~/.config/image_optim.yml`)
251
+ * `.image_optim.yml` in current working directory
252
+
253
+ Paths can be changed using `:config_paths` option and `--config-paths` argument.
254
+
255
+ Example configuration:
256
+
257
+ ```yaml
258
+ nice: 20
259
+ pngout: false # disable
260
+ optipng:
261
+ level: 5
262
+ ```
263
+
264
+ ## Options
265
+
266
+ * `:nice` — Nice level, priority of all used tools with higher value meaning lower priority, in range `-20..19`, negative values can be set only if run by root user *(defaults to `10`)*
267
+ * `:threads` — Number of threads or disable *(defaults to number of processors)*
268
+ * `:verbose` — Verbose output *(defaults to `false`)*
269
+ * `:pack` — Require image\_optim\_pack or disable it, by default image\_optim\_pack will be used if available, will turn on `:skip-missing-workers` unless explicitly disabled *(defaults to `nil`)*
270
+ * `:skip_missing_workers` — Skip workers with missing or problematic binaries *(defaults to `false`)*
271
+ * `:allow_lossy` — Allow lossy workers and optimizations *(defaults to `false`)*
272
+ * `:cache_dir` — Configure cache directory
273
+ * `:cache_worker_digests` - Also cache worker digests along with original file digest and worker options: updating workers invalidates cache
274
+ * `:timeout` — Number of seconds before workers are timed out. Must be greater than 0 to enable timeout. *(defaults to `0`)*
275
+
276
+ Worker can be disabled by passing `false` instead of options hash or by setting option `:disable` to `true`.
277
+
278
+ <!---<worker-options>-->
279
+ <!-- markdown for worker options is generated by `script/update_worker_options_in_readme` -->
280
+
281
+ ### advpng:
282
+ * `:level` — Compression level: `0` - don't compress, `1` - fast, `2` - normal, `3` - extra, `4` - extreme *(defaults to `4`)*
283
+ * `:timeout` — Number of seconds before worker is timed out. Must be greater than 0 to enable timeout. *(defaults to `0`)*
284
+
285
+ ### gifsicle:
286
+ * `:interlace` — Interlace: `true` - interlace on, `false` - interlace off, `nil` - as is in original image (defaults to running two instances, one with interlace off and one with on)
287
+ * `:level` — Compression level: `1` - light and fast, `2` - normal, `3` - heavy (slower) *(defaults to `3`)*
288
+ * `:careful` — Avoid bugs with some software *(defaults to `false`)*
289
+ * `:timeout` — Number of seconds before worker is timed out. Must be greater than 0 to enable timeout. *(defaults to `0`)*
290
+
291
+ ### jhead:
292
+ * `:timeout` — Number of seconds before worker is timed out. Must be greater than 0 to enable timeout. *(defaults to `0`)*
293
+
294
+ ### jpegoptim:
295
+ * `:allow_lossy` — Allow limiting maximum quality *(defaults to `false`)*
296
+ * `:strip` — List of extra markers to strip: `:comments`, `:exif`, `:iptc`, `:icc` or `:all` *(defaults to `:all`)*
297
+ * `:max_quality` — Maximum image quality factor `0`..`100`, ignored in default/lossless mode *(defaults to `100`)*
298
+ * `:timeout` — Number of seconds before worker is timed out. Must be greater than 0 to enable timeout. *(defaults to `0`)*
299
+
300
+ ### jpegrecompress:
301
+ * `:allow_lossy` — Allow worker, it is always lossy *(defaults to `false`)*
302
+ * `:quality` — JPEG quality preset: `0` - low, `1` - medium, `2` - high, `3` - veryhigh *(defaults to `3`)*
303
+ * `:timeout` — Number of seconds before worker is timed out. Must be greater than 0 to enable timeout. *(defaults to `0`)*
304
+
305
+ ### jpegtran:
306
+ * `:copy_chunks` — Copy all chunks *(defaults to `false`)*
307
+ * `:progressive` — Create progressive JPEG file *(defaults to `true`)*
308
+ * `:jpegrescan` — Use jpegtran through jpegrescan, ignore progressive option *(defaults to `false`)*
309
+ * `:timeout` — Number of seconds before worker is timed out. Must be greater than 0 to enable timeout. *(defaults to `0`)*
310
+
311
+ ### optipng:
312
+ * `:level` — Optimization level preset: `0` is least, `7` is best *(defaults to `6`)*
313
+ * `:interlace` — Interlace: `true` - interlace on, `false` - interlace off, `nil` - as is in original image *(defaults to `false`)*
314
+ * `:strip` — Remove all auxiliary chunks *(defaults to `true`)*
315
+ * `:timeout` — Number of seconds before worker is timed out. Must be greater than 0 to enable timeout. *(defaults to `0`)*
316
+
317
+ ### pngcrush:
318
+ * `:chunks` — List of chunks to remove or `:alla` - all except tRNS/transparency or `:allb` - all except tRNS and gAMA/gamma *(defaults to `:alla`)*
319
+ * `:fix` — Fix otherwise fatal conditions such as bad CRCs *(defaults to `false`)*
320
+ * `:brute` — Brute force try all methods, very time-consuming and generally not worthwhile *(defaults to `false`)*
321
+ * `:blacken` — Blacken fully transparent pixels *(defaults to `true`)*
322
+ * `:timeout` — Number of seconds before worker is timed out. Must be greater than 0 to enable timeout. *(defaults to `0`)*
323
+
324
+ ### pngout:
325
+ * `:copy_chunks` — Copy optional chunks *(defaults to `false`)*
326
+ * `:strategy` — Strategy: `0` - xtreme, `1` - intense, `2` - longest Match, `3` - huffman Only, `4` - uncompressed *(defaults to `0`)*
327
+ * `:timeout` — Number of seconds before worker is timed out. Must be greater than 0 to enable timeout. *(defaults to `0`)*
328
+
329
+ ### pngquant:
330
+ * `:allow_lossy` — Allow quality option *(defaults to `false`)*
331
+ * `: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)*
332
+ * `:speed` — speed/quality trade-off: `1` - slow, `3` - default, `11` - fast & rough *(defaults to `3`)*
333
+ * `:timeout` — Number of seconds before worker is timed out. Must be greater than 0 to enable timeout. *(defaults to `0`)*
334
+
335
+ ### svgo:
336
+ * `:disable_plugins` — List of plugins to disable *(defaults to `[]`)*
337
+ * `:enable_plugins` — List of plugins to enable *(defaults to `[]`)*
338
+ * `:timeout` — Number of seconds before worker is timed out. Must be greater than 0 to enable timeout. *(defaults to `0`)*
339
+
340
+ <!---</worker-options>-->
341
+
342
+ ## Contributing
343
+
344
+ [List](https://github.com/toy/image_optim/graphs/contributors) of contributors to `image_optim`.
345
+
346
+ If you would like to contribute - that is great and you are very welcome. Please check few notes in file [CONTRIBUTING.markdown](CONTRIBUTING.markdown).
347
+
348
+ Financial contributions can be made via [gratipay](https://gratipay.com/toy/).
349
+
350
+ [![Support via Gratipay](https://cdn.rawgit.com/gratipay/gratipay-badge/2.1.2/dist/gratipay.png)](https://gratipay.com/toy/)
351
+
352
+ ## ChangeLog
353
+
354
+ In separate file [CHANGELOG.markdown](CHANGELOG.markdown).
355
+
356
+ ## Copyright
357
+
358
+ Copyright (c) 2012-2017 Ivan Kuchin. See [LICENSE.txt](LICENSE.txt) for details.
@@ -0,0 +1,38 @@
1
+ Vagrant.configure('2') do |config|
2
+ config.vm.box = 'ubuntu/precise64'
3
+
4
+ config.vm.provision 'shell', :inline => <<-SH
5
+ set -e
6
+
7
+ cd /vagrant
8
+
9
+ echo 'apt-get update...'
10
+ apt-get update > /dev/null
11
+
12
+ echo 'Install git, imagemagick, ruby1.9.1-dev...'
13
+ apt-get install -y git npm imagemagick ruby1.9.1-dev > /dev/null
14
+
15
+ echo 'Install node, npm...'
16
+ curl -sL https://deb.nodesource.com/setup | sudo bash - > /dev/null
17
+ sudo apt-get install -y nodejs > /dev/null
18
+
19
+ echo 'Update rubygems...'
20
+ REALLY_GEM_UPDATE_SYSTEM=x gem update --system > /dev/null
21
+
22
+ echo 'Install bundler...'
23
+ gem install bundler > /dev/null
24
+
25
+ echo 'Install svgo...'
26
+ npm install -g -q svgo > /dev/null
27
+
28
+ echo 'Install pngout...'
29
+ curl -s \
30
+ 'http://static.jonof.id.au/dl/kenutils/pngout-20130221-linux.tar.gz' | \
31
+ tar -xz -C /usr/local/bin --strip-components 2 \
32
+ --wildcards '*/x86_64/pngout'
33
+
34
+ echo 'Bundle...'
35
+ bundle install --jobs=3 --quiet
36
+ bundle list
37
+ SH
38
+ end
@@ -0,0 +1,28 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: UTF-8
3
+
4
+ require 'image_optim/runner'
5
+ require 'image_optim/runner/option_parser'
6
+
7
+ args = ARGV.dup
8
+
9
+ options = ImageOptim::Runner::OptionParser.parse!(args)
10
+
11
+ begin
12
+ if options[:verbose]
13
+ $stderr.puts ImageOptim.full_version
14
+ end
15
+
16
+ only_info = options.delete(:only_info)
17
+ runner = ImageOptim::Runner.new(options)
18
+ unless only_info
19
+ abort 'specify paths to optimize' if args.empty?
20
+ abort unless runner.run!(args)
21
+ end
22
+ rescue => e
23
+ if options[:verbose]
24
+ abort "#{e}\n#{e.backtrace.join("\n")}"
25
+ else
26
+ abort e.to_s
27
+ end
28
+ end