pixel_dreamer 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.
- checksums.yaml +4 -4
- data/README.md +4 -3
- data/lib/pixel_dreamer/constants.rb +1 -1
- data/lib/pixel_dreamer/version.rb +1 -1
- data/lib/pixel_dreamer.rb +26 -4
- data/pixel_dreamer.gemspec +2 -2
- metadata +15 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 422174998f5c9dbeb0ab38b2a1612f50f2ef2c72
|
4
|
+
data.tar.gz: 2257e2f7d6795833689f7aeccc1037aa681b0019
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d4f534f28708d8ab5d03a1d3dad43633030b20c7f85a2c22ab6180ebc6d2347ef12b2a550a12f579f0452d25871084bc70a67e0734a6e6af6be342b9353d1823
|
7
|
+
data.tar.gz: 9ef9eed08717ae13a9fd3cc148e7473d515bf6e6632c71a94adf39b927dbe44c179ef784d678e069f3e57c26e41dc294974211cdd4160fa44602ffe5122b04d7
|
data/README.md
CHANGED
@@ -2,10 +2,10 @@
|
|
2
2
|
|
3
3
|
## Installation
|
4
4
|
|
5
|
-
Add this line to your application's Gemfile:
|
6
|
-
|
7
5
|
Install RMagick and ImageMagick from here: [RMagick](https://github.com/rmagick/rmagick)
|
8
6
|
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
9
|
```ruby
|
10
10
|
gem 'pixel_dreamer'
|
11
11
|
```
|
@@ -22,7 +22,7 @@ Or install it yourself as:
|
|
22
22
|
|
23
23
|
### ImageDreamer
|
24
24
|
|
25
|
-
To use pixel dreamer you must first create a new `PixelDreamer::ImageDreamer`
|
25
|
+
To use pixel dreamer you must first create a new `PixelDreamer::ImageDreamer` instance
|
26
26
|
to do this you must pass in the uri of the image you will be pixel sorting:
|
27
27
|
```ruby
|
28
28
|
image = PixelDreamer::ImageDreamer.new('/uri/image.png')
|
@@ -167,6 +167,7 @@ speed is used to set the length of time for each frame of the gif, it defaults t
|
|
167
167
|
- 60 fps: length of frame = 17 ms
|
168
168
|
the dither hash used to set the dither settings
|
169
169
|
the image_delay hash is used to pause the sequence on an image for a set amount of time
|
170
|
+
the patrol boolean is used to have the animation reverse at the end of it's cycle
|
170
171
|
|
171
172
|
#### uri_helper
|
172
173
|
|
@@ -48,7 +48,7 @@ module PixelDreamer
|
|
48
48
|
BARRAGE_DEFAULTS = { gif: false, compress: true, speed: 84 }.freeze
|
49
49
|
|
50
50
|
BRUTE_SORT_SAVE_WITH_SETTINGS_DEFAULTS = { settings: {}, output_name: nil, gif: false,
|
51
|
-
output_folder: false }.freeze
|
51
|
+
output_folder: false, resize: false, compress: false }.freeze
|
52
52
|
IMAGE_DELAY_DEFAULTS = { active: false, image_to_delay: 1, delay_length: 1000 }.freeze
|
53
53
|
|
54
54
|
DITHER_DEFAULTS = { active: false, number_of_colors: 200 }.freeze
|
data/lib/pixel_dreamer.rb
CHANGED
@@ -67,6 +67,8 @@ module PixelDreamer
|
|
67
67
|
options[:image] ||= @image
|
68
68
|
options = Constants::BRUTE_SORT_SAVE_WITH_SETTINGS_DEFAULTS.merge(options)
|
69
69
|
image = options[:image]
|
70
|
+
resize!(image) if options[:resize]
|
71
|
+
compress!(image) if options[:compress]
|
70
72
|
settings = Constants::DEFAULTS.merge(options[:settings])
|
71
73
|
output_name = options[:output_name]
|
72
74
|
gif = options[:gif]
|
@@ -84,6 +86,7 @@ module PixelDreamer
|
|
84
86
|
result = pixel_sorted.composite(overlay, Magick::CenterGravity, Magick::OverCompositeOp)
|
85
87
|
result.write(f.path)
|
86
88
|
end
|
89
|
+
f.path
|
87
90
|
end
|
88
91
|
|
89
92
|
##
|
@@ -196,6 +199,17 @@ module PixelDreamer
|
|
196
199
|
puts 'Image copied and compressed.'
|
197
200
|
end
|
198
201
|
|
202
|
+
##
|
203
|
+
# compresses image in place
|
204
|
+
def compress!(img)
|
205
|
+
puts 'Compressing image.'
|
206
|
+
image_optim = ImageOptim.new(allow_lossy: true, verbose: false, skip_missing_workers: true, optipng: false,
|
207
|
+
pngcrush: false, pngquant: { allow_lossy: true },
|
208
|
+
advpng: false, pngout: false, svgo: false)
|
209
|
+
image_optim.optimize_image(img)
|
210
|
+
puts 'compressed.'
|
211
|
+
end
|
212
|
+
|
199
213
|
##
|
200
214
|
# creates a gif using the @sequence_folder path and outputs gif into the @output_folder path
|
201
215
|
# once the image has been instantiated you can run this method without passing in any parameters
|
@@ -207,7 +221,7 @@ module PixelDreamer
|
|
207
221
|
# image.gif({speed: 42, dither: DITHER_DEFAULTS, image_delay: IMAGE_DELAY_DEFAULTS, output_name: 'image_gif'})
|
208
222
|
#
|
209
223
|
# or image.gif({speed: 42, dither: {active: false, number_of_colors: 200},
|
210
|
-
# image_delay: {active: false, image_to_delay: 1, delay_length: 1000}, output_name: 'image_gif'})
|
224
|
+
# image_delay: {active: false, image_to_delay: 1, delay_length: 1000}, patrol: true, output_name: 'image_gif'})
|
211
225
|
#
|
212
226
|
# speed is used to set the length of time for each frame of the gif, it defaults to milliseconds
|
213
227
|
# - 12 fps: length of frame = 84 ms
|
@@ -216,6 +230,7 @@ module PixelDreamer
|
|
216
230
|
# - 60 fps: length of frame = 17 ms
|
217
231
|
# the dither hash used to set the dither settings
|
218
232
|
# the image_delay hash is used to pause the sequence on an image for a set amount of time
|
233
|
+
# the patrol boolean is used to have the animation reverse at the end of it's cycle
|
219
234
|
def gif(options = {})
|
220
235
|
options[:output_name] ||= @input_name
|
221
236
|
options = Constants::GIF_DEFAULTS.merge(options)
|
@@ -233,7 +248,8 @@ module PixelDreamer
|
|
233
248
|
end
|
234
249
|
end
|
235
250
|
animation = ImageList.new(*sorted_dir)
|
236
|
-
animation.
|
251
|
+
animation.concat(patrol(animation)) unless options[:patrol].nil?
|
252
|
+
animation.ticks_per_second = 1000
|
237
253
|
puts 'Got images.'
|
238
254
|
animation.delay = options[:speed]
|
239
255
|
animation[(image_delay[:image_to_delay] - 1)].delay = image_delay[:delay_length] if image_delay[:active]
|
@@ -260,6 +276,13 @@ module PixelDreamer
|
|
260
276
|
|
261
277
|
private
|
262
278
|
|
279
|
+
def patrol(animation)
|
280
|
+
animation_reversed = animation.copy.reverse
|
281
|
+
animation_reversed.delete_at(0)
|
282
|
+
animation_reversed.delete_at(animation_reversed.length - 1)
|
283
|
+
animation_reversed
|
284
|
+
end
|
285
|
+
|
263
286
|
##
|
264
287
|
# checks if image is png, if it is, returns the uri passed else it converts to png
|
265
288
|
def prepare_image(image_uri)
|
@@ -378,8 +401,7 @@ module PixelDreamer
|
|
378
401
|
s = h * w
|
379
402
|
|
380
403
|
if s > 1500000
|
381
|
-
|
382
|
-
resized = i.resize(percentage)
|
404
|
+
resized = i.change_geometry('@1500000') {|col, row, img| img.resize(col, row)}
|
383
405
|
resized.write(image_uri)
|
384
406
|
end
|
385
407
|
end
|
data/pixel_dreamer.gemspec
CHANGED
@@ -21,8 +21,8 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
22
|
spec.require_paths = ["lib"]
|
23
23
|
|
24
|
-
spec.add_runtime_dependency 'rmagick', '~> 2.16.0'
|
25
|
-
spec.add_runtime_dependency 'pxlsrt', '~> 1.8.2'
|
24
|
+
spec.add_runtime_dependency 'rmagick', '~> 2.16', '>= 2.16.0'
|
25
|
+
spec.add_runtime_dependency 'pxlsrt', '~> 1.8', '>= 1.8.2'
|
26
26
|
spec.add_runtime_dependency 'image_optim', '~> 0.24.0'
|
27
27
|
spec.add_runtime_dependency 'image_optim_pack', '~> 0.3.0.20161108'
|
28
28
|
|
metadata
CHANGED
@@ -1,20 +1,23 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pixel_dreamer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christian Samuel
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-10-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rmagick
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.16'
|
20
|
+
- - ">="
|
18
21
|
- !ruby/object:Gem::Version
|
19
22
|
version: 2.16.0
|
20
23
|
type: :runtime
|
@@ -22,6 +25,9 @@ dependencies:
|
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
27
|
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '2.16'
|
30
|
+
- - ">="
|
25
31
|
- !ruby/object:Gem::Version
|
26
32
|
version: 2.16.0
|
27
33
|
- !ruby/object:Gem::Dependency
|
@@ -29,6 +35,9 @@ dependencies:
|
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
30
36
|
requirements:
|
31
37
|
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '1.8'
|
40
|
+
- - ">="
|
32
41
|
- !ruby/object:Gem::Version
|
33
42
|
version: 1.8.2
|
34
43
|
type: :runtime
|
@@ -36,6 +45,9 @@ dependencies:
|
|
36
45
|
version_requirements: !ruby/object:Gem::Requirement
|
37
46
|
requirements:
|
38
47
|
- - "~>"
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '1.8'
|
50
|
+
- - ">="
|
39
51
|
- !ruby/object:Gem::Version
|
40
52
|
version: 1.8.2
|
41
53
|
- !ruby/object:Gem::Dependency
|
@@ -163,7 +175,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
163
175
|
version: '0'
|
164
176
|
requirements: []
|
165
177
|
rubyforge_project:
|
166
|
-
rubygems_version: 2.
|
178
|
+
rubygems_version: 2.5.2.1
|
167
179
|
signing_key:
|
168
180
|
specification_version: 4
|
169
181
|
summary: A wrapper for pxlsrt, adds settings and gif creation.
|