image_optim 0.6.0 → 0.7.0

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.
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: image_optim
3
3
  version: !ruby/object:Gem::Version
4
- hash: 7
4
+ hash: 3
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 6
8
+ - 7
9
9
  - 0
10
- version: 0.6.0
10
+ version: 0.7.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ivan Kuchin
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-11-15 00:00:00 Z
18
+ date: 2013-01-17 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: fspath
@@ -112,15 +112,14 @@ files:
112
112
  - lib/image_optim.rb
113
113
  - lib/image_optim/image_path.rb
114
114
  - lib/image_optim/option_helpers.rb
115
- - lib/image_optim/util.rb
116
115
  - lib/image_optim/worker.rb
117
- - lib/image_optim/workers/advpng.rb
118
- - lib/image_optim/workers/gifsicle.rb
119
- - lib/image_optim/workers/jpegoptim.rb
120
- - lib/image_optim/workers/jpegtran.rb
121
- - lib/image_optim/workers/optipng.rb
122
- - lib/image_optim/workers/pngcrush.rb
123
- - lib/image_optim/workers/pngout.rb
116
+ - lib/image_optim/worker/advpng.rb
117
+ - lib/image_optim/worker/gifsicle.rb
118
+ - lib/image_optim/worker/jpegoptim.rb
119
+ - lib/image_optim/worker/jpegtran.rb
120
+ - lib/image_optim/worker/optipng.rb
121
+ - lib/image_optim/worker/pngcrush.rb
122
+ - lib/image_optim/worker/pngout.rb
124
123
  - spec/image_optim_spec.rb
125
124
  - spec/images/comparison.png
126
125
  - spec/images/decompressed.jpeg
@@ -1,27 +0,0 @@
1
- require 'shellwords'
2
-
3
- class ImageOptim
4
- module Util
5
- # http://stackoverflow.com/questions/891537/ruby-detect-number-of-cpus-installed
6
- def self.processor_count
7
- @processor_count ||= case host_os = RbConfig::CONFIG['host_os']
8
- when /darwin9/
9
- `hwprefs cpu_count`
10
- when /darwin/
11
- (`which hwprefs` != '') ? `hwprefs thread_count` : `sysctl -n hw.ncpu`
12
- when /linux/
13
- `grep -c processor /proc/cpuinfo`
14
- when /freebsd/
15
- `sysctl -n hw.ncpu`
16
- when /mswin|mingw/
17
- require 'win32ole'
18
- wmi = WIN32OLE.connect('winmgmts://')
19
- cpu = wmi.ExecQuery('select NumberOfLogicalProcessors from Win32_Processor')
20
- cpu.to_enum.first.NumberOfLogicalProcessors
21
- else
22
- warn "Unknown architecture (#{host_os}) assuming one processor."
23
- 1
24
- end.to_i
25
- end
26
- end
27
- end
@@ -1,19 +0,0 @@
1
- require 'image_optim'
2
-
3
- class ImageOptim
4
- class Advpng < Worker
5
- # Compression level: 0 - don't compress, 1 - fast, 2 - normal, 3 - extra, 4 - extreme (defaults to 4)
6
- attr_reader :level
7
-
8
- private
9
-
10
- def parse_options(options)
11
- get_option!(options, :level, 4){ |v| limit_with_range(v.to_i, 0..4) }
12
- end
13
-
14
- def command_args(src, dst)
15
- src.copy(dst)
16
- %W[-#{level} -z -q -- #{dst}]
17
- end
18
- end
19
- end
@@ -1,20 +0,0 @@
1
- require 'image_optim'
2
-
3
- class ImageOptim
4
- class Gifsicle < Worker
5
- # Turn on interlacing (defaults to false)
6
- attr_reader :interlace
7
-
8
- private
9
-
10
- def parse_options(options)
11
- get_option!(options, :interlace, false){ |v| !!v }
12
- end
13
-
14
- def command_args(src, dst)
15
- args = %W[-o #{dst} -O3 --no-comments --no-names --same-delay --same-loopcount --no-warnings -- #{src}]
16
- args.unshift('-i') if interlace
17
- args
18
- end
19
- end
20
- end
@@ -1,50 +0,0 @@
1
- require 'image_optim'
2
-
3
- class ImageOptim
4
- class Jpegoptim < Worker
5
- # Strip Comment markers from output file (defaults to true)
6
- attr_reader :strip_comments
7
-
8
- # Strip Exif markers from output file (defaults to true)
9
- attr_reader :strip_exif
10
-
11
- # Strip IPTC markers from output file (defaults to true)
12
- attr_reader :strip_iptc
13
-
14
- # Strip ICC profile markers from output file (defaults to true)
15
- attr_reader :strip_icc
16
-
17
- # Maximum image quality factor (defaults to 100)
18
- attr_reader :max_quality
19
-
20
- # Run first if max_quality < 100
21
- def run_first?
22
- max_quality < 100
23
- end
24
-
25
- private
26
-
27
- def parse_options(options)
28
- get_option!(options, :strip_comments, true){ |v| !!v }
29
- get_option!(options, :strip_exif, true){ |v| !!v }
30
- get_option!(options, :strip_iptc, true){ |v| !!v }
31
- get_option!(options, :strip_icc, true){ |v| !!v }
32
- get_option!(options, :max_quality, 100){ |v| v.to_i }
33
- end
34
-
35
- def command_args(src, dst)
36
- src.copy(dst)
37
- args = %W[-q -- #{dst}]
38
- if strip_comments && strip_exif && strip_iptc && strip_icc
39
- args.unshift '--strip-all'
40
- else
41
- args.unshift '--strip-com' if strip_comments
42
- args.unshift '--strip-exif' if strip_exif
43
- args.unshift '--strip-iptc' if strip_iptc
44
- args.unshift '--strip-icc' if strip_icc
45
- end
46
- args.unshift "-m#{max_quality}" if max_quality < 100
47
- args
48
- end
49
- end
50
- end
@@ -1,25 +0,0 @@
1
- require 'image_optim'
2
-
3
- class ImageOptim
4
- class Jpegtran < Worker
5
- # Copy all chunks or none (defaults to false)
6
- attr_reader :copy
7
-
8
- # Create progressive JPEG file (defaults to true)
9
- attr_reader :progressive
10
-
11
- private
12
-
13
- def parse_options(options)
14
- get_option!(options, :copy, false){ |v| !!v }
15
- get_option!(options, :progressive, true){ |v| !!v }
16
- end
17
-
18
- def command_args(src, dst)
19
- args = %W[-optimize -outfile #{dst} #{src}]
20
- args.unshift '-copy', copy ? 'all' : 'none'
21
- args.unshift '-progressive' if progressive
22
- args
23
- end
24
- end
25
- end
@@ -1,27 +0,0 @@
1
- require 'image_optim'
2
-
3
- class ImageOptim
4
- class Optipng < Worker
5
- # Optimization level preset 0..7 (0 is least, 7 is best, defaults to 6)
6
- attr_reader :level
7
-
8
- # Interlace, true - interlace on, false - interlace off, nil - as is in original image (defaults to false)
9
- attr_reader :interlace
10
-
11
- private
12
-
13
- def parse_options(options)
14
- get_option!(options, :level, 6){ |v| limit_with_range(v.to_i, 0..7) }
15
- get_option!(options, :interlace, false){ |v| v && true }
16
- end
17
-
18
- def command_args(src, dst)
19
- src.copy(dst)
20
- args = %W[-o#{level} -quiet -- #{dst}]
21
- unless interlace.nil?
22
- args.unshift "-i#{interlace ? 1 : 0}"
23
- end
24
- args
25
- end
26
- end
27
- end
@@ -1,37 +0,0 @@
1
- require 'image_optim'
2
-
3
- class ImageOptim
4
- class Pngcrush < Worker
5
- # List of chunks to remove or 'alla' or 'allb' (defaults to 'alla')
6
- attr_reader :chunks
7
-
8
- # Fix otherwise fatal conditions such as bad CRCs (defaults to false)
9
- attr_reader :fix
10
-
11
- # Brute force try all methods, very time-consuming and generally not worthwhile (defaults to false)
12
- attr_reader :brute
13
-
14
- # Always run first
15
- def run_first?
16
- true
17
- end
18
-
19
- private
20
-
21
- def parse_options(options)
22
- get_option!(options, :chunks, :alla){ |v| Array(v).map(&:to_s) }
23
- get_option!(options, :fix, false){ |v| !!v }
24
- get_option!(options, :brute, false){ |v| !!v }
25
- end
26
-
27
- def command_args(src, dst)
28
- args = %W[-reduce -cc -q -- #{src} #{dst}]
29
- Array(chunks).each do |chunk|
30
- args.unshift '-rem', chunk
31
- end
32
- args.unshift '-fix' if fix
33
- args.unshift '-brute' if brute
34
- args
35
- end
36
- end
37
- end
@@ -1,27 +0,0 @@
1
- require 'image_optim'
2
-
3
- class ImageOptim
4
- class Pngout < Worker
5
- # Keep optional chunks (defaults to false)
6
- attr_reader :keep_chunks
7
-
8
- # Strategy: 0 - xtreme, 1 - intense, 2 - longest Match, 3 - huffman Only, 4 - uncompressed (defaults to 0)
9
- attr_reader :strategy
10
-
11
- # Always run first
12
- def run_first?
13
- true
14
- end
15
-
16
- private
17
-
18
- def parse_options(options)
19
- get_option!(options, :keep_chunks, false){ |v| !!v }
20
- get_option!(options, :strategy, 0){ |v| limit_with_range(v.to_i, 0..4) }
21
- end
22
-
23
- def command_args(src, dst)
24
- %W[-k#{keep_chunks ? 1 : 0} -s#{strategy} -q -y #{src} #{dst}]
25
- end
26
- end
27
- end