image_mosaic 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/image_mosaic.rb +9 -1
- data/lib/image_mosaic/data/setting.rb +18 -0
- data/lib/image_mosaic/image/parent.rb +7 -9
- data/lib/image_mosaic/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4a1a7071ef66b370eb317cb4253fc2a27f1dabe6
|
4
|
+
data.tar.gz: 44e791111586332891ef202a18cc3995b25cee15
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 281facb0beed13789225c0463cdc90257d144d2fb3634140d5c04152ca84fe016c5e12bc72dc9fe2555696d97eff0cc8bf032407077f2e6e5b26b84afcdca69d
|
7
|
+
data.tar.gz: 3a924e0c83cb1d5e124226abec8e5da90d5e24a07b7e39f7f64f946fc45d39520527e08ec15a2481b9145fbec7494eefb17d7164897e493e0e6d8262f6af8b1a
|
data/lib/image_mosaic.rb
CHANGED
@@ -3,11 +3,15 @@ require 'mini_magick'
|
|
3
3
|
require 'tempfile'
|
4
4
|
require 'securerandom'
|
5
5
|
require 'image_mosaic/operations/compositor'
|
6
|
+
require 'image_mosaic/data/setting'
|
6
7
|
require 'image_mosaic/data/validator'
|
7
8
|
require 'image_mosaic/image/parent'
|
8
9
|
require 'image_mosaic/image/child'
|
9
10
|
|
10
11
|
module ImageMosaic
|
12
|
+
HEIGHT = 1000
|
13
|
+
WIDTH = 1000
|
14
|
+
|
11
15
|
class Construct
|
12
16
|
def initialize(items)
|
13
17
|
@items = items
|
@@ -20,7 +24,11 @@ module ImageMosaic
|
|
20
24
|
private
|
21
25
|
|
22
26
|
def parent
|
23
|
-
@parent ||= Image::Parent.new(valid_items).create
|
27
|
+
@parent ||= Image::Parent.new(valid_items, colour: 'white', columns: setting.columns, dimension: setting.dimension).create
|
28
|
+
end
|
29
|
+
|
30
|
+
def setting
|
31
|
+
@setting ||= Data::Setting.new(valid_items.count)
|
24
32
|
end
|
25
33
|
|
26
34
|
def valid_items
|
@@ -1,26 +1,24 @@
|
|
1
1
|
module ImageMosaic
|
2
2
|
module Image
|
3
|
-
#Takes an array of images and metrics and then returns a single image of
|
3
|
+
#Takes an array of images and metrics and then returns a single image of composited images.
|
4
4
|
class Parent
|
5
|
-
def initialize(items,
|
5
|
+
def initialize(items, colour: 'white', columns: 5, dimension: 200)
|
6
6
|
@items = items
|
7
|
-
@width = width
|
8
|
-
@height = height
|
9
7
|
@colour = colour
|
10
8
|
@columns = columns
|
11
|
-
@
|
9
|
+
@dimension = dimension
|
12
10
|
end
|
13
11
|
|
14
12
|
def create
|
15
|
-
image.run_command(:convert, '-size', "#{
|
13
|
+
image.run_command(:convert, '-size', "#{WIDTH}x#{HEIGHT}", "xc:#{@colour}", image.path)
|
16
14
|
y = 0
|
17
15
|
sliced_grid.each do |row|
|
18
16
|
x = 0
|
19
17
|
row.each do |cell|
|
20
18
|
@image = add_image(cell, x, y)
|
21
|
-
x += @
|
19
|
+
x += @dimension
|
22
20
|
end
|
23
|
-
y += @
|
21
|
+
y += @dimension
|
24
22
|
end
|
25
23
|
image
|
26
24
|
end
|
@@ -32,7 +30,7 @@ module ImageMosaic
|
|
32
30
|
end
|
33
31
|
|
34
32
|
def add_image(child_image, x, y)
|
35
|
-
Operations::Compositor.new(@image, child_image).save(x, y, type: 'Over', dimension: @
|
33
|
+
Operations::Compositor.new(@image, child_image).save(x, y, type: 'Over', dimension: @dimension)
|
36
34
|
end
|
37
35
|
|
38
36
|
def temp_file
|
data/lib/image_mosaic/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: image_mosaic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dan Goodwin
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-04-
|
11
|
+
date: 2017-04-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -85,6 +85,7 @@ files:
|
|
85
85
|
- bin/setup
|
86
86
|
- image_mosaic.gemspec
|
87
87
|
- lib/image_mosaic.rb
|
88
|
+
- lib/image_mosaic/data/setting.rb
|
88
89
|
- lib/image_mosaic/data/validator.rb
|
89
90
|
- lib/image_mosaic/image/child.rb
|
90
91
|
- lib/image_mosaic/image/parent.rb
|