appiconset 2.0.0 → 2.1.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
  SHA256:
3
- metadata.gz: 2effb276686faf59913e1750ddac211d82b68e997079cf751ca3741ab28b72de
4
- data.tar.gz: bda7998c4c90066966e6b1cdf3e54d2b0081cc20fda781d25410acfe81d3fb3b
3
+ metadata.gz: 549331175159c997383904e9061d81b1b77ac8d2a14cc9a4cea03d4886d5d85a
4
+ data.tar.gz: b01d59477537e1d9fd2e8612e2b584c911f2e5e0657cb7c2dac9786c10a99091
5
5
  SHA512:
6
- metadata.gz: 9c89abbdf651a1caf63fd6d6c9787b9fdb85f80bceea6897343d909fe27f8e313e6fb7430b65e0e9a815f402aa58673c8f01b2d505b25d23caa6369812d25305
7
- data.tar.gz: 5b4a5cc20e7cd4c1ff1ca36bd1e4d36e683e649b9522862d1d9841225325a92309ec979a05a162761f0a6d3051894e653aec2ffb6e47ff047729c516c14eb38a
6
+ metadata.gz: 296b77ef50754dcced430b30a9411eab85f5de95240b57c4f49a12276a6593a0da7d672c3b1dde8b62260ebf428116d3b7bf1a14f5a362f157c459b768d466a3
7
+ data.tar.gz: e11a35910216aa33421e501df9604b421db43c3387ae60fa8e9ea5788feaca0754a92e620ef77688a0c46daef4be9c14a1c57299babd340b30e80ba6e421e31d
data/.rubocop_todo.yml CHANGED
@@ -1,17 +1,27 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2024-12-07 11:26:17 UTC using RuboCop version 1.63.2.
3
+ # on 2024-12-07 14:32:20 UTC using RuboCop version 1.63.2.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
7
7
  # versions of RuboCop, may require this file to be generated again.
8
8
 
9
- # Offense count: 1
9
+ # Offense count: 3
10
10
  # Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
11
11
  Metrics/AbcSize:
12
12
  Max: 32
13
13
 
14
14
  # Offense count: 1
15
+ # Configuration parameters: CountComments, CountAsOne.
16
+ Metrics/ClassLength:
17
+ Max: 120
18
+
19
+ # Offense count: 1
20
+ # Configuration parameters: AllowedMethods, AllowedPatterns.
21
+ Metrics/CyclomaticComplexity:
22
+ Max: 8
23
+
24
+ # Offense count: 3
15
25
  # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
16
26
  Metrics/MethodLength:
17
- Max: 23
27
+ Max: 38
data/README.md CHANGED
@@ -11,14 +11,26 @@
11
11
  * Universal
12
12
  * watchOS
13
13
  * Android
14
+ * tvOS
14
15
 
15
16
  ## 使い方
16
17
 
17
18
  1024px x 1024px の画像からアプリアイコンを作成します。
18
19
 
19
20
  ```
20
- $ appiconset icons -i='sample.jpg' -o='output'
21
+ $ appiconset square -i='sample.jpg' -o='output'
21
22
  ```
22
23
 
23
24
  Contents.jsonと複数のpngファイルが作成されます。
24
- これらのファイルをXcodeプロジェクトの AppIcon.appiconset にコピーします。
25
+ これらのファイルをXcodeプロジェクトの AppIcon.appiconset にコピーします。
26
+
27
+
28
+ ## tvOSのアイコンについて
29
+
30
+ tvOSアプリ向けのアイコンを作成するには。4640px x 1440px の画像を用意します。
31
+ この画像からApp Icon.imagestack、Top Shelf Image.imageset、Top Shelf Image Wide.imagesetのアイコンを作成します。
32
+
33
+
34
+ ```
35
+ $ appiconset tvos -i='sample.jpg' -o='output'
36
+ ```
@@ -17,10 +17,10 @@ module Appiconset
17
17
  puts(Appiconset::VERSION)
18
18
  end
19
19
 
20
- desc 'icons', 'Icons'
21
- method_option :input, desc: 'Input query', aliases: '-i'
22
- method_option :output, desc: 'Write output to <file>', aliases: '-o'
23
- def icons
20
+ desc 'square', 'Create icons from a square image'
21
+ method_option :input, desc: 'Input image(1024px x 1024px)', aliases: '-i'
22
+ method_option :output, desc: 'Write output to <dir>', aliases: '-o'
23
+ def square
24
24
  generator = Appiconset::Generator.new
25
25
 
26
26
  begin
@@ -31,5 +31,35 @@ module Appiconset
31
31
  exit(1)
32
32
  end
33
33
  end
34
+
35
+ desc 'tvos', 'Create tvOS icons'
36
+ method_option :input, desc: 'Input image(4640px x 1440px)', aliases: '-i'
37
+ method_option :output, desc: 'Write output to <dir>', aliases: '-o'
38
+ def tvos
39
+ generator = Appiconset::Generator.new
40
+
41
+ begin
42
+ generator.config(options[:input].to_s, options[:output].to_s, 4640, 1440)
43
+ generator.tvos_platforms
44
+ rescue StandardError => e
45
+ warn e.message
46
+ exit(1)
47
+ end
48
+ end
49
+
50
+ desc 'icons', 'Create Universal icons'
51
+ method_option :input, desc: 'Input any size image', aliases: '-i'
52
+ method_option :output, desc: 'Write output to <dir>', aliases: '-o'
53
+ def icons
54
+ generator = Appiconset::Generator.new
55
+
56
+ begin
57
+ generator.config(options[:input].to_s, options[:output].to_s, 0, 0)
58
+ generator.universal_platforms
59
+ rescue StandardError => e
60
+ warn e.message
61
+ exit(1)
62
+ end
63
+ end
34
64
  end
35
65
  end
@@ -9,11 +9,11 @@ module Appiconset
9
9
  class Generator
10
10
  def initialize; end
11
11
 
12
- def config(input, output)
12
+ def config(input, output, width = 1024, height = 1024)
13
13
  raise 'no input file.' unless File.exist?(input)
14
14
 
15
15
  size = FastImage.size(input)
16
- raise 'unsupported size.' if size[0].to_i != 1024 || size[1].to_i != 1024
16
+ raise 'unsupported size.' if width != 0 && height != 0 && (size[0].to_i != width || size[1].to_i != height)
17
17
 
18
18
  output += '/' unless output.end_with?('/')
19
19
 
@@ -45,7 +45,10 @@ module Appiconset
45
45
  real_size = size * scale
46
46
  name = image['filename']
47
47
 
48
- image_write(real_size, output_dir + name)
48
+ image = Magick::ImageList.new(@input)
49
+ new_image = image.resize_to_fit(real_size, real_size)
50
+ new_image.format = 'PNG'
51
+ new_image.write(output_dir + name)
49
52
  end
50
53
 
51
54
  # Xcode用にファイルをコピーする
@@ -57,13 +60,84 @@ module Appiconset
57
60
  end
58
61
  end
59
62
 
60
- private
63
+ # ユニバーサルアイコン
64
+ def universal_platforms
65
+ size = FastImage.size(@input)
66
+ platforms = [
67
+ {
68
+ name: 'universal',
69
+ contents: [
70
+ { width: size[0], height: size[1], scale: 3 },
71
+ { width: size[0] / 3 * 2, height: size[1] / 3 * 2, scale: 2 },
72
+ { width: size[0] / 3, height: size[1] / 3, scale: 1 }
73
+
74
+ ]
75
+ }
76
+ ]
77
+
78
+ platforms.each do |platform|
79
+ output_dir = "#{@output}#{platform[:name]}/"
80
+ FileUtils.mkdir_p(output_dir)
81
+
82
+ platform[:contents].each do |content|
83
+ width = content[:width].to_f
84
+ height = content[:height].to_f
85
+ scale = content[:scale].to_i
86
+
87
+ name = "Icon@#{scale}x.png"
88
+
89
+ image = Magick::ImageList.new(@input)
90
+ new_image = image.resize_to_fit(width, height)
91
+ new_image.format = 'PNG'
92
+ new_image.write(output_dir + name)
93
+ end
94
+ end
95
+ end
61
96
 
62
- def image_write(size, path)
63
- image = Magick::ImageList.new(@input)
64
- new_image = image.resize_to_fit(size, size)
65
- new_image.format = 'PNG'
66
- new_image.write(path)
97
+ # tvOSアイコン
98
+ def tvos_platforms
99
+ platforms = [
100
+ {
101
+ name: 'tv',
102
+ contents: [
103
+ { width: 800, height: 480, scale: 2 },
104
+ { width: 400, height: 240, scale: 1 }
105
+ ]
106
+ },
107
+ {
108
+ name: 'tv-top-shelf',
109
+ contents: [
110
+ { width: 3840, height: 1440, scale: 2 },
111
+ { width: 1920, height: 720, scale: 1 }
112
+ ]
113
+ },
114
+ {
115
+ name: 'tv-top-shelf-wide',
116
+ contents: [
117
+ { width: 4640, height: 1440, scale: 2 },
118
+ { width: 2320, height: 720, scale: 1 }
119
+ ]
120
+ }
121
+ ]
122
+
123
+ platforms.each do |platform|
124
+ output_dir = "#{@output}#{platform[:name]}/"
125
+ FileUtils.mkdir_p(output_dir)
126
+
127
+ platform[:contents].each do |content|
128
+ width = content[:width].to_f
129
+ height = content[:height].to_f
130
+ scale = content[:scale].to_i
131
+
132
+ name = "Icon@#{scale}x.png"
133
+
134
+ image = Magick::ImageList.new(@input)
135
+ new_image = image.scale(height / 1440.0)
136
+ new_image = new_image.crop(Magick::CenterGravity, width, height)
137
+ new_image.format = 'PNG'
138
+ new_image.write(output_dir + name)
139
+ end
140
+ end
67
141
  end
68
142
  end
69
143
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Appiconset
4
- VERSION = '2.0.0'
4
+ VERSION = '2.1.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: appiconset
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - arthur87