slice_rename 0.6.0 → 0.7.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: aac69eaad8ffe87dfad9544205cabbc910fdf99d
4
- data.tar.gz: 3450638f1bb048993031bd9ff8e912d4c6a0b108
3
+ metadata.gz: b904682be754cd62856bc95c8ed2c2324dc6b9c9
4
+ data.tar.gz: 854a7644760d3bbe45c5f32da9cad82de618b152
5
5
  SHA512:
6
- metadata.gz: 4bf959f753e60da6758a368b222c744f39b84113ffade1fdd0bd948c565ffeb67936e7104313fc60f67622c3b16a96ea91ac5f0303f38f31fb2e43d776e0c24c
7
- data.tar.gz: d0245a15c94568ed488dc653e0a143f5ec910ec2795780e922bfeda75f06c31a34d776d145d2a077fa3e6c649d4986c83e633cbb64390c9362995c63ba6b1d4f
6
+ metadata.gz: 9f3ae0a13ddfa223431cd443fef54b08263ec6559ade5cc42af1d7b1626f5dd8456efb866b2d6b65fc4ab23c0940bac5a72aa75ab0c30298a48c8c29c2f0c129
7
+ data.tar.gz: 6b771932d174d1d87a0210fbc3ac7f656732063189f81f062b3a6813e09446584446d400093d2889eea41415f204b88df8cfc8219b2bd8bc4ed84f068d20196d
data/Gemfile.lock CHANGED
@@ -1,6 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
+ slice_rename (0.7.0)
4
5
 
5
6
  GEM
6
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -49,12 +49,11 @@ for more details on how the padding works.
49
49
 
50
50
  * `collapse_padding` - defaults to `false`
51
51
 
52
- The option called `collapse_padding` specifies if the padding between
53
- images are collapsed into eachother. Meaning that if the `padding` setting is 2
54
- and `collapse_padding` is true then it expects all images to be separated by 2
55
- pixels. If `collapse_padding` is false it will instead expect 2 pixels around
56
- each image resulting in 4 pixels between images but only 2 around the whole
57
- image.
52
+ This specifies if the padding between images are collapsed into
53
+ eachother. Meaning that if the `padding` setting is 2 and `collapse_padding` is
54
+ true then it expects all images to be separated by 2 pixels. If
55
+ `collapse_padding` is false it will instead expect 2 pixels around each image
56
+ resulting in 4 pixels between images but only 2 around the whole image.
58
57
 
59
58
  Images created by slice_rename do not collapse the padding so
60
59
  `collapse_padding` defaults to `false`. If you need the old behaviour simply
@@ -66,6 +65,13 @@ set it to `true` in your config file.
66
65
  transparent, if you want a color pass a hex color code. Keep in mind that you
67
66
  need quotes since the `#` character is reserved for comments in YAML.
68
67
 
68
+ * `full_grid` - defaults to `true`
69
+
70
+ This option decides if it should draw padding around empty images when
71
+ combining. When this is false empty spaces are filled with background color.
72
+ It defaults to true since that generates a grid that covers the whole image
73
+ however many empty images it has.
74
+
69
75
  * `background_color` - defaults to `none`
70
76
 
71
77
  The color of the background behind your individual slices. The default
data/lib/slice_rename.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  require 'slice_rename/cli'
2
2
 
3
3
  module SliceRename
4
- VERSION = '0.6.0'
4
+ VERSION = '0.7.0'
5
5
  end
@@ -12,6 +12,11 @@ module SliceRename
12
12
  geometry = "#{config.width}x#{config.height}\>+0+0"
13
13
  border = "#{config.padding}x#{config.padding}"
14
14
  tile = "#{config.columns}x#{config.rows}"
15
+ empty_image = config.full_grid ? "#{path}/empty.png" : 'null:'
16
+
17
+ if config.full_grid
18
+ generate_empty_image config
19
+ end
15
20
 
16
21
  config.suffixes.each do |suffix|
17
22
  if suffix != nil
@@ -19,12 +24,12 @@ module SliceRename
19
24
 
20
25
  if !Pathname.new(input_path).file?
21
26
  input_path = "#{path}/#{config.fallback}#{suffix}#{extension}"
22
- input_path = 'null:' if !Pathname.new(input_path).file?
27
+ input_path = empty_image if !Pathname.new(input_path).file?
23
28
  end
24
29
 
25
30
  images << input_path
26
31
  else
27
- images << 'null:'
32
+ images << empty_image
28
33
  end
29
34
  end
30
35
 
@@ -35,6 +40,10 @@ module SliceRename
35
40
  end
36
41
 
37
42
  save_combination(config, images, output_name, geometry, tile, border)
43
+
44
+ if config.full_grid
45
+ File.delete "#{path}/empty.png"
46
+ end
38
47
  end
39
48
 
40
49
  private
@@ -57,5 +66,13 @@ module SliceRename
57
66
  montage << output_name
58
67
  end
59
68
  end
69
+
70
+ def self.generate_empty_image(config)
71
+ MiniMagick::Tool::Convert.new do |convert|
72
+ convert.size "#{config.width}x#{config.height}"
73
+ convert << 'xc:transparent'
74
+ convert << "#{File.dirname(config.path)}/empty.png"
75
+ end
76
+ end
60
77
  end
61
78
  end
@@ -4,7 +4,7 @@ module SliceRename
4
4
  class Config
5
5
  attr_accessor :path, :debug, :fallback
6
6
  attr_reader :rows, :columns, :width, :height, :padding, :collapse_padding,
7
- :padding_color, :background_color
7
+ :padding_color, :background_color, :full_grid
8
8
 
9
9
  def initialize
10
10
  @path = ''
@@ -17,6 +17,7 @@ module SliceRename
17
17
  @suffixes = []
18
18
  @collapse_padding = false
19
19
  @padding_color = 'none'
20
+ @full_grid = true
20
21
  @background_color = 'none'
21
22
  @fallback = ''
22
23
  end
@@ -32,6 +33,7 @@ module SliceRename
32
33
  @suffixes = config.fetch('suffixes', @suffixes)
33
34
  @collapse_padding = config.fetch('collapse_padding', @collapse_padding)
34
35
  @padding_color = config.fetch('padding_color', @padding_color)
36
+ @full_grid = config.fetch('full_grid', @full_grid)
35
37
  @background_color = config.fetch('background_color', @background_color)
36
38
  end
37
39
 
@@ -20,8 +20,10 @@ RSpec.describe SliceRename::Combiner do
20
20
 
21
21
  describe '.combine_images' do
22
22
  it 'combines the images and saves them as a single image' do
23
+ allow_any_instance_of(Pathname).to receive(:file?).and_return(true)
24
+
23
25
  expect(SliceRename::Combiner).to(
24
- receive(:save_combination).exactly(1).times do |input_names, output_name, geometry, tile, border|
26
+ receive(:save_combination).exactly(1).times do |config, input_names, output_name, geometry, tile, border|
25
27
  input_names.each_with_index do |name, index|
26
28
  expect(name).to include suffixes[index]
27
29
  end
@@ -61,7 +61,7 @@ RSpec.describe SliceRename::Config do
61
61
  expect(config.suffixes).to be_an Array
62
62
  end
63
63
 
64
- it 'exposes the wether to collapse padding or not' do
64
+ it 'exposes wether to collapse padding or not' do
65
65
  expect(config.collapse_padding).to be_falsy
66
66
  end
67
67
 
@@ -69,6 +69,10 @@ RSpec.describe SliceRename::Config do
69
69
  expect(config.padding_color).to be_a String
70
70
  end
71
71
 
72
+ it 'exposes wether to draw padding around empty images' do
73
+ expect(config.full_grid).to be_truthy
74
+ end
75
+
72
76
  it 'exposes the background color' do
73
77
  expect(config.background_color).to be_a String
74
78
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slice_rename
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zoee Silcock
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-02 00:00:00.000000000 Z
11
+ date: 2016-10-04 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Slice an image and give each slice a specific name.
14
14
  email: mrzoee@gmail.com