appiconset 2.5.0 → 2.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
  SHA256:
3
- metadata.gz: 2a7767388959af2163784bee32c1a70fc845eef093882f4fb26911fada88ef15
4
- data.tar.gz: c2f1a80e9ea7a5d30928b3d157e1964eed726f26b2f7cb49b4c5dfc50637b856
3
+ metadata.gz: 91ca34e89d534da0a0db5aeb3a28ab1f6e1c3a6edf19a8d306d76414a800058e
4
+ data.tar.gz: 6cef3caf6d961a2c564374a67d40a35086fc941ffe1ffe160390ab9055629620
5
5
  SHA512:
6
- metadata.gz: 8b82c5fe7f7b5d61fadfb49a1126f0a1ab07bc4fb823803c1ce7f2ab513d437512ed97fff395d1b834fed33e493c8e968319bb3e3326e6df732822f7b26fb88a
7
- data.tar.gz: 3e2f7a7443b136f3e3d7f5a14d268475c395eb5e7d6590e11ddb66e7c0ffc1ddac85e96d0b4b7e87799cdad4fb0a58674daedbf9e3e61a21fc638ae5167dd735
6
+ metadata.gz: b0d570d40bd186c8c0c9e99d55127b0b13c5c81ea39a0585ac44e016abad3488766f79a27e388d66adf07c8b27ac0e328f6265e945f26f3398b5f49bcb9daa61
7
+ data.tar.gz: b27e74468419a9d62f5f036e4f442bf7162f9cae128bdf49adee8c86aa906b90f8667834daf7fcba2da5e2b74cb03e6274c6164b0ac4267d734d73031140f97f
data/.rubocop.yml CHANGED
@@ -1 +1,4 @@
1
1
  inherit_from: .rubocop_todo.yml
2
+
3
+ AllCops:
4
+ SuggestExtensions: false
data/.rubocop_todo.yml CHANGED
@@ -9,7 +9,7 @@
9
9
  # Offense count: 3
10
10
  # Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
11
11
  Metrics/AbcSize:
12
- Max: 40
12
+ Max: 50
13
13
 
14
14
  # Offense count: 1
15
15
  # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
@@ -20,14 +20,17 @@ Metrics/BlockLength:
20
20
  # Offense count: 1
21
21
  # Configuration parameters: CountComments, CountAsOne.
22
22
  Metrics/ClassLength:
23
- Max: 140
23
+ Max: 150
24
24
 
25
25
  # Offense count: 1
26
26
  # Configuration parameters: AllowedMethods, AllowedPatterns.
27
27
  Metrics/CyclomaticComplexity:
28
- Max: 8
28
+ Max: 10
29
29
 
30
30
  # Offense count: 3
31
31
  # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
32
32
  Metrics/MethodLength:
33
33
  Max: 64
34
+
35
+ Metrics/PerceivedComplexity:
36
+ Max: 12
data/README.base.md CHANGED
@@ -25,16 +25,20 @@
25
25
  * tvOS
26
26
  * icns.iconset
27
27
  * icns(macOS only)
28
+ * favicon
28
29
 
29
30
  # ガイド
30
31
 
31
- ## 正方形アイコン
32
- 正方形アイコンを生成するには、1024px x 1024px の画像からアプリアイコンを作成します。
32
+ 1つの画像から複数のアプリアイコンを作成します。
33
33
 
34
34
  ```
35
35
  $ appiconset g -i='sample.jpg' -o='output'
36
36
  ```
37
37
 
38
+
39
+ ## 正方形アイコン
40
+ 正方形アイコンを作成するには、1024px x 1024px の画像を用意します。
41
+
38
42
  Contents.jsonと複数のpngファイルが作成されます。
39
43
  これらのファイルをXcodeプロジェクトの AppIcon.appiconset にコピーします。
40
44
 
@@ -51,18 +55,10 @@ tvOSアプリ向けのアイコンを作成するには。4640px x 1440px の画
51
55
  | tv-top-shelf | 3840x1440 | ![tv-top-shelf](sample/tv-top-shelf/Icon@2x.png)|
52
56
  | tv-top-shelf-wide | 4640x1440 |![tv-top-shelf-wide](sample/tv-top-shelf-wide/Icon@2x.png) |
53
57
 
54
- ```
55
- $ appiconset g -i='sample.jpg' -o='output'
56
- ```
57
-
58
58
  ## 任意のサイズのアイコン
59
59
 
60
60
  任意のサイズの画像から、1倍、2/3倍、1/3倍のアイコンを作成します。
61
61
 
62
- ```
63
- $ appiconset g -i='sample.jpg' -o='output'
64
- ```
65
-
66
62
  <!-- [en] -->
67
63
 
68
64
  # Appiconset
@@ -83,17 +79,20 @@ Icon creation is supported for the following platforms.
83
79
  * tvOS
84
80
  * icns.iconset
85
81
  * icns(macOS only)
82
+ * favicon
86
83
 
87
84
  # Guide
88
85
 
89
- ## Square icons
90
-
91
- Create an app icon from a 1024px x 1024px image.
86
+ Create multiple app icons from one image.
92
87
 
93
88
  ```
94
89
  $ appiconset g -i='sample.jpg' -o='output'
95
90
  ```
96
91
 
92
+ ## Square icons
93
+
94
+ Create an app icon from a 1024px x 1024px image.
95
+
97
96
  A Contents.json and several png files will be created.
98
97
  Copy these files to AppIcon.appiconset in the Xcode project.
99
98
 
@@ -110,14 +109,7 @@ The input image is the same as tv-top-shelf-wide, tv-top-shelf is the image from
110
109
  | tv-top-shelf | 3840x1440 | ![tv-top-shelf](sample/tv-top-shelf/Icon@2x.png)|
111
110
  | tv-top-shelf-wide | 4640x1440 |![tv-top-shelf-wide](sample/tv-top-shelf-wide/Icon@2x.png) |
112
111
 
113
- ```
114
- $ appiconset g -i='sample.jpg' -o='output'
115
- ```
116
112
 
117
113
  ## Icons of any size
118
114
 
119
115
  Create 1x, 2/3x, and 1/3x icons from any size image.
120
-
121
- ```
122
- $ appiconset g -i='sample.jpg' -o='output'
123
- ```
data/README.ja.md CHANGED
@@ -19,16 +19,20 @@
19
19
  * tvOS
20
20
  * icns.iconset
21
21
  * icns(macOS only)
22
+ * favicon
22
23
 
23
24
  # ガイド
24
25
 
25
- ## 正方形アイコン
26
- 正方形アイコンを生成するには、1024px x 1024px の画像からアプリアイコンを作成します。
26
+ 1つの画像から複数のアプリアイコンを作成します。
27
27
 
28
28
  ```
29
29
  $ appiconset g -i='sample.jpg' -o='output'
30
30
  ```
31
31
 
32
+
33
+ ## 正方形アイコン
34
+ 正方形アイコンを作成するには、1024px x 1024px の画像を用意します。
35
+
32
36
  Contents.jsonと複数のpngファイルが作成されます。
33
37
  これらのファイルをXcodeプロジェクトの AppIcon.appiconset にコピーします。
34
38
 
@@ -45,14 +49,6 @@ tvOSアプリ向けのアイコンを作成するには。4640px x 1440px の画
45
49
  | tv-top-shelf | 3840x1440 | ![tv-top-shelf](sample/tv-top-shelf/Icon@2x.png)|
46
50
  | tv-top-shelf-wide | 4640x1440 |![tv-top-shelf-wide](sample/tv-top-shelf-wide/Icon@2x.png) |
47
51
 
48
- ```
49
- $ appiconset g -i='sample.jpg' -o='output'
50
- ```
51
-
52
52
  ## 任意のサイズのアイコン
53
53
 
54
54
  任意のサイズの画像から、1倍、2/3倍、1/3倍のアイコンを作成します。
55
-
56
- ```
57
- $ appiconset g -i='sample.jpg' -o='output'
58
- ```
data/README.md CHANGED
@@ -19,17 +19,20 @@ Icon creation is supported for the following platforms.
19
19
  * tvOS
20
20
  * icns.iconset
21
21
  * icns(macOS only)
22
+ * favicon
22
23
 
23
24
  # Guide
24
25
 
25
- ## Square icons
26
-
27
- Create an app icon from a 1024px x 1024px image.
26
+ Create multiple app icons from one image.
28
27
 
29
28
  ```
30
29
  $ appiconset g -i='sample.jpg' -o='output'
31
30
  ```
32
31
 
32
+ ## Square icons
33
+
34
+ Create an app icon from a 1024px x 1024px image.
35
+
33
36
  A Contents.json and several png files will be created.
34
37
  Copy these files to AppIcon.appiconset in the Xcode project.
35
38
 
@@ -46,14 +49,7 @@ The input image is the same as tv-top-shelf-wide, tv-top-shelf is the image from
46
49
  | tv-top-shelf | 3840x1440 | ![tv-top-shelf](sample/tv-top-shelf/Icon@2x.png)|
47
50
  | tv-top-shelf-wide | 4640x1440 |![tv-top-shelf-wide](sample/tv-top-shelf-wide/Icon@2x.png) |
48
51
 
49
- ```
50
- $ appiconset g -i='sample.jpg' -o='output'
51
- ```
52
52
 
53
53
  ## Icons of any size
54
54
 
55
- Create 1x, 2/3x, and 1/3x icons from any size image.
56
-
57
- ```
58
- $ appiconset g -i='sample.jpg' -o='output'
59
- ```
55
+ Create 1x, 2/3x, and 1/3x icons from any size image.
@@ -26,9 +26,7 @@ module Appiconset
26
26
  begin
27
27
  generator.config(options[:input].to_s, options[:output].to_s)
28
28
  generator.square_platforms
29
- generator.tvos_platforms
30
- generator.universal_platforms
31
- generator.icns_platforms
29
+ generator.any_platforms
32
30
  rescue StandardError => e
33
31
  warn e.message
34
32
  exit(1)
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'appiconset'
4
4
  require 'json'
5
+ require 'rbconfig'
5
6
 
6
7
  # Appiconset
7
8
  module Appiconset
@@ -29,9 +30,7 @@ module Appiconset
29
30
 
30
31
  # 正方形アイコン
31
32
  def square_platforms
32
- return unless @width == 1024 && @height == 1024
33
-
34
- show_info('square')
33
+ return unless size_match?([1024, 1024])
35
34
 
36
35
  json_dir = "#{__dir__}/settings/*.json"
37
36
 
@@ -43,9 +42,10 @@ module Appiconset
43
42
  # プラットフォームごとのディレクトリ
44
43
  platform = File.basename(path).gsub('-Contents.json', '')
45
44
  output_dir = "#{@output}#{platform}/"
46
-
47
45
  FileUtils.mkdir_p(output_dir)
48
46
 
47
+ show_info(platform)
48
+
49
49
  json_data['images'].each do |image|
50
50
  size = image['size'].match(/(.*?)x/)[1].to_f
51
51
  scale = image['scale'].gsub('x', '').to_i
@@ -65,127 +65,88 @@ module Appiconset
65
65
  rescue StandardError
66
66
  # none
67
67
  end
68
+
69
+ if platform == 'icns.iconset' && RbConfig::CONFIG['host_os'].match(/darwin|mac os/)
70
+ # macOSで実行可能
71
+ system("iconutil -c icns --output #{output_dir}/Icon.icns #{output_dir}/")
72
+ elsif platform == 'favicon'
73
+ images = Dir.glob("#{output_dir}*")
74
+ image = Magick::ImageList.new(*images)
75
+ image.format = 'ICO'
76
+ image.write("#{output_dir}favicon.ico")
77
+ end
68
78
  end
69
79
  end
70
80
 
71
- # ユニバーサルアイコン
72
- def universal_platforms
73
- show_info('universal')
74
-
81
+ def any_platforms
75
82
  platforms = [
76
83
  {
77
84
  name: 'universal',
85
+ size: [0, 0],
78
86
  contents: [
79
- { width: @width, height: @height, scale: 3 },
80
- { width: @width / 3 * 2, height: @height / 3 * 2, scale: 2 },
81
- { width: @width / 3, height: @height / 3, scale: 1 }
87
+ { width: @width, height: @height, name: 'Icon@3x.png' },
88
+ { width: @width / 3 * 2, height: @height / 3 * 2, name: 'Icon@2x.png' },
89
+ { width: @width / 3, height: @height / 3, name: 'Icon@1x.png' }
82
90
  ]
83
- }
84
- ]
85
-
86
- platforms.each do |platform|
87
- output_dir = "#{@output}#{platform[:name]}/"
88
- FileUtils.mkdir_p(output_dir)
89
-
90
- platform[:contents].each do |content|
91
- width = content[:width].to_f
92
- height = content[:height].to_f
93
- scale = content[:scale].to_i
94
-
95
- name = "Icon@#{scale}x.png"
96
-
97
- image = Magick::ImageList.new(@input)
98
- new_image = image.resize_to_fit(width, height)
99
- new_image.format = 'PNG'
100
- new_image.write(output_dir + name)
101
- end
102
- end
103
- end
104
-
105
- # tvOSアイコン
106
- # Input 4640x1440
107
- # Output 2400x1440, 3840x1440, 4640x1440
108
- def tvos_platforms
109
- return unless @width == 4640 && @height == 1440
110
-
111
- show_info('tvOS')
112
-
113
- platforms = [
91
+ },
114
92
  {
115
93
  name: 'tv',
94
+ size: [4640, 1440],
116
95
  contents: [
117
- { width: 800, height: 480, scale: 2 },
118
- { width: 400, height: 240, scale: 1 }
96
+ { width: 800, height: 480, name: 'Icon@2x.png' },
97
+ { width: 400, height: 240, name: 'Icon@1x.png' }
119
98
  ]
120
99
  },
121
100
  {
122
101
  name: 'tv-top-shelf',
102
+ size: [4640, 1440],
123
103
  contents: [
124
- { width: 3840, height: 1440, scale: 2 },
125
- { width: 1920, height: 720, scale: 1 }
104
+ { width: 3840, height: 1440, name: 'Icon@2x.png' },
105
+ { width: 1920, height: 720, name: 'Icon@1x.png' }
126
106
  ]
127
107
  },
128
108
  {
129
109
  name: 'tv-top-shelf-wide',
110
+ size: [4640, 1440],
130
111
  contents: [
131
- { width: 4640, height: 1440, scale: 2 },
132
- { width: 2320, height: 720, scale: 1 }
112
+ { width: 4640, height: 1440, name: 'Icon@2x.png' },
113
+ { width: 2320, height: 720, name: 'Icon@1x.png' }
133
114
  ]
134
115
  }
135
116
  ]
136
117
 
137
118
  platforms.each do |platform|
138
- output_dir = "#{@output}#{platform[:name]}/"
119
+ platform_name = platform[:name]
120
+ next unless size_match?(platform[:size])
121
+
122
+ show_info(platform_name)
123
+
124
+ output_dir = "#{@output}#{platform_name}/"
139
125
  FileUtils.mkdir_p(output_dir)
140
126
 
141
127
  platform[:contents].each do |content|
142
128
  width = content[:width].to_f
143
129
  height = content[:height].to_f
144
- scale = content[:scale].to_i
145
-
146
- name = "Icon@#{scale}x.png"
130
+ name = content[:name]
147
131
 
148
132
  image = Magick::ImageList.new(@input)
149
- new_image = image.scale(height / 1440.0)
150
- new_image = new_image.crop(Magick::CenterGravity, width, height)
151
- new_image.format = 'PNG'
152
- new_image.write(output_dir + name)
153
- end
154
- end
155
- end
156
-
157
- # icnsアイコン
158
- def icns_platforms
159
- return unless @width == 1024 && @height == 1024
160
-
161
- show_info('icns.iconset')
162
-
163
- output_dir = "#{@output}icns.iconset/"
164
- FileUtils.mkdir_p(output_dir)
165
-
166
- sizes = [512, 256, 128, 64, 32, 16]
167
- sizes.each do |size|
168
- [2, 1].each do |scale|
169
- if scale == 2
170
- name = "icon_#{size}x#{size}@2x.png"
171
- new_size = size * scale
133
+ if platform_name.start_with?('tv')
134
+ image = image.scale(height / 1440.0)
135
+ image = image.crop(Magick::CenterGravity, width, height)
172
136
  else
173
- name = "icon_#{size}x#{size}.png"
174
- new_size = size
137
+ image = image.resize_to_fit(width, height)
175
138
  end
176
-
177
- image = Magick::ImageList.new(@input)
178
- new_image = image.resize_to_fit(new_size, new_size)
179
- new_image.format = 'PNG'
180
- new_image.write(output_dir + name)
139
+ image.format = 'PNG'
140
+ image.write(output_dir + name)
181
141
  end
182
142
  end
143
+ end
183
144
 
184
- return unless RUBY_PLATFORM.match(/darwin/)
145
+ private
185
146
 
186
- # macOSで実行可能
187
- show_info('icns')
188
- system("iconutil -c icns #{output_dir}")
147
+ # 入力画像のサイズが条件に一致したときtrueを返す
148
+ def size_match?(size)
149
+ size == [0, 0] || (@width == size[0] && @height == size[1])
189
150
  end
190
151
 
191
152
  def show_info(platform_name)
@@ -0,0 +1,39 @@
1
+ {
2
+ "images": [
3
+ {
4
+ "size": "256x256",
5
+ "filename": "icon_256x256.png",
6
+ "scale": "1x"
7
+ },
8
+ {
9
+ "size": "128x128",
10
+ "filename": "icon_128x128.png",
11
+ "scale": "1x"
12
+ },
13
+ {
14
+ "size": "64x64",
15
+ "filename": "icon_64x64.png",
16
+ "scale": "1x"
17
+ },
18
+ {
19
+ "size": "48x48",
20
+ "filename": "icon_48x48.png",
21
+ "scale": "1x"
22
+ },
23
+ {
24
+ "size": "32x32",
25
+ "filename": "icon_32x32.png",
26
+ "scale": "1x"
27
+ },
28
+ {
29
+ "size": "24x24",
30
+ "filename": "icon_24x24.png",
31
+ "scale": "1x"
32
+ },
33
+ {
34
+ "size": "16x16",
35
+ "filename": "icon_16x16.png",
36
+ "scale": "1x"
37
+ }
38
+ ]
39
+ }
@@ -0,0 +1,64 @@
1
+ {
2
+ "images": [
3
+ {
4
+ "size": "512x512",
5
+ "filename": "icon_512x512@2x.png",
6
+ "scale": "2x"
7
+ },
8
+ {
9
+ "size": "512x512",
10
+ "filename": "icon_512x512.png",
11
+ "scale": "1x"
12
+ },
13
+ {
14
+ "size": "256x256",
15
+ "filename": "icon_256x256@2x.png",
16
+ "scale": "2x"
17
+ },
18
+ {
19
+ "size": "256x256",
20
+ "filename": "icon_256x256.png",
21
+ "scale": "1x"
22
+ },
23
+ {
24
+ "size": "128x128",
25
+ "filename": "icon_128x128@2x.png",
26
+ "scale": "2x"
27
+ },
28
+ {
29
+ "size": "128x128",
30
+ "filename": "icon_128x128.png",
31
+ "scale": "1x"
32
+ },
33
+ {
34
+ "size": "64x64",
35
+ "filename": "icon_64x64@2x.png",
36
+ "scale": "2x"
37
+ },
38
+ {
39
+ "size": "64x64",
40
+ "filename": "icon_64x64.png",
41
+ "scale": "1x"
42
+ },
43
+ {
44
+ "size": "32x32",
45
+ "filename": "icon_32x32@2x.png",
46
+ "scale": "2x"
47
+ },
48
+ {
49
+ "size": "32x32",
50
+ "filename": "icon_32x32.png",
51
+ "scale": "1x"
52
+ },
53
+ {
54
+ "size": "16x16",
55
+ "filename": "icon_16x16@2x.png",
56
+ "scale": "2x"
57
+ },
58
+ {
59
+ "size": "16x16",
60
+ "filename": "icon_16x16.png",
61
+ "scale": "1x"
62
+ }
63
+ ]
64
+ }
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Appiconset
4
- VERSION = '2.5.0'
4
+ VERSION = '2.7.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: appiconset
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.0
4
+ version: 2.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - arthur87
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-01-06 00:00:00.000000000 Z
11
+ date: 2025-02-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubocop
@@ -89,6 +89,8 @@ files:
89
89
  - lib/appiconset.rb
90
90
  - lib/appiconset/cli.rb
91
91
  - lib/appiconset/generator.rb
92
+ - lib/appiconset/settings/favicon-Contents.json
93
+ - lib/appiconset/settings/icns.iconset-Contents.json
92
94
  - lib/appiconset/settings/iphone-xcode9.1-Contents.json
93
95
  - lib/appiconset/settings/mac-xcode9.1-Contents.json
94
96
  - lib/appiconset/settings/mipmap-hdpi-Contents.json
@@ -127,7 +129,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
127
129
  - !ruby/object:Gem::Version
128
130
  version: '0'
129
131
  requirements: []
130
- rubygems_version: 3.5.11
132
+ rubygems_version: 3.3.3
131
133
  signing_key:
132
134
  specification_version: 4
133
135
  summary: appiconset generator for Xcode