piet 0.1.2 → 0.1.3
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 +3 -1
- data/README.md +14 -0
- data/lib/piet.rb +2 -18
- data/lib/piet/version.rb +1 -1
- data/piet.gemspec +1 -0
- metadata +18 -2
data/Gemfile.lock
CHANGED
@@ -1,13 +1,15 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
piet (0.1.
|
4
|
+
piet (0.1.3)
|
5
|
+
png_quantizator
|
5
6
|
|
6
7
|
GEM
|
7
8
|
remote: http://rubygems.org/
|
8
9
|
specs:
|
9
10
|
ZenTest (4.5.0)
|
10
11
|
diff-lcs (1.1.3)
|
12
|
+
png_quantizator (0.1.0)
|
11
13
|
rspec (2.7.0)
|
12
14
|
rspec-core (~> 2.7.0)
|
13
15
|
rspec-expectations (~> 2.7.0)
|
data/README.md
CHANGED
@@ -135,6 +135,19 @@ would optimize that JPEG file and ouput similar to this one:
|
|
135
135
|
|
136
136
|
/my/wonderful/pics/pony.jpg 235x314 24bit JFIF [OK] 15305 --> 13012 bytes (14.98%), optimized.
|
137
137
|
|
138
|
+
Pngquant
|
139
|
+
--------
|
140
|
+
You can use Piet to convert 24/32-bit PNG images to paletted (8-bit) PNGs. The conversion reduces file sizes significantly and preserves full alpha transparency.
|
141
|
+
|
142
|
+
Simply use Piet like this:
|
143
|
+
```ruby
|
144
|
+
Piet.pngquant('/a/path/where/you/store/the/file/to/convert')
|
145
|
+
```
|
146
|
+
|
147
|
+
Please note **you have to install the binary** in order to use the tool. Simply follow the instructions (and read more info about it) in [the official site](http://pngquant.org/).
|
148
|
+
|
149
|
+
Thanks to [@rogercampos](http://github.com/rogercampos) for providing the awesome **png_quantizator** gem, which you can find [here](https://github.com/rogercampos/png_quantizator).
|
150
|
+
|
138
151
|
TODO
|
139
152
|
----
|
140
153
|
|
@@ -147,3 +160,4 @@ Changelog
|
|
147
160
|
* v.0.1.0 Optimization of PNGs and JPEGs, including an integration with Carrierwave
|
148
161
|
* 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
162
|
* v.0.1.2 Fixed some problems with missing processing, thanks to @lentg.
|
163
|
+
* v.0.1.3 Use png_quantizator gem instead of the own implementation.
|
data/lib/piet.rb
CHANGED
@@ -10,10 +10,8 @@ module Piet
|
|
10
10
|
true
|
11
11
|
end
|
12
12
|
|
13
|
-
def pngquant(path
|
14
|
-
|
15
|
-
puts output if opts[:verbose]
|
16
|
-
true
|
13
|
+
def pngquant(path)
|
14
|
+
PngQuantizator::Image.new(path).quantize!
|
17
15
|
end
|
18
16
|
|
19
17
|
private
|
@@ -38,19 +36,5 @@ module Piet
|
|
38
36
|
vo = opts[:verbose] ? "-v" : "-q"
|
39
37
|
`jpegoptim -f --strip-all #{vo} #{path}`
|
40
38
|
end
|
41
|
-
|
42
|
-
def pngquant_for(path, opts)
|
43
|
-
opts.merge!({:force => true})
|
44
|
-
vo = if opts.any?
|
45
|
-
opts.keys.map{|x| "-#{x}"}.join(" ")
|
46
|
-
else
|
47
|
-
""
|
48
|
-
end
|
49
|
-
out = `pngquant #{vo} 256 #{path}`
|
50
|
-
blobs = path.split(".")
|
51
|
-
new_path = "#{blobs[0..-2].join(".")}-fs8.#{blobs[-1]}"
|
52
|
-
`mv #{new_path} #{path}`
|
53
|
-
out
|
54
|
-
end
|
55
39
|
end
|
56
40
|
end
|
data/lib/piet/version.rb
CHANGED
data/piet.gemspec
CHANGED
@@ -17,6 +17,7 @@ Gem::Specification.new do |s|
|
|
17
17
|
s.files = `git ls-files`.split("\n")
|
18
18
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
19
|
s.require_paths = ["lib"]
|
20
|
+
s.add_dependency "png_quantizator"
|
20
21
|
s.add_development_dependency "rspec"
|
21
22
|
s.add_development_dependency "ZenTest"
|
22
23
|
end
|
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.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,8 +9,24 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-02-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: png_quantizator
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
14
30
|
- !ruby/object:Gem::Dependency
|
15
31
|
name: rspec
|
16
32
|
requirement: !ruby/object:Gem::Requirement
|