geordi 0.14.9 → 0.15.0
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/optimize-png +76 -0
- data/lib/geordi/version.rb +1 -1
- metadata +25 -40
data/bin/optimize-png
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# pngcrush -rem allb -reduce -brute original.png optimized.png
|
4
|
+
# pngcrush -d target-dir/ *.png
|
5
|
+
#
|
6
|
+
# -rem allb — remove all extraneous data (Except transparency and gamma; to remove everything except transparency, try -rem alla)
|
7
|
+
# -reduce — eliminate unused colors and reduce bit-depth (If possible)
|
8
|
+
#
|
9
|
+
# -brute — attempt all optimization methods (Requires MUCH MORE processing time and may not improve optimization by much)
|
10
|
+
#
|
11
|
+
# original.png — the name of the original (unoptimized) PNG file
|
12
|
+
# optimized.png — the name of the new, optimized PNG file
|
13
|
+
# -d target-dir/ — bulk convert into this directory "target-dir"
|
14
|
+
#
|
15
|
+
# -rem cHRM -rem sRGB -rem gAMA -rem ICC — remove color profiles by name (shortcut -rem alla)
|
16
|
+
#
|
17
|
+
# An article explaining why removing gamma correction
|
18
|
+
# http://hsivonen.iki.fi/png-gamma/
|
19
|
+
|
20
|
+
def indented_puts(str="")
|
21
|
+
puts " #{str}"
|
22
|
+
end
|
23
|
+
|
24
|
+
def print_manual
|
25
|
+
script_name = "optimize-png"
|
26
|
+
|
27
|
+
indented_puts
|
28
|
+
indented_puts script_name
|
29
|
+
indented_puts "=" *script_name.size
|
30
|
+
indented_puts "- May reduce PNG file size lossless"
|
31
|
+
indented_puts "- Removes color profiles: cHRM, sRGB, gAMA, ICC, etc."
|
32
|
+
indented_puts "- Eliminates unused colors and reduce bit-depth (If possible)"
|
33
|
+
indented_puts
|
34
|
+
indented_puts "Batch optimize all *.png in current directory:"
|
35
|
+
indented_puts " #{script_name} output_directory"
|
36
|
+
indented_puts
|
37
|
+
indented_puts "Optimize single file:"
|
38
|
+
indented_puts " #{script_name} input.png output.png"
|
39
|
+
indented_puts
|
40
|
+
end
|
41
|
+
|
42
|
+
def optimization_default_args
|
43
|
+
args = ""
|
44
|
+
args << "-rem alla " # remove everything except transparency
|
45
|
+
args << "-rem text " # remove text chunks
|
46
|
+
args << "-reduce " # eliminate unused colors and reduce bit-depth (If possible)
|
47
|
+
args
|
48
|
+
end
|
49
|
+
|
50
|
+
def batch_optimize(script_args)
|
51
|
+
output_directory = script_args[0]
|
52
|
+
match_pattern = "*.*" # be aware of case sensitivty: *.png wouldn't match IMAGE.PNG # pngcrush does nothing with other files than png
|
53
|
+
exec "pngcrush -d #{output_directory} #{optimization_default_args} #{match_pattern}"
|
54
|
+
end
|
55
|
+
|
56
|
+
def single_file_optimize(script_args)
|
57
|
+
input_file = script_args[0]
|
58
|
+
output_file = script_args[1]
|
59
|
+
exec "pngcrush #{optimization_default_args} #{input_file} #{output_file}"
|
60
|
+
end
|
61
|
+
|
62
|
+
def main
|
63
|
+
if ARGV.size == 1
|
64
|
+
batch_optimize(ARGV)
|
65
|
+
elsif ARGV.size == 2
|
66
|
+
single_file_optimize(ARGV)
|
67
|
+
else
|
68
|
+
print_manual
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
main
|
73
|
+
|
74
|
+
|
75
|
+
|
76
|
+
|
data/lib/geordi/version.rb
CHANGED
metadata
CHANGED
@@ -1,27 +1,21 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: geordi
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.15.0
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 14
|
9
|
-
- 9
|
10
|
-
version: 0.14.9
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Henning Koch
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
date: 2013-04-10 00:00:00 Z
|
12
|
+
date: 2013-04-19 00:00:00.000000000 Z
|
19
13
|
dependencies: []
|
20
|
-
|
21
|
-
|
22
|
-
email:
|
14
|
+
description: Collection of command line tools we use in our daily work with Ruby,
|
15
|
+
Rails and Linux at makandra.
|
16
|
+
email:
|
23
17
|
- henning.koch@makandra.de
|
24
|
-
executables:
|
18
|
+
executables:
|
25
19
|
- apache-site
|
26
20
|
- b
|
27
21
|
- cap-all
|
@@ -39,6 +33,7 @@ executables:
|
|
39
33
|
- launchy_browser
|
40
34
|
- load-dump
|
41
35
|
- migrate-all
|
36
|
+
- optimize-png
|
42
37
|
- power-deploy
|
43
38
|
- power-rake
|
44
39
|
- remotify-local-branch
|
@@ -48,10 +43,8 @@ executables:
|
|
48
43
|
- shell-for
|
49
44
|
- tests
|
50
45
|
extensions: []
|
51
|
-
|
52
46
|
extra_rdoc_files: []
|
53
|
-
|
54
|
-
files:
|
47
|
+
files:
|
55
48
|
- .gitignore
|
56
49
|
- Gemfile
|
57
50
|
- README.md
|
@@ -73,6 +66,7 @@ files:
|
|
73
66
|
- bin/launchy_browser
|
74
67
|
- bin/load-dump
|
75
68
|
- bin/migrate-all
|
69
|
+
- bin/optimize-png
|
76
70
|
- bin/power-deploy
|
77
71
|
- bin/power-rake
|
78
72
|
- bin/remotify-local-branch
|
@@ -90,37 +84,28 @@ files:
|
|
90
84
|
- lib/geordi/version.rb
|
91
85
|
homepage: http://makandra.com
|
92
86
|
licenses: []
|
93
|
-
|
94
87
|
post_install_message:
|
95
88
|
rdoc_options: []
|
96
|
-
|
97
|
-
require_paths:
|
89
|
+
require_paths:
|
98
90
|
- lib
|
99
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
91
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
100
92
|
none: false
|
101
|
-
requirements:
|
102
|
-
- -
|
103
|
-
- !ruby/object:Gem::Version
|
104
|
-
|
105
|
-
|
106
|
-
- 0
|
107
|
-
version: "0"
|
108
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ! '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
109
98
|
none: false
|
110
|
-
requirements:
|
111
|
-
- -
|
112
|
-
- !ruby/object:Gem::Version
|
113
|
-
|
114
|
-
segments:
|
115
|
-
- 0
|
116
|
-
version: "0"
|
99
|
+
requirements:
|
100
|
+
- - ! '>='
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
117
103
|
requirements: []
|
118
|
-
|
119
104
|
rubyforge_project: geordi
|
120
105
|
rubygems_version: 1.8.24
|
121
106
|
signing_key:
|
122
107
|
specification_version: 3
|
123
|
-
summary: Collection of command line tools we use in our daily work with Ruby, Rails
|
108
|
+
summary: Collection of command line tools we use in our daily work with Ruby, Rails
|
109
|
+
and Linux at makandra.
|
124
110
|
test_files: []
|
125
|
-
|
126
111
|
has_rdoc:
|