jpreg 0.4 → 0.5
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/Rakefile +1 -1
- data/bin/jpreg +43 -3
- data/jpreg.gemspec +2 -2
- metadata +2 -2
data/Rakefile
CHANGED
data/bin/jpreg
CHANGED
@@ -9,11 +9,14 @@ options = {
|
|
9
9
|
:output => "#{ENV['HOME']}/Desktop/jpreg-#{timestamp}.jpg",
|
10
10
|
:quiet => false,
|
11
11
|
:times => 5,
|
12
|
-
:quality => 40
|
12
|
+
:quality => 40,
|
13
|
+
:resize => false,
|
14
|
+
:resize_amount => 50,
|
15
|
+
:range => 5
|
13
16
|
}
|
14
17
|
|
15
18
|
parser = OptionParser.new do |opts|
|
16
|
-
opts.version = "0.
|
19
|
+
opts.version = "0.5"
|
17
20
|
opts.banner = "Usage: jpreg [-h] [-o /path/to/output] [-q] [-v] FILE"
|
18
21
|
|
19
22
|
opts.separator ""
|
@@ -44,6 +47,15 @@ parser = OptionParser.new do |opts|
|
|
44
47
|
puts opts
|
45
48
|
exit
|
46
49
|
end
|
50
|
+
|
51
|
+
opts.on("-r", "--resize 50", "Resize, then de-resize") do |resize_amount|
|
52
|
+
options[:resize] = true
|
53
|
+
options[:resize_amount] = resize_amount unless resize_amount.to_i == 0
|
54
|
+
end
|
55
|
+
|
56
|
+
opts.on("--range 5", "Range of quality deviation") do |range|
|
57
|
+
options[:range] = range.to_i
|
58
|
+
end
|
47
59
|
end
|
48
60
|
|
49
61
|
parser.parse!
|
@@ -79,8 +91,22 @@ end
|
|
79
91
|
|
80
92
|
options[:times].to_i.times do
|
81
93
|
|
94
|
+
if options[:resize]
|
95
|
+
cmd = ["convert"]
|
96
|
+
cmd << "-resize" << "#{options[:resize_amount]}%"
|
97
|
+
cmd << File.join(path, "#{modified_base_name}.tiff")
|
98
|
+
cmd << File.join(path, "#{modified_base_name}2.tiff")
|
99
|
+
|
100
|
+
unless system(*cmd)
|
101
|
+
puts "Something broke when we were compressing your jpeg. Shit."
|
102
|
+
exit(1)
|
103
|
+
end
|
104
|
+
|
105
|
+
FileUtils.mv File.join(path, "#{modified_base_name}2.tiff"), File.join(path, "#{modified_base_name}.tiff")
|
106
|
+
end
|
107
|
+
|
82
108
|
cmd = ["convert"]
|
83
|
-
cmd << "-quality" << (options[:quality].to_i + (-
|
109
|
+
cmd << "-quality" << (options[:quality].to_i + (-options[:range]..options[:range]).to_a.shuffle.first).to_s
|
84
110
|
cmd << File.join(path, "#{modified_base_name}.tiff")
|
85
111
|
cmd << File.join(path, "#{modified_base_name}.jpg")
|
86
112
|
|
@@ -89,6 +115,20 @@ options[:times].to_i.times do
|
|
89
115
|
exit(1)
|
90
116
|
end
|
91
117
|
|
118
|
+
if options[:resize]
|
119
|
+
cmd = ["convert"]
|
120
|
+
cmd << "-resize" << "#{100.0 / options[:resize_amount].to_f * 100}%"
|
121
|
+
cmd << File.join(path, "#{modified_base_name}.jpg")
|
122
|
+
cmd << File.join(path, "#{modified_base_name}2.jpg")
|
123
|
+
|
124
|
+
unless system(*cmd)
|
125
|
+
puts "Something broke when we were compressing your jpeg. Shit."
|
126
|
+
exit(1)
|
127
|
+
end
|
128
|
+
|
129
|
+
FileUtils.mv File.join(path, "#{modified_base_name}2.jpg"), File.join(path, "#{modified_base_name}.jpg")
|
130
|
+
end
|
131
|
+
|
92
132
|
cmd = ["convert"]
|
93
133
|
cmd << File.join(path, "#{modified_base_name}.jpg")
|
94
134
|
cmd << File.join(path, "#{modified_base_name}.tiff")
|
data/jpreg.gemspec
CHANGED
@@ -13,8 +13,8 @@ Gem::Specification.new do |s|
|
|
13
13
|
## If your rubyforge_project name is different, then edit it and comment out
|
14
14
|
## the sub! line in the Rakefile
|
15
15
|
s.name = 'jpreg'
|
16
|
-
s.version = '0.
|
17
|
-
s.date = '2013-04-
|
16
|
+
s.version = '0.5'
|
17
|
+
s.date = '2013-04-18'
|
18
18
|
# s.rubyforge_project = 'jpreg'
|
19
19
|
|
20
20
|
## Make sure your summary is short. The description may be as long
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jpreg
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.5'
|
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: 2013-04-
|
12
|
+
date: 2013-04-18 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Shitty jpeg compression for the masses
|
15
15
|
email: joshbrentkaplan@gmail.com
|