appiconset 2.5.0 → 2.6.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: 04c392fedbb90f46a1a68063f3e355ec5fa8bd81123d250a7799d453ea243dc9
4
+ data.tar.gz: 5128b965a8349ad8094ce560a5681935b36f652d7590ee624ec2bc87bb3a1573
5
5
  SHA512:
6
- metadata.gz: 8b82c5fe7f7b5d61fadfb49a1126f0a1ab07bc4fb823803c1ce7f2ab513d437512ed97fff395d1b834fed33e493c8e968319bb3e3326e6df732822f7b26fb88a
7
- data.tar.gz: 3e2f7a7443b136f3e3d7f5a14d268475c395eb5e7d6590e11ddb66e7c0ffc1ddac85e96d0b4b7e87799cdad4fb0a58674daedbf9e3e61a21fc638ae5167dd735
6
+ metadata.gz: 34f6a72de126bf51135bf2ad8bc9cf0780e187d37507872e74a24f14324d9c92f8a0c395573c315e25066b79cda73fee98356fc66f7d0b896f66c76add624d56
7
+ data.tar.gz: f2bf02f8b5663a0153343358f3a669a6f407c108415f26ef0c8de02cbd9aef8e14f5d232684429d183a32492603eb7b810b12e97d8638fa9b74d30cdc2141ae3
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
@@ -20,12 +20,12 @@ 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.
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,7 +30,7 @@ module Appiconset
29
30
 
30
31
  # 正方形アイコン
31
32
  def square_platforms
32
- return unless @width == 1024 && @height == 1024
33
+ return unless size_match?([1024, 1024])
33
34
 
34
35
  show_info('square')
35
36
 
@@ -68,124 +69,126 @@ module Appiconset
68
69
  end
69
70
  end
70
71
 
71
- # ユニバーサルアイコン
72
- def universal_platforms
73
- show_info('universal')
74
-
72
+ # rubocop:todo Metrics/PerceivedComplexity
73
+ # rubocop:todo Metrics/AbcSize
74
+ def any_platforms # rubocop:disable Metrics/MethodLength, Metrics/AbcSize, Metrics/PerceivedComplexity
75
75
  platforms = [
76
76
  {
77
77
  name: 'universal',
78
+ size: [0, 0],
78
79
  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 }
80
+ { width: @width, height: @height, name: 'Icon@3x.png' },
81
+ { width: @width / 3 * 2, height: @height / 3 * 2, name: 'Icon@2x.png' },
82
+ { width: @width / 3, height: @height / 3, name: 'Icon@1x.png' }
82
83
  ]
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 = [
84
+ },
114
85
  {
115
86
  name: 'tv',
87
+ size: [4640, 1440],
116
88
  contents: [
117
- { width: 800, height: 480, scale: 2 },
118
- { width: 400, height: 240, scale: 1 }
89
+ { width: 800, height: 480, name: 'Icon@2x.png' },
90
+ { width: 400, height: 240, name: 'Icon@1x.png' }
119
91
  ]
120
92
  },
121
93
  {
122
94
  name: 'tv-top-shelf',
95
+ size: [4640, 1440],
123
96
  contents: [
124
- { width: 3840, height: 1440, scale: 2 },
125
- { width: 1920, height: 720, scale: 1 }
97
+ { width: 3840, height: 1440, name: 'Icon@2x.png' },
98
+ { width: 1920, height: 720, name: 'Icon@1x.png' }
126
99
  ]
127
100
  },
128
101
  {
129
102
  name: 'tv-top-shelf-wide',
103
+ size: [4640, 1440],
104
+ contents: [
105
+ { width: 4640, height: 1440, name: 'Icon@2x.png' },
106
+ { width: 2320, height: 720, name: 'Icon@1x.png' }
107
+ ]
108
+ },
109
+ {
110
+ name: 'icns.iconset',
111
+ size: [1024, 1024],
112
+ contents: [
113
+ { width: 1024, height: 1024, name: 'icon_512x512@2x.png' },
114
+ { width: 512, height: 512, name: 'icon_512x512.png' },
115
+ { width: 512, height: 512, name: 'icon_256x256@2x.png' },
116
+ { width: 256, height: 256, name: 'icon_256x256.png' },
117
+ { width: 256, height: 256, name: 'icon_128x128@2x.png' },
118
+ { width: 128, height: 128, name: 'icon_128x128.png' },
119
+ { width: 128, height: 128, name: 'icon_64x64@2x.png' },
120
+ { width: 64, height: 64, name: 'icon_64x64.png' },
121
+ { width: 64, height: 64, name: 'icon_32x32@2x.png' },
122
+ { width: 32, height: 32, name: 'icon_32x32.png' },
123
+ { width: 32, height: 32, name: 'icon_16x16@2x.png' },
124
+ { width: 16, height: 16, name: 'icon_16x16.png' }
125
+ ]
126
+ },
127
+ {
128
+ name: 'favicon',
129
+ size: [1024, 1024],
130
130
  contents: [
131
- { width: 4640, height: 1440, scale: 2 },
132
- { width: 2320, height: 720, scale: 1 }
131
+ { width: 256, height: 256, name: 'icon_256x256.png' },
132
+ { width: 128, height: 128, name: 'icon_128x128.png' },
133
+ { width: 64, height: 64, name: 'icon_64x64.png' },
134
+ { width: 48, height: 48, name: 'icon_48x48.png' },
135
+ { width: 32, height: 32, name: 'icon_32x32.png' },
136
+ { width: 24, height: 24, name: 'icon_24x24.png' },
137
+ { width: 16, height: 16, name: 'icon_16x16.png' }
133
138
  ]
134
139
  }
135
140
  ]
136
141
 
137
142
  platforms.each do |platform|
138
- output_dir = "#{@output}#{platform[:name]}/"
143
+ platform_name = platform[:name]
144
+ next unless size_match?(platform[:size])
145
+
146
+ show_info(platform_name)
147
+
148
+ output_dir = "#{@output}#{platform_name}/"
139
149
  FileUtils.mkdir_p(output_dir)
140
150
 
141
151
  platform[:contents].each do |content|
142
152
  width = content[:width].to_f
143
153
  height = content[:height].to_f
144
- scale = content[:scale].to_i
145
-
146
- name = "Icon@#{scale}x.png"
154
+ name = content[:name]
147
155
 
148
156
  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)
157
+ if platform_name.start_with?('tv')
158
+ image = image.scale(height / 1440.0)
159
+ image = image.crop(Magick::CenterGravity, width, height)
160
+ else
161
+ image = image.resize_to_fit(width, height)
162
+ end
163
+ image.format = 'PNG'
164
+ image.write(output_dir + name)
153
165
  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
166
 
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
172
- else
173
- name = "icon_#{size}x#{size}.png"
174
- new_size = size
167
+ if platform_name == 'icns.iconset' && RbConfig::CONFIG['host_os'].match(/darwin|mac os/)
168
+ # macOSで実行可能
169
+ show_info('icns')
170
+ system("iconutil -c icns --output #{@output}Icon.icns #{@output}icns.iconset/")
171
+ elsif platform_name == 'favicon'
172
+ images = platforms.find do |x|
173
+ x[:name] == 'favicon'
174
+ end[:contents].map do |x| # rubocop:disable Style/MultilineBlockChain
175
+ "#{output_dir}#{x[:name]}"
175
176
  end
176
177
 
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)
178
+ image = Magick::ImageList.new(*images)
179
+ image.format = 'ICO'
180
+ image.write("#{@output}favicon/favicon.ico")
181
181
  end
182
182
  end
183
+ end
184
+ # rubocop:enable Metrics/AbcSize
185
+ # rubocop:enable Metrics/PerceivedComplexity
183
186
 
184
- return unless RUBY_PLATFORM.match(/darwin/)
187
+ private
185
188
 
186
- # macOSで実行可能
187
- show_info('icns')
188
- system("iconutil -c icns #{output_dir}")
189
+ # 入力画像のサイズが条件に一致したときtrueを返す
190
+ def size_match?(size)
191
+ size == [0, 0] || (@width == size[0] && @height == size[1])
189
192
  end
190
193
 
191
194
  def show_info(platform_name)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Appiconset
4
- VERSION = '2.5.0'
4
+ VERSION = '2.6.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.6.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-01-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubocop