photo_mosaic 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5f7db9f1825c8ea011b24140162b4142ef82072b9d704fa7dcdaa100301e4039
4
- data.tar.gz: 58d7115186a4aea4d01d284c1b5a0fe90f53e6d4f1512688cbe6a111b06d2c14
3
+ metadata.gz: 062c5d511bbf57b980fd6781f2ac939b51bd1ae8c6944a873423acd41ae43c35
4
+ data.tar.gz: 25438636b5f94b2cbe74ace8bab108db4faf54fae39105a122730d7c65df51fb
5
5
  SHA512:
6
- metadata.gz: a78549c799456e8585b253f43d7efefeadb3982694fca59fdd2a9d337fdb530d28f74cad7ad239cdc0703c21b0c5ec898bffed163158fb74c82e338c2a8da4ac
7
- data.tar.gz: 51bdc9d4ba4849adf1aa2e9ec96b183bd82a2322a3968e2e76442ef20f556ba5e813a4fc6230b32962257384ddf01f84be9de2636dd6d44168eea64094d95ded
6
+ metadata.gz: e69a3313e07dd58aefbfa477f2316c2942c9b15b05fe52632fbee1923cd9f62fa46797de33942d7ed3fffc59b0c948dcd0db8bbb8f74475e503b53c54fe1b439
7
+ data.tar.gz: fc692654db3730ec7975c63221ff3457b40e649b7527384064e0c1424220e47c7704124f2026271daf210e0ae661240641049817be8a5fae9ae8ed83b66509b2
data/.gitignore CHANGED
@@ -40,5 +40,5 @@ Gemfile.lock
40
40
  /.idea/
41
41
  .rspec_status
42
42
 
43
- /lib/main.rb
43
+ main.rb
44
44
  .DS_Store
data/Gemfile CHANGED
@@ -14,3 +14,5 @@ gem "ruby-progressbar", "~> 1.11"
14
14
  gem "simplecov", "~> 0.21", require: false, group: :test
15
15
  gem "wisper", "~> 2.0.1"
16
16
  gem "wisper-rspec", "~>1.1.0", require: false, group: :test
17
+
18
+ gem "optimist", "~> 3.0"
data/README.md CHANGED
@@ -1,38 +1,15 @@
1
1
  # PhotoMosaic
2
2
  Create beautiful photo mosaics from your own images.
3
3
 
4
- ![Alt text](docs/img/eltz_flowers.png "Eltz Castle made of flower tiles")
4
+ ![Alt text](docs/img/tiger_mosaic.png "tiger made of flower tiles")
5
5
  ## Installation
6
6
 
7
- Add this line to your application's Gemfile:
8
-
9
- ```ruby
10
- gem 'photo_mosaic'
11
- ```
12
-
13
- And then execute:
14
-
15
- $ bundle install
16
-
17
- Or install it yourself with:
18
-
19
7
  $ gem install photo_mosaic
20
8
 
21
9
  ## Usage
22
10
 
23
- ```ruby
24
- require "photo_mosaic"
25
-
26
- PhotoMosaic.subscribe(PhotoMosaic::ProgressBar.new)
11
+ $ photo_mosaic --original images/original.jpg --tiles images/tiles --output mosaic.jpg --tile-width 20 --tile-height 20
27
12
 
28
- PhotoMosaic.create(
29
- original_image: "./images/castle.png",
30
- tile_images: Dir["./images/tile_images/flowers/*"],
31
- output_image: "./images/castle_mosaic.png",
32
- tile_width: 25,
33
- tile_height: 25
34
- );
35
- ```
36
13
  ## Development
37
14
 
38
15
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
Binary file
data/exe/photo_mosaic ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require "photo_mosaic"
3
+ PhotoMosaic::Parser.run(ARGV)
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PhotoMosaic
4
+ class Parser
5
+ def self.tokenize(_args)
6
+ opts = Optimist.options do
7
+ opt :original, 'Original Image', type: :string
8
+ opt :tiles, 'Tile Images', type: :string
9
+ opt :output, 'Output File', type: :string
10
+ opt :tile_width, 'Tile Width', default: 20
11
+ opt :tile_height, 'Tile Height', default: 20
12
+ end
13
+ Optimist.die :original, 'must be specified' if opts[:original].nil?
14
+ opts
15
+ end
16
+
17
+ def self.run(args)
18
+ opts = tokenize(args)
19
+ PhotoMosaic.subscribe(PhotoMosaic::ProgressBar.new)
20
+ begin
21
+ PhotoMosaic.create(
22
+ original_image: opts[:original],
23
+ tile_images: Dir["#{opts[:tiles]}/*"],
24
+ output_image: opts[:output],
25
+ tile_width: opts[:tile_width],
26
+ tile_height: opts[:tile_height]
27
+ )
28
+ rescue Exception => e
29
+ puts e.message
30
+ exit false
31
+ end
32
+ end
33
+ end
34
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PhotoMosaic
4
- VERSION = "0.1.4"
4
+ VERSION = "0.1.5"
5
5
  end
data/lib/photo_mosaic.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require "mini_magick"
2
+ require "optimist"
2
3
  require "ruby-progressbar"
3
4
  require "wisper"
4
5
  require "zeitwerk"
data/photo_mosaic.gemspec CHANGED
@@ -16,15 +16,15 @@ Gem::Specification.new do |spec|
16
16
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
17
17
  spec.files = File.directory?(".git") ? `git ls-files`.split($/) : Dir.glob("**/*")
18
18
  spec.bindir = "exe"
19
- spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
19
+ spec.executables = ["photo_mosaic"]
20
20
  spec.require_paths = ["lib"]
21
21
 
22
22
  # Uncomment to register a new dependency of your gem
23
- spec.add_dependency "bundler"
24
- spec.add_dependency "zeitwerk"
25
- spec.add_dependency "mini_magick"
26
- spec.add_dependency "ruby-progressbar"
27
- spec.add_dependency "wisper"
23
+ spec.add_dependency "bundler", ["2.3.5"]
24
+ spec.add_dependency "zeitwerk", ["2.5.3"]
25
+ spec.add_dependency "mini_magick", ["4.11.0"]
26
+ spec.add_dependency "ruby-progressbar", ["1.11.0"]
27
+ spec.add_dependency "wisper", ["2.0.1"]
28
28
 
29
29
  # For more information and docs about making a new gem, checkout our
30
30
  # guide at: https://bundler.io/guides/creating_gem.html
metadata CHANGED
@@ -1,89 +1,90 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: photo_mosaic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Axel Molina
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-05-07 00:00:00.000000000 Z
11
+ date: 2022-01-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: 2.3.5
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: 2.3.5
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: zeitwerk
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - '='
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: 2.5.3
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - '='
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: 2.5.3
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: mini_magick
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - '='
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: 4.11.0
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - '='
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
54
+ version: 4.11.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: ruby-progressbar
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - '='
60
60
  - !ruby/object:Gem::Version
61
- version: '0'
61
+ version: 1.11.0
62
62
  type: :runtime
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: '0'
68
+ version: 1.11.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: wisper
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ">="
73
+ - - '='
74
74
  - !ruby/object:Gem::Version
75
- version: '0'
75
+ version: 2.0.1
76
76
  type: :runtime
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: 2.0.1
83
83
  description:
84
84
  email:
85
85
  - axel.molina@gmail.com
86
- executables: []
86
+ executables:
87
+ - photo_mosaic
87
88
  extensions: []
88
89
  extra_rdoc_files: []
89
90
  files:
@@ -98,15 +99,16 @@ files:
98
99
  - bin/setup
99
100
  - docs/.DS_Store
100
101
  - docs/img/.DS_Store
101
- - docs/img/eltz_flowers.png
102
+ - docs/img/tiger_mosaic.png
103
+ - exe/photo_mosaic
102
104
  - lib/photo_mosaic.rb
103
105
  - lib/photo_mosaic/image.rb
104
106
  - lib/photo_mosaic/mini_magick_io.rb
105
107
  - lib/photo_mosaic/mini_magick_xform.rb
106
108
  - lib/photo_mosaic/mosaic.rb
109
+ - lib/photo_mosaic/parser.rb
107
110
  - lib/photo_mosaic/progress_bar.rb
108
111
  - lib/photo_mosaic/version.rb
109
- - main.rb
110
112
  - photo_mosaic.gemspec
111
113
  - spec/.DS_Store
112
114
  - spec/images/.DS_Store
Binary file
data/main.rb DELETED
@@ -1,11 +0,0 @@
1
- require_relative "lib/photo_mosaic"
2
-
3
- PhotoMosaic.subscribe(PhotoMosaic::ProgressBar.new)
4
-
5
- PhotoMosaic.create(
6
- original_image: "/users/axel/pictures/tiger.jpg",
7
- tile_images: Dir["/users/axel/pictures/flowers/*"],
8
- output_image: "/users/axel/pictures/tiger_mosaic.png",
9
- tile_width: 20,
10
- tile_height: 20
11
- );