image_svd 0.1.5 → 0.1.6
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.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/image_svd.gemspec +4 -4
- data/lib/image_svd/image_matrix.rb +9 -0
- data/lib/image_svd/util.rb +9 -0
- data/lib/image_svd/version.rb +1 -1
- data/spec/cli_spec.rb +4 -4
- metadata +18 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7ba755a5c928c69d8bf6b2e84e51cb1a2493d641
|
4
|
+
data.tar.gz: ed5574e929155f21d39e95cf1b9d7026babb6fba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7653dc6421ad11f66c938b34a653ad5ed74372c803984d38d904c8017021d994abaa278fde9e93ae2598efd9fc40927fac904846ed477f49db1432b54c12c5a9
|
7
|
+
data.tar.gz: de64f94042ef0e17949ae4bd4b7772f4f60c9ed210bc3b10ceb9d781d93a36b36b77d0584dcbf99f48482ff08583e1e50eeb4e8e09deea5f70cdcd68ffc91d6d
|
data/README.md
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
[](https://waffle.io/ilyakava/image_svd)
|
2
|
+
|
1
3
|
# image_svd
|
2
4
|
|
3
5
|
A utility to compress images, with interesting [Richter](https://artsy.net/artist/gerhard-richter)-esque blur effects at high compression.
|
data/image_svd.gemspec
CHANGED
@@ -20,10 +20,10 @@ Gem::Specification.new do |spec|
|
|
20
20
|
spec.test_files = spec.files.grep(/^(test|spec|features)\//)
|
21
21
|
spec.require_paths = ['lib']
|
22
22
|
|
23
|
-
spec.add_runtime_dependency 'pnm'
|
23
|
+
spec.add_runtime_dependency 'pnm', '~> 0.3'
|
24
24
|
spec.add_runtime_dependency 'trollop', '~> 2.0'
|
25
25
|
spec.add_development_dependency 'bundler', '~> 1.5'
|
26
|
-
spec.add_development_dependency 'rake'
|
27
|
-
spec.add_development_dependency 'pry'
|
28
|
-
spec.add_development_dependency 'rspec'
|
26
|
+
spec.add_development_dependency 'rake', '~> 10.3'
|
27
|
+
spec.add_development_dependency 'pry', '~> 0.9'
|
28
|
+
spec.add_development_dependency 'rspec', '~> 2.14'
|
29
29
|
end
|
@@ -131,6 +131,7 @@ module ImageSvd
|
|
131
131
|
cleansed_mtrx = ImageMatrix.matrix_to_valid_pixels(reconstructed_mtrx)
|
132
132
|
PNM::Image.new(cleansed_mtrx).write(intermediate)
|
133
133
|
%x(convert #{intermediate} #{out_path})
|
134
|
+
add_image_svd_credit!(out_path)
|
134
135
|
%x(rm #{intermediate})
|
135
136
|
end
|
136
137
|
end
|
@@ -145,10 +146,18 @@ module ImageSvd
|
|
145
146
|
ppm_matrix = ImageMatrix.rgb_to_ppm(*cleansed_mtrxs)
|
146
147
|
PNM::Image.new(ppm_matrix).write(intermediate)
|
147
148
|
%x(convert #{intermediate} #{out_path})
|
149
|
+
add_image_svd_credit!(out_path)
|
148
150
|
%x(rm #{intermediate})
|
149
151
|
end
|
150
152
|
end
|
151
153
|
|
154
|
+
# more info: http://www.imagemagick.org/Usage/formats/#profile_iptc
|
155
|
+
def add_image_svd_credit!(path)
|
156
|
+
%x(echo '#{Util::IMAGE_CREDIT}' > iptcData.pro)
|
157
|
+
%x(convert #{path} +profile 8BIM -profile 8BIMTEXT:iptcData.pro #{path})
|
158
|
+
%x(rm iptcData.pro)
|
159
|
+
end
|
160
|
+
|
152
161
|
def save_svd(path)
|
153
162
|
out_path = extension_swap(path, 'svdim')
|
154
163
|
string = @channels.map(&:to_h).to_json
|
data/lib/image_svd/util.rb
CHANGED
@@ -12,5 +12,14 @@ module ImageSvd
|
|
12
12
|
head = path.gsub(/\..{1,5}$/, '')
|
13
13
|
"#{head}#{suffix}.#{new_ext}"
|
14
14
|
end
|
15
|
+
|
16
|
+
IMAGE_CREDIT = <<-EOS
|
17
|
+
2#0="�"
|
18
|
+
2#120#Caption="Created with image_svd"
|
19
|
+
2#40#Special Instructions="http://www.rubygems.org/gems/image_svd"
|
20
|
+
2#80#Byline="http://www.ilyakavalerov.com"
|
21
|
+
2#110#Credit="Image manipulation by Ilya Kavalerov"
|
22
|
+
2#221="0:0:0:-00001"
|
23
|
+
EOS
|
15
24
|
end
|
16
25
|
end
|
data/lib/image_svd/version.rb
CHANGED
data/spec/cli_spec.rb
CHANGED
@@ -26,7 +26,7 @@ describe 'CLI' do
|
|
26
26
|
m2 = i2.channels.first.reconstruct_matrix
|
27
27
|
diff_matrix = m - m2
|
28
28
|
diff_matrix.to_a.flatten.each do |diff_component|
|
29
|
-
diff_component.abs.should be
|
29
|
+
diff_component.abs.should be <= 5
|
30
30
|
end
|
31
31
|
|
32
32
|
# cleanup
|
@@ -54,7 +54,7 @@ describe 'CLI' do
|
|
54
54
|
m2 = i2.channels.first.reconstruct_matrix
|
55
55
|
diff_matrix = m - m2
|
56
56
|
diff_matrix.to_a.flatten.each do |diff_component|
|
57
|
-
diff_component.abs.should be
|
57
|
+
diff_component.abs.should be <= 5
|
58
58
|
end
|
59
59
|
# cleanup
|
60
60
|
%x(rm #{conv}_two_2_svs.jpg #{conv}.svdim)
|
@@ -84,7 +84,7 @@ describe 'CLI' do
|
|
84
84
|
m2 = i2.channels.map { |c| c.reconstruct_matrix }
|
85
85
|
diff_matricies = (0..2).to_a.map { |idx| m[idx] - m2[idx] }
|
86
86
|
diff_matricies.map(&:to_a).flatten.each do |diff_component|
|
87
|
-
diff_component.abs.should be
|
87
|
+
diff_component.abs.should be <= 5
|
88
88
|
end
|
89
89
|
# cleanup
|
90
90
|
%x(rm #{conv}_2_svs.jpg)
|
@@ -111,7 +111,7 @@ describe 'CLI' do
|
|
111
111
|
m2 = i2.channels.map { |c| c.reconstruct_matrix }
|
112
112
|
diff_matricies = (0..2).to_a.map { |idx| m[idx] - m2[idx] }
|
113
113
|
diff_matricies.map(&:to_a).flatten.each do |diff_component|
|
114
|
-
diff_component.abs.should be
|
114
|
+
diff_component.abs.should be <= 5
|
115
115
|
end
|
116
116
|
# cleanup
|
117
117
|
%x(rm #{conv}_two_2_svs.jpg #{conv}.svdim)
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: image_svd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ilya Kavalerov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-07-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pnm
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
19
|
+
version: '0.3'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '0'
|
26
|
+
version: '0.3'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: trollop
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -56,44 +56,44 @@ dependencies:
|
|
56
56
|
name: rake
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '10.3'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '10.3'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: pry
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - "
|
73
|
+
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '0'
|
75
|
+
version: '0.9'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - "
|
80
|
+
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '0'
|
82
|
+
version: '0.9'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: rspec
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- - "
|
87
|
+
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
89
|
+
version: '2.14'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- - "
|
94
|
+
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
96
|
+
version: '2.14'
|
97
97
|
description: |2
|
98
98
|
Break down images into their singular value decomposition.
|
99
99
|
email:
|