image_optimizer 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +9 -9
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +1 -2
- data/.travis.yml +5 -4
- data/README.md +16 -3
- data/image_optimizer.gemspec +5 -4
- data/lib/image_optimizer.rb +9 -8
- data/lib/image_optimizer/jpeg_optimizer.rb +9 -4
- data/lib/image_optimizer/png_optimizer.rb +1 -1
- data/lib/image_optimizer/version.rb +1 -1
- data/spec/image_optimizer/jpeg_optimizer_spec.rb +12 -2
- data/spec/image_optimizer/version_spec.rb +2 -2
- data/spec/image_optimizer_spec.rb +2 -2
- metadata +31 -17
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZGQwZDcwZDNiZjQ5ODMwNTEzNzU3ZWY2MzM5MzMzMDg2Zjk3Y2YzNg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
7
|
-
|
6
|
+
Zjc2OGU1NGQyNzFhMDcxMDVkYzQ5OWJjMDliMjgwZjAxNzliZjg5Mg==
|
7
|
+
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZWI3ZDQ2YjgxNzVjYjk5ZGY5NDE3ZDZjY2RjNGM1MGI3NmQ4MDA5OTc2MDk2
|
10
|
+
MzEwZmIxOTMwNTdiMmEzNzg1YzU3MjgwNGRkY2RmMDc1NjdhNWVhMjI2M2Vj
|
11
|
+
MmVkZTdkMTc1MjI1MDRiMTI5MzNjZGU3ZWYxNWJhMmUxNTcxNjU=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZTk1ZGM2M2IzMTQ0ZDZlM2Q3MGRlYmQwZTk3OWUwZTcwMjQzNWFmYzYzMmJl
|
14
|
+
YjVjMDc4YzAwNTViOTA1NTA4ZGQzMDgwOGIzYWI0NmYxMGU0NDdiMTk0NzVj
|
15
|
+
YmVjOTlmM2ZjMmM4OGNhMGU2NWM0NjZkNjkxYTA3ZjdiYjUzNWY=
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
@@ -1,2 +1 @@
|
|
1
|
-
|
2
|
-
kr�
|
1
|
+
���t�gk#\�����e�8����w���/�s`�Oծz�܋��"����������ڂ��h�>��n}չJ�@'Z&���s?��@o�S�)�:?����r��hYPӶ�4}�ٕ\�z<"BIW!���E{�|S�2�KI�w��y*�S��a��j�:#����6���(㣎Nf��D�k����q~B�ʦ�BMZ�(l:�qax��4� �N.=���9���$ξ��}�<�*ZF�v�'�=C�KI�зUWu�
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -2,16 +2,18 @@
|
|
2
2
|
|
3
3
|
This gem allows you to simply optimize images via jpegoptim or OptiPNG.
|
4
4
|
|
5
|
-
Tested against ruby 1.8.7, 1.9.2, 1.9.3, ruby-head, jruby-18mode, jruby-19mode, jruby-head, rbx-18mode,
|
6
|
-
ree
|
5
|
+
Tested against ruby 1.8.7, 1.9.2, 1.9.3, 2.0.0, ruby-head, jruby-18mode, jruby-19mode, jruby-head, rbx-18mode,
|
6
|
+
rbx-19mode, and ree
|
7
7
|
|
8
8
|
[![Build Status](https://secure.travis-ci.org/jtescher/image_optimizer.png)]
|
9
9
|
(http://travis-ci.org/jtescher/image_optimizer)
|
10
10
|
[![Dependency Status](https://gemnasium.com/jtescher/image_optimizer.png)]
|
11
11
|
(https://gemnasium.com/jtescher/image_optimizer)
|
12
|
-
[![Code Climate](https://codeclimate.com/
|
12
|
+
[![Code Climate](https://codeclimate.com/github/jtescher/image_optimizer.png)]
|
13
|
+
(https://codeclimate.com/github/jtescher/image_optimizer)
|
13
14
|
[![Coverage Status](https://coveralls.io/repos/jtescher/image_optimizer/badge.png)]
|
14
15
|
(https://coveralls.io/r/jtescher/image_optimizer)
|
16
|
+
[![Gem Version](https://badge.fury.io/rb/image_optimizer.png)](http://badge.fury.io/rb/image_optimizer)
|
15
17
|
|
16
18
|
## Installation
|
17
19
|
|
@@ -56,11 +58,22 @@ ImageOptimizer.new('path/to/file.png').optimize
|
|
56
58
|
#### Optimize JPEG formats:
|
57
59
|
|
58
60
|
jpegoptim provides lossless optimization for JPEG files based on optimizing the Huffman tables.
|
61
|
+
All jpegs will be progressively optimized for a better web experience
|
59
62
|
|
60
63
|
```ruby
|
61
64
|
ImageOptimizer.new('path/to/file.jpg').optimize
|
62
65
|
```
|
63
66
|
|
67
|
+
##### Lossy JPEG optimization
|
68
|
+
|
69
|
+
Pass an optional `quality` parameter to target a specific lossy JPG quality level (0-100), default is lossless
|
70
|
+
optimization. PNGs will ignore the quality setting.
|
71
|
+
|
72
|
+
```ruby
|
73
|
+
ImageOptimizer.new('path/to/file.jpg', quality: 80).optimize
|
74
|
+
```
|
75
|
+
|
76
|
+
|
64
77
|
## Contributing
|
65
78
|
|
66
79
|
1. Fork it
|
data/image_optimizer.gemspec
CHANGED
@@ -20,8 +20,9 @@ Gem::Specification.new do |gem|
|
|
20
20
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
21
21
|
gem.require_paths = ["lib"]
|
22
22
|
|
23
|
-
gem.add_development_dependency "rspec"
|
24
|
-
gem.add_development_dependency "rake"
|
25
|
-
gem.add_development_dependency "simplecov"
|
26
|
-
gem.add_development_dependency "coveralls"
|
23
|
+
gem.add_development_dependency "rspec"
|
24
|
+
gem.add_development_dependency "rake"
|
25
|
+
gem.add_development_dependency "simplecov"
|
26
|
+
gem.add_development_dependency "coveralls"
|
27
|
+
gem.add_development_dependency "mime-types", "~> 1.25.1"
|
27
28
|
end
|
data/lib/image_optimizer.rb
CHANGED
@@ -1,16 +1,17 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
1
|
+
require 'image_optimizer/version'
|
2
|
+
require 'image_optimizer/jpeg_optimizer'
|
3
|
+
require 'image_optimizer/png_optimizer'
|
4
4
|
|
5
5
|
class ImageOptimizer
|
6
|
-
attr_reader :path
|
6
|
+
attr_reader :path, :options
|
7
7
|
|
8
|
-
def initialize(path)
|
9
|
-
@path
|
8
|
+
def initialize(path, options = {})
|
9
|
+
@path = path
|
10
|
+
@options = options
|
10
11
|
end
|
11
12
|
|
12
13
|
def optimize
|
13
|
-
JPEGOptimizer.new(path).optimize
|
14
|
+
JPEGOptimizer.new(path, options).optimize
|
14
15
|
PNGOptimizer.new(path).optimize
|
15
16
|
end
|
16
|
-
end
|
17
|
+
end
|
@@ -1,9 +1,10 @@
|
|
1
1
|
class ImageOptimizer
|
2
2
|
class JPEGOptimizer
|
3
|
-
attr_reader :path
|
3
|
+
attr_reader :path, :quality
|
4
4
|
|
5
|
-
def initialize(path)
|
5
|
+
def initialize(path, options = {})
|
6
6
|
@path = path
|
7
|
+
@quality = options[:quality]
|
7
8
|
end
|
8
9
|
|
9
10
|
def optimize
|
@@ -23,11 +24,15 @@ class ImageOptimizer
|
|
23
24
|
end
|
24
25
|
|
25
26
|
def extension(path)
|
26
|
-
path.split(
|
27
|
+
path.split('.').last.downcase
|
27
28
|
end
|
28
29
|
|
29
30
|
def optimize_jpeg
|
30
|
-
system "#{jpeg_optimizer_bin} -f --strip-all #{path}"
|
31
|
+
system "#{jpeg_optimizer_bin} -f --strip-all #{optional_max_quality} --all-progressive #{path}"
|
32
|
+
end
|
33
|
+
|
34
|
+
def optional_max_quality
|
35
|
+
"--max=#{quality}" if (0..100).include?(quality)
|
31
36
|
end
|
32
37
|
|
33
38
|
def jpeg_optimizer_present?
|
@@ -7,7 +7,8 @@ describe ImageOptimizer::JPEGOptimizer do
|
|
7
7
|
|
8
8
|
it 'optimizes the jpeg' do
|
9
9
|
jpeg_optimizer.stub(:jpeg_optimizer_bin => '/usr/local/bin/jpegoptim')
|
10
|
-
|
10
|
+
optimizer_options = '-f --strip-all --all-progressive'
|
11
|
+
jpeg_optimizer.should_receive(:system).with("/usr/local/bin/jpegoptim #{optimizer_options} #{file_path}")
|
11
12
|
jpeg_optimizer.optimize
|
12
13
|
end
|
13
14
|
|
@@ -20,7 +21,16 @@ describe ImageOptimizer::JPEGOptimizer do
|
|
20
21
|
it 'detects if there is an ENV variable path to jpegoptim' do
|
21
22
|
image_optim_jpegoptim_bin_path = '/app/vendor/bundle/ruby/2.0.0/gems/image_optim_bin-0.0.2/bin/jpegoptim'
|
22
23
|
ENV['JPEGOPTIM_BIN'] = image_optim_jpegoptim_bin_path
|
23
|
-
|
24
|
+
optimizer_options = '-f --strip-all --all-progressive'
|
25
|
+
jpeg_optimizer.should_receive(:system).with("#{image_optim_jpegoptim_bin_path} #{optimizer_options} #{file_path}")
|
26
|
+
jpeg_optimizer.optimize
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'accepts an optional quality parameter' do
|
30
|
+
jpeg_optimizer = ImageOptimizer::JPEGOptimizer.new(file_path, :quality => 50)
|
31
|
+
jpeg_optimizer.stub(:jpeg_optimizer_bin => '/usr/local/bin/jpegoptim')
|
32
|
+
optimizer_options = '-f --strip-all --max=50 --all-progressive'
|
33
|
+
jpeg_optimizer.should_receive(:system).with("/usr/local/bin/jpegoptim #{optimizer_options} #{file_path}")
|
24
34
|
jpeg_optimizer.optimize
|
25
35
|
end
|
26
36
|
end
|
@@ -1,11 +1,11 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe ImageOptimizer do
|
4
|
-
describe
|
4
|
+
describe '#optimize' do
|
5
5
|
it 'delegates to jpeg and png optimizers' do
|
6
6
|
ImageOptimizer::JPEGOptimizer.any_instance.should_receive(:optimize)
|
7
7
|
ImageOptimizer::PNGOptimizer.any_instance.should_receive(:optimize)
|
8
8
|
ImageOptimizer.new('/path/to/image.jpg').optimize
|
9
9
|
end
|
10
10
|
end
|
11
|
-
end
|
11
|
+
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.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Julian Tescher
|
@@ -35,64 +35,78 @@ cert_chain:
|
|
35
35
|
V3NaK2F3dzJpU05DNVhGaEEvOHhzSzBCbHRZUkY5blAKSEE0MVV0RHhySmtI
|
36
36
|
TDNOMXo4Z1BNWFNyRlQ0MUZSMndnazgrbDE0UCs3ZzFVVFBpZDJFSXdmdDJ4
|
37
37
|
T2JGZUE9PQotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg==
|
38
|
-
date: 2013-
|
38
|
+
date: 2013-12-04 00:00:00.000000000 Z
|
39
39
|
dependencies:
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
41
|
name: rspec
|
42
42
|
requirement: !ruby/object:Gem::Requirement
|
43
43
|
requirements:
|
44
|
-
- -
|
44
|
+
- - ! '>='
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version:
|
46
|
+
version: '0'
|
47
47
|
type: :development
|
48
48
|
prerelease: false
|
49
49
|
version_requirements: !ruby/object:Gem::Requirement
|
50
50
|
requirements:
|
51
|
-
- -
|
51
|
+
- - ! '>='
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version:
|
53
|
+
version: '0'
|
54
54
|
- !ruby/object:Gem::Dependency
|
55
55
|
name: rake
|
56
56
|
requirement: !ruby/object:Gem::Requirement
|
57
57
|
requirements:
|
58
|
-
- -
|
58
|
+
- - ! '>='
|
59
59
|
- !ruby/object:Gem::Version
|
60
|
-
version:
|
60
|
+
version: '0'
|
61
61
|
type: :development
|
62
62
|
prerelease: false
|
63
63
|
version_requirements: !ruby/object:Gem::Requirement
|
64
64
|
requirements:
|
65
|
-
- -
|
65
|
+
- - ! '>='
|
66
66
|
- !ruby/object:Gem::Version
|
67
|
-
version:
|
67
|
+
version: '0'
|
68
68
|
- !ruby/object:Gem::Dependency
|
69
69
|
name: simplecov
|
70
70
|
requirement: !ruby/object:Gem::Requirement
|
71
71
|
requirements:
|
72
|
-
- -
|
72
|
+
- - ! '>='
|
73
73
|
- !ruby/object:Gem::Version
|
74
|
-
version: 0
|
74
|
+
version: '0'
|
75
75
|
type: :development
|
76
76
|
prerelease: false
|
77
77
|
version_requirements: !ruby/object:Gem::Requirement
|
78
78
|
requirements:
|
79
|
-
- -
|
79
|
+
- - ! '>='
|
80
80
|
- !ruby/object:Gem::Version
|
81
|
-
version: 0
|
81
|
+
version: '0'
|
82
82
|
- !ruby/object:Gem::Dependency
|
83
83
|
name: coveralls
|
84
|
+
requirement: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ! '>='
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
type: :development
|
90
|
+
prerelease: false
|
91
|
+
version_requirements: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ! '>='
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
96
|
+
- !ruby/object:Gem::Dependency
|
97
|
+
name: mime-types
|
84
98
|
requirement: !ruby/object:Gem::Requirement
|
85
99
|
requirements:
|
86
100
|
- - ~>
|
87
101
|
- !ruby/object:Gem::Version
|
88
|
-
version:
|
102
|
+
version: 1.25.1
|
89
103
|
type: :development
|
90
104
|
prerelease: false
|
91
105
|
version_requirements: !ruby/object:Gem::Requirement
|
92
106
|
requirements:
|
93
107
|
- - ~>
|
94
108
|
- !ruby/object:Gem::Version
|
95
|
-
version:
|
109
|
+
version: 1.25.1
|
96
110
|
description: A simple image optimizer
|
97
111
|
email:
|
98
112
|
- jatescher@gmail.com
|
@@ -137,7 +151,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
137
151
|
version: '0'
|
138
152
|
requirements: []
|
139
153
|
rubyforge_project:
|
140
|
-
rubygems_version: 2.
|
154
|
+
rubygems_version: 2.1.5
|
141
155
|
signing_key:
|
142
156
|
specification_version: 4
|
143
157
|
summary: Simply optimize images via jpegoptim or OptiPNG
|
metadata.gz.sig
CHANGED
Binary file
|