appiconset 2.0.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 2effb276686faf59913e1750ddac211d82b68e997079cf751ca3741ab28b72de
4
+ data.tar.gz: bda7998c4c90066966e6b1cdf3e54d2b0081cc20fda781d25410acfe81d3fb3b
5
+ SHA512:
6
+ metadata.gz: 9c89abbdf651a1caf63fd6d6c9787b9fdb85f80bceea6897343d909fe27f8e313e6fb7430b65e0e9a815f402aa58673c8f01b2d505b25d23caa6369812d25305
7
+ data.tar.gz: 5b4a5cc20e7cd4c1ff1ca36bd1e4d36e683e649b9522862d1d9841225325a92309ec979a05a162761f0a6d3051894e653aec2ffb6e47ff047729c516c14eb38a
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.rubocop.yml ADDED
@@ -0,0 +1 @@
1
+ inherit_from: .rubocop_todo.yml
data/.rubocop_todo.yml ADDED
@@ -0,0 +1,17 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2024-12-07 11:26:17 UTC using RuboCop version 1.63.2.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 1
10
+ # Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
11
+ Metrics/AbcSize:
12
+ Max: 32
13
+
14
+ # Offense count: 1
15
+ # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
16
+ Metrics/MethodLength:
17
+ Max: 23
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.0
data/CHANGELOG.md ADDED
File without changes
data/README.md ADDED
@@ -0,0 +1,24 @@
1
+ # Appiconset
2
+
3
+ 1024px x 1024pxの画像からmacOSアプリやiOSアプリで必要になるアプリアイコンを書き出すRubyスクリプトです。
4
+
5
+ 以下の環境で動作確認をしています。
6
+ * macOS 15.1
7
+
8
+ 以下のプラットフォームのアイコン作成をサポートしています。
9
+ * iOS/iPadOS
10
+ * macOS
11
+ * Universal
12
+ * watchOS
13
+ * Android
14
+
15
+ ## 使い方
16
+
17
+ 1024px x 1024px の画像からアプリアイコンを作成します。
18
+
19
+ ```
20
+ $ appiconset icons -i='sample.jpg' -o='output'
21
+ ```
22
+
23
+ Contents.jsonと複数のpngファイルが作成されます。
24
+ これらのファイルをXcodeプロジェクトの AppIcon.appiconset にコピーします。
data/Rakefile ADDED
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ task default: %i[]
data/exe/appiconset ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'appiconset'
5
+
6
+ Appiconset::CLI.start
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'appiconset'
4
+ require 'thor'
5
+
6
+ module Appiconset
7
+ # entry point
8
+ class CLI < Thor
9
+ class << self
10
+ def exit_on_failure?
11
+ true
12
+ end
13
+ end
14
+
15
+ desc 'version', 'Show Version'
16
+ def version
17
+ puts(Appiconset::VERSION)
18
+ end
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
24
+ generator = Appiconset::Generator.new
25
+
26
+ begin
27
+ generator.config(options[:input].to_s, options[:output].to_s)
28
+ generator.square_platforms
29
+ rescue StandardError => e
30
+ warn e.message
31
+ exit(1)
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,69 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'appiconset'
4
+ require 'json'
5
+
6
+ # Appiconset
7
+ module Appiconset
8
+ # Generator
9
+ class Generator
10
+ def initialize; end
11
+
12
+ def config(input, output)
13
+ raise 'no input file.' unless File.exist?(input)
14
+
15
+ size = FastImage.size(input)
16
+ raise 'unsupported size.' if size[0].to_i != 1024 || size[1].to_i != 1024
17
+
18
+ output += '/' unless output.end_with?('/')
19
+
20
+ FileUtils.mkdir_p(output) unless FileTest.exist?(output)
21
+
22
+ @input = input
23
+ @output = output
24
+ end
25
+
26
+ # 正方形アイコン
27
+ def square_platforms
28
+ json_dir = "#{__dir__}/settings/*.json"
29
+
30
+ Dir.glob(json_dir).each do |path|
31
+ json_data = File.open(path) do |f|
32
+ JSON.parse(f.read)
33
+ end
34
+
35
+ # プラットフォームごとのディレクトリ
36
+ platform = File.basename(path).gsub('-Contents.json', '')
37
+ output_dir = "#{@output}#{platform}/"
38
+
39
+ FileUtils.mkdir_p(output_dir)
40
+
41
+ json_data['images'].each do |image|
42
+ size = image['size'].match(/(.*?)x/)[1].to_f
43
+ scale = image['scale'].gsub('x', '').to_i
44
+ # 実際のサイズ
45
+ real_size = size * scale
46
+ name = image['filename']
47
+
48
+ image_write(real_size, output_dir + name)
49
+ end
50
+
51
+ # Xcode用にファイルをコピーする
52
+ begin
53
+ FileUtils.cp(path, "#{output_dir}/Contents.json") if json_data['info']['author'] == 'xcode'
54
+ rescue StandardError
55
+ # none
56
+ end
57
+ end
58
+ end
59
+
60
+ private
61
+
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)
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,116 @@
1
+ {
2
+ "images": [
3
+ {
4
+ "size": "20x20",
5
+ "idiom": "iphone",
6
+ "filename": "Icon-20@2x.png",
7
+ "scale": "2x"
8
+ },
9
+ {
10
+ "size": "20x20",
11
+ "idiom": "iphone",
12
+ "filename": "Icon-20@3x.png",
13
+ "scale": "3x"
14
+ },
15
+ {
16
+ "size": "29x29",
17
+ "idiom": "iphone",
18
+ "filename": "Icon-29@2x.png",
19
+ "scale": "2x"
20
+ },
21
+ {
22
+ "size": "29x29",
23
+ "idiom": "iphone",
24
+ "filename": "Icon-29@3x.png",
25
+ "scale": "3x"
26
+ },
27
+ {
28
+ "size": "40x40",
29
+ "idiom": "iphone",
30
+ "filename": "Icon-40@2x.png",
31
+ "scale": "2x"
32
+ },
33
+ {
34
+ "size": "40x40",
35
+ "idiom": "iphone",
36
+ "filename": "Icon-40@3x.png",
37
+ "scale": "3x"
38
+ },
39
+ {
40
+ "size": "60x60",
41
+ "idiom": "iphone",
42
+ "filename": "Icon-60@2x.png",
43
+ "scale": "2x"
44
+ },
45
+ {
46
+ "size": "60x60",
47
+ "idiom": "iphone",
48
+ "filename": "Icon-60@3x.png",
49
+ "scale": "3x"
50
+ },
51
+ {
52
+ "size": "20x20",
53
+ "idiom": "ipad",
54
+ "filename": "Icon-20@1x.png",
55
+ "scale": "1x"
56
+ },
57
+ {
58
+ "size": "20x20",
59
+ "idiom": "ipad",
60
+ "filename": "Icon-20@2x.png",
61
+ "scale": "2x"
62
+ },
63
+ {
64
+ "size": "29x29",
65
+ "idiom": "ipad",
66
+ "filename": "Icon-29@1x.png",
67
+ "scale": "1x"
68
+ },
69
+ {
70
+ "size": "29x29",
71
+ "idiom": "ipad",
72
+ "filename": "Icon-29@2x.png",
73
+ "scale": "2x"
74
+ },
75
+ {
76
+ "size": "40x40",
77
+ "idiom": "ipad",
78
+ "filename": "Icon-40@1x.png",
79
+ "scale": "1x"
80
+ },
81
+ {
82
+ "size": "40x40",
83
+ "idiom": "ipad",
84
+ "filename": "Icon-40@2x.png",
85
+ "scale": "2x"
86
+ },
87
+ {
88
+ "size": "76x76",
89
+ "idiom": "ipad",
90
+ "filename": "Icon-76@1x.png",
91
+ "scale": "1x"
92
+ },
93
+ {
94
+ "size": "76x76",
95
+ "idiom": "ipad",
96
+ "filename": "Icon-76@2x.png",
97
+ "scale": "2x"
98
+ },
99
+ {
100
+ "size": "83.5x83.5",
101
+ "idiom": "ipad",
102
+ "filename": "Icon-83.5@2x.png",
103
+ "scale": "2x"
104
+ },
105
+ {
106
+ "size": "1024x1024",
107
+ "idiom": "ios-marketing",
108
+ "filename": "Icon-1024@1x.png",
109
+ "scale": "1x"
110
+ }
111
+ ],
112
+ "info": {
113
+ "version": 1,
114
+ "author": "xcode"
115
+ }
116
+ }
@@ -0,0 +1,68 @@
1
+ {
2
+ "images": [
3
+ {
4
+ "size": "16x16",
5
+ "idiom": "mac",
6
+ "filename": "Icon-16@1x.png",
7
+ "scale": "1x"
8
+ },
9
+ {
10
+ "size": "16x16",
11
+ "idiom": "mac",
12
+ "filename": "Icon-16@2x.png",
13
+ "scale": "2x"
14
+ },
15
+ {
16
+ "size": "32x32",
17
+ "idiom": "mac",
18
+ "filename": "Icon-32@1x.png",
19
+ "scale": "1x"
20
+ },
21
+ {
22
+ "size": "32x32",
23
+ "idiom": "mac",
24
+ "filename": "Icon-32@2x.png",
25
+ "scale": "2x"
26
+ },
27
+ {
28
+ "size": "128x128",
29
+ "idiom": "mac",
30
+ "filename": "Icon-128@1x.png",
31
+ "scale": "1x"
32
+ },
33
+ {
34
+ "size": "128x128",
35
+ "idiom": "mac",
36
+ "filename": "Icon-128@2x.png",
37
+ "scale": "2x"
38
+ },
39
+ {
40
+ "size": "256x256",
41
+ "idiom": "mac",
42
+ "filename": "Icon-256@1x.png",
43
+ "scale": "1x"
44
+ },
45
+ {
46
+ "size": "256x256",
47
+ "idiom": "mac",
48
+ "filename": "Icon-256@2x.png",
49
+ "scale": "2x"
50
+ },
51
+ {
52
+ "size": "512x512",
53
+ "idiom": "mac",
54
+ "filename": "Icon-512@1x.png",
55
+ "scale": "1x"
56
+ },
57
+ {
58
+ "size": "512x512",
59
+ "idiom": "mac",
60
+ "filename": "Icon-512@2x.png",
61
+ "scale": "2x"
62
+ }
63
+ ],
64
+ "info": {
65
+ "version": 1,
66
+ "author": "xcode"
67
+ }
68
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "images": [
3
+ {
4
+ "size": "72x72",
5
+ "filename": "ic_launcher.png",
6
+ "scale": "1x"
7
+ }
8
+ ]
9
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "images": [
3
+ {
4
+ "size": "48x48",
5
+ "filename": "ic_launcher.png",
6
+ "scale": "1x"
7
+ }
8
+ ]
9
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "images": [
3
+ {
4
+ "size": "96x96",
5
+ "filename": "ic_launcher.png",
6
+ "scale": "1x"
7
+ }
8
+ ]
9
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "images": [
3
+ {
4
+ "size": "144x144",
5
+ "filename": "ic_launcher.png",
6
+ "scale": "1x"
7
+ }
8
+ ]
9
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "images": [
3
+ {
4
+ "size": "192x192",
5
+ "filename": "ic_launcher.png",
6
+ "scale": "1x"
7
+ }
8
+ ]
9
+ }
@@ -0,0 +1,26 @@
1
+ {
2
+ "images": [
3
+ {
4
+ "size": "341x341",
5
+ "idiom": "universal",
6
+ "filename": "Icon-341@3x.png",
7
+ "scale": "3x"
8
+ },
9
+ {
10
+ "size": "341x341",
11
+ "idiom": "universal",
12
+ "filename": "Icon-341@2x.png",
13
+ "scale": "2x"
14
+ },
15
+ {
16
+ "size": "341x341",
17
+ "idiom": "universal",
18
+ "filename": "Icon-341@1x.png",
19
+ "scale": "1x"
20
+ }
21
+ ],
22
+ "info": {
23
+ "version": 1,
24
+ "author": "xcode"
25
+ }
26
+ }
@@ -0,0 +1,92 @@
1
+ {
2
+ "images": [
3
+ {
4
+ "size": "24x24",
5
+ "idiom": "watch",
6
+ "filename": "Icon-24@2x.png",
7
+ "scale": "2x",
8
+ "role": "notificationCenter",
9
+ "subtype": "38mm"
10
+ },
11
+ {
12
+ "size": "27.5x27.5",
13
+ "idiom": "watch",
14
+ "filename": "Icon-27.5@2x.png",
15
+ "scale": "2x",
16
+ "role": "notificationCenter",
17
+ "subtype": "42mm"
18
+ },
19
+ {
20
+ "size": "29x29",
21
+ "idiom": "watch",
22
+ "filename": "Icon-29@2x.png",
23
+ "scale": "2x",
24
+ "role": "companionSettings"
25
+ },
26
+ {
27
+ "size": "29x29",
28
+ "idiom": "watch",
29
+ "filename": "Icon-29@3x.png",
30
+ "scale": "3x",
31
+ "role": "companionSettings"
32
+ },
33
+ {
34
+ "size": "40x40",
35
+ "idiom": "watch",
36
+ "filename": "Icon-40@2x.png",
37
+ "scale": "2x",
38
+ "role": "appLauncher",
39
+ "subtype": "38mm"
40
+ },
41
+ {
42
+ "size": "44x44",
43
+ "idiom": "watch",
44
+ "filename": "Icon-44@2x.png",
45
+ "scale": "2x",
46
+ "role": "appLauncher",
47
+ "subtype": "40mm"
48
+ },
49
+ {
50
+ "size" : "50x50",
51
+ "idiom" : "watch",
52
+ "filename": "Icon-50@2x.png",
53
+ "scale" : "2x",
54
+ "role" : "appLauncher",
55
+ "subtype" : "44mm"
56
+ },
57
+ {
58
+ "size": "86x86",
59
+ "idiom": "watch",
60
+ "filename": "Icon-86@2x.png",
61
+ "scale": "2x",
62
+ "role": "quickLook",
63
+ "subtype": "38mm"
64
+ },
65
+ {
66
+ "size": "98x98",
67
+ "idiom": "watch",
68
+ "filename": "Icon-98@2x.png",
69
+ "scale": "2x",
70
+ "role": "quickLook",
71
+ "subtype": "42mm"
72
+ },
73
+ {
74
+ "size" : "108x108",
75
+ "idiom" : "watch",
76
+ "filename": "Icon-108@2x.png",
77
+ "scale" : "2x",
78
+ "role" : "quickLook",
79
+ "subtype" : "44mm"
80
+ },
81
+ {
82
+ "size": "1024x1024",
83
+ "idiom": "watch-marketing",
84
+ "filename": "Icon-1024@1x.png",
85
+ "scale": "1x"
86
+ }
87
+ ],
88
+ "info": {
89
+ "version": 1,
90
+ "author": "xcode"
91
+ }
92
+ }
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Appiconset
4
+ VERSION = '2.0.0'
5
+ end
data/lib/appiconset.rb ADDED
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'appiconset/version'
4
+ require 'appiconset/cli'
5
+ require 'appiconset/generator'
6
+ require 'fastimage'
7
+ require 'fileutils'
8
+ require 'RMagick'
9
+
10
+ module Appiconset
11
+ class Error < StandardError; end
12
+ # Your code goes here...
13
+ end
@@ -0,0 +1,4 @@
1
+ module Appiconset
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
metadata ADDED
@@ -0,0 +1,125 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: appiconset
3
+ version: !ruby/object:Gem::Version
4
+ version: 2.0.0
5
+ platform: ruby
6
+ authors:
7
+ - arthur87
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2024-12-07 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rubocop
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: fastimage
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rmagick
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: thor
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: |-
70
+ This is a Ruby script that will write out app icons needed for macOS apps,
71
+ iOS apps, etc. from a 1024px x 1024px image.
72
+ email:
73
+ - arthur87@users.noreply.github.com
74
+ executables:
75
+ - appiconset
76
+ extensions: []
77
+ extra_rdoc_files: []
78
+ files:
79
+ - ".rspec"
80
+ - ".rubocop.yml"
81
+ - ".rubocop_todo.yml"
82
+ - ".travis.yml"
83
+ - CHANGELOG.md
84
+ - README.md
85
+ - Rakefile
86
+ - exe/appiconset
87
+ - lib/appiconset.rb
88
+ - lib/appiconset/cli.rb
89
+ - lib/appiconset/generator.rb
90
+ - lib/appiconset/settings/iphone-xcode9.1-Contents.json
91
+ - lib/appiconset/settings/mac-xcode9.1-Contents.json
92
+ - lib/appiconset/settings/mipmap-hdpi-Contents.json
93
+ - lib/appiconset/settings/mipmap-mdpi-Contents.json
94
+ - lib/appiconset/settings/mipmap-xdpi-Contents.json
95
+ - lib/appiconset/settings/mipmap-xxhdpi-Contents.json
96
+ - lib/appiconset/settings/mipmap-xxxhdpi-Contents.json
97
+ - lib/appiconset/settings/universal-xcode9.1-Contents.json
98
+ - lib/appiconset/settings/watch-xcode10.0-Contents.json
99
+ - lib/appiconset/version.rb
100
+ - sig/appiconset.rbs
101
+ homepage: https://github.com/arthur87/appiconset
102
+ licenses: []
103
+ metadata:
104
+ homepage_uri: https://github.com/arthur87/appiconset
105
+ source_code_uri: https://github.com/arthur87/appiconset
106
+ post_install_message:
107
+ rdoc_options: []
108
+ require_paths:
109
+ - lib
110
+ required_ruby_version: !ruby/object:Gem::Requirement
111
+ requirements:
112
+ - - ">="
113
+ - !ruby/object:Gem::Version
114
+ version: 3.0.0
115
+ required_rubygems_version: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - ">="
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
120
+ requirements: []
121
+ rubygems_version: 3.5.11
122
+ signing_key:
123
+ specification_version: 4
124
+ summary: appiconset generator for Xcode
125
+ test_files: []