piet 0.1.1 → 0.1.2
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.
- data/Gemfile.lock +1 -1
- data/README.md +47 -34
- data/lib/piet/carrierwave_extension.rb +1 -1
- data/lib/piet/version.rb +1 -1
- metadata +2 -2
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -29,11 +29,15 @@ Usage
|
|
29
29
|
|
30
30
|
You simply require the gem
|
31
31
|
|
32
|
-
|
32
|
+
```ruby
|
33
|
+
require 'piet'
|
34
|
+
```
|
33
35
|
|
34
36
|
and then call the **optimize** method:
|
35
37
|
|
36
|
-
|
38
|
+
```ruby
|
39
|
+
Piet.optimize(path, opts)
|
40
|
+
```
|
37
41
|
|
38
42
|
The options are:
|
39
43
|
|
@@ -48,53 +52,61 @@ This way, you can optimize the original image or a version.
|
|
48
52
|
|
49
53
|
In order to do that, firstly add **piet** to your Gemfile:
|
50
54
|
|
51
|
-
|
55
|
+
```ruby
|
56
|
+
gem 'piet'
|
57
|
+
```
|
52
58
|
|
53
59
|
Then go to your CarrierWave uploader and include Piet's extension:
|
54
60
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
61
|
+
```ruby
|
62
|
+
class ImageUploader < CarrierWave::Uploader::Base
|
63
|
+
...
|
64
|
+
include Piet::CarrierWaveExtension
|
65
|
+
...
|
66
|
+
end
|
67
|
+
```
|
60
68
|
|
61
69
|
And finally use Piet! For all the images:
|
62
70
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
71
|
+
```ruby
|
72
|
+
class ImageUploader < CarrierWave::Uploader::Base
|
73
|
+
...
|
74
|
+
process :optimize
|
75
|
+
...
|
76
|
+
end
|
77
|
+
```
|
68
78
|
|
69
79
|
Or only for a version:
|
70
80
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
81
|
+
```ruby
|
82
|
+
class ImageUploader < CarrierWave::Uploader::Base
|
83
|
+
...
|
84
|
+
version :normal do
|
85
|
+
...
|
86
|
+
process :optimize
|
87
|
+
end
|
88
|
+
...
|
89
|
+
end
|
90
|
+
```
|
79
91
|
|
80
92
|
Examples
|
81
93
|
--------
|
82
94
|
|
83
95
|
* Simply Optimizing
|
84
96
|
|
85
|
-
|
86
|
-
|
97
|
+
```ruby
|
98
|
+
Piet.optimize('/my/wonderful/pics/piggy.png')
|
87
99
|
|
88
|
-
|
89
|
-
|
100
|
+
Piet.optimize('/my/wonderful/pics/pony.jpg')
|
101
|
+
```
|
90
102
|
|
91
103
|
would optimize those PNG, GIF and JPEG files but ouput nothing.
|
92
104
|
|
93
105
|
* Optimizing PNG/GIF and getting feedback
|
94
106
|
|
95
|
-
|
96
|
-
|
97
|
-
|
107
|
+
```ruby
|
108
|
+
Piet.optimize('/my/wonderful/pics/piggy.png', :verbose => true)
|
109
|
+
```
|
98
110
|
|
99
111
|
would optimize that PNG/GIF file and ouput something similar to this one:
|
100
112
|
|
@@ -104,20 +116,20 @@ would optimize that PNG/GIF file and ouput something similar to this one:
|
|
104
116
|
Input file size = 157426 bytes
|
105
117
|
|
106
118
|
Trying:
|
107
|
-
zc = 9 zm = 9 zs = 0 f = 1
|
108
|
-
zc = 9 zm = 8 zs = 0 f = 1
|
119
|
+
zc = 9 zm = 9 zs = 0 f = 1 IDAT size = 156966
|
120
|
+
zc = 9 zm = 8 zs = 0 f = 1 IDAT size = 156932
|
109
121
|
|
110
122
|
Selecting parameters:
|
111
|
-
zc = 9 zm = 8 zs = 0 f = 1
|
123
|
+
zc = 9 zm = 8 zs = 0 f = 1 IDAT size = 156932
|
112
124
|
|
113
125
|
Output IDAT size = 156932 bytes (437 bytes decrease)
|
114
126
|
Output file size = 156989 bytes (437 bytes = 0.28% decrease)
|
115
127
|
|
116
128
|
* Optimizing JPEG and getting feedback
|
117
129
|
|
118
|
-
|
119
|
-
|
120
|
-
|
130
|
+
```ruby
|
131
|
+
Piet.optimize('/my/wonderful/pics/pony.jpg', :verbose => true)
|
132
|
+
```
|
121
133
|
|
122
134
|
would optimize that JPEG file and ouput similar to this one:
|
123
135
|
|
@@ -134,3 +146,4 @@ Changelog
|
|
134
146
|
|
135
147
|
* v.0.1.0 Optimization of PNGs and JPEGs, including an integration with Carrierwave
|
136
148
|
* v.0.1.1 Added support for GIFs. Added an extra option to use pngquant (thanks @rogercampos). Solved problems with Carrierwave >= 0.6 (thanks @mllocs and @huacnlee).
|
149
|
+
* v.0.1.2 Fixed some problems with missing processing, thanks to @lentg.
|
data/lib/piet/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: piet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-01-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|