appiconset 2.0.0 → 2.2.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 +4 -4
- data/.rubocop_todo.yml +19 -3
- data/README.md +24 -3
- data/lib/appiconset/cli.rb +34 -4
- data/lib/appiconset/generator.rb +83 -9
- data/lib/appiconset/version.rb +1 -1
- data/lib/appiconset.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6ef0d21daa468cb3bca61be5786766824f2c4ec9c553e9c3df5cf6dec06fd635
|
4
|
+
data.tar.gz: 514769fbdbfa9bbcc9de26ee59ecab63f89062695d158a1f54d87af76afa6c89
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 314eac0eab5dea83e8785067433d781f52ecdf769a46a06b2a678a868c30c03a73fbb6b1bf6025cd304ac66600c787251da2c17f5f5280beef16892518982534
|
7
|
+
data.tar.gz: 7a76a7819eaf2dfef44a2b9fad945b3cbedb578b04c84374eed3b41464f7c6da4667a26258a77683ff83424d3aa312b464d663c3bb8fd30e5a174c81a22a68d6
|
data/.rubocop_todo.yml
CHANGED
@@ -1,17 +1,33 @@
|
|
1
1
|
# This configuration was generated by
|
2
2
|
# `rubocop --auto-gen-config`
|
3
|
-
# on 2024-12-
|
3
|
+
# on 2024-12-09 13:28:48 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:
|
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
15
|
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
|
16
|
+
# AllowedMethods: refine
|
17
|
+
Metrics/BlockLength:
|
18
|
+
Max: 47
|
19
|
+
|
20
|
+
# Offense count: 1
|
21
|
+
# Configuration parameters: CountComments, CountAsOne.
|
22
|
+
Metrics/ClassLength:
|
23
|
+
Max: 102
|
24
|
+
|
25
|
+
# Offense count: 1
|
26
|
+
# Configuration parameters: AllowedMethods, AllowedPatterns.
|
27
|
+
Metrics/CyclomaticComplexity:
|
28
|
+
Max: 8
|
29
|
+
|
30
|
+
# Offense count: 3
|
31
|
+
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
|
16
32
|
Metrics/MethodLength:
|
17
|
-
Max:
|
33
|
+
Max: 38
|
data/README.md
CHANGED
@@ -11,14 +11,35 @@
|
|
11
11
|
* Universal
|
12
12
|
* watchOS
|
13
13
|
* Android
|
14
|
+
* tvOS
|
14
15
|
|
15
|
-
|
16
|
+
# 使い方
|
17
|
+
|
18
|
+
## 正方形アイコン
|
16
19
|
|
17
20
|
1024px x 1024px の画像からアプリアイコンを作成します。
|
18
21
|
|
19
22
|
```
|
20
|
-
$ appiconset
|
23
|
+
$ appiconset square -i='sample.jpg' -o='output'
|
21
24
|
```
|
22
25
|
|
23
26
|
Contents.jsonと複数のpngファイルが作成されます。
|
24
|
-
これらのファイルをXcodeプロジェクトの AppIcon.appiconset にコピーします。
|
27
|
+
これらのファイルをXcodeプロジェクトの AppIcon.appiconset にコピーします。
|
28
|
+
|
29
|
+
|
30
|
+
## tvOSのアイコン
|
31
|
+
|
32
|
+
tvOSアプリ向けのアイコンを作成するには。4640px x 1440px の画像を用意します。
|
33
|
+
この画像からApp Icon.imagestack、Top Shelf Image.imageset、Top Shelf Image Wide.imagesetのアイコンを作成します。
|
34
|
+
|
35
|
+
```
|
36
|
+
$ appiconset tvos -i='sample.jpg' -o='output'
|
37
|
+
```
|
38
|
+
|
39
|
+
## 任意のサイズのアイコン
|
40
|
+
|
41
|
+
任意のサイズの画像から、1倍、2/3倍、1/3倍のアイコンを作成します。
|
42
|
+
|
43
|
+
```
|
44
|
+
$ appiconset universal -i='sample.jpg' -o='output'
|
45
|
+
```
|
data/lib/appiconset/cli.rb
CHANGED
@@ -17,10 +17,10 @@ module Appiconset
|
|
17
17
|
puts(Appiconset::VERSION)
|
18
18
|
end
|
19
19
|
|
20
|
-
desc '
|
21
|
-
method_option :input, desc: 'Input
|
22
|
-
method_option :output, desc: 'Write output to <
|
23
|
-
def
|
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
|
data/lib/appiconset/generator.rb
CHANGED
@@ -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 !=
|
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
|
-
|
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
|
-
|
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
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
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
|
data/lib/appiconset/version.rb
CHANGED
data/lib/appiconset.rb
CHANGED
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.
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- arthur87
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-12-
|
11
|
+
date: 2024-12-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubocop
|