makeicon 0.1.6 → 0.1.7

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
  SHA1:
3
- metadata.gz: b55822ad4a4d571c821d608e0acae5076afb2ead
4
- data.tar.gz: 1fb70295687592406888bfe9649bac773b3c58e7
3
+ metadata.gz: 5b44b43cf85eec1e22ea91cd46604cdd81e46904
4
+ data.tar.gz: bc25f0ea9699644146a7f0d1170eb313132f0393
5
5
  SHA512:
6
- metadata.gz: c056a4b37069044078774972b7efcbd9b287331155eee57811a69f75407595b5abde7d3287499e1f0533de1b6f255ae18372b80d2245a9a2ab8dc1b214fdffbb
7
- data.tar.gz: 33bb434dbd8e31df768737bff101905c8c306647d3f4fb79f2e78c2e2f8b8e3a7b3a2b23dcf3eb99cb0bc11bf88308ffd0bda6d085c86bebec08e3ccd55a1445
6
+ metadata.gz: d40d2e31e0b8663edd4e9ab6e8a3ec6c7ca4267f4e4fabb43b78558d1c17a85452767b146fa1793bdf29a4b0bd7960c6400dae6489551d5103b2da753d2e7fe3
7
+ data.tar.gz: 003d4b6da0e9e6d69806d6c0e528575033760ac784f1fd95a63f4eef3ae31c366b657d452eb2296cf9a0f4bdb46e0af6a9f32ab1a28e7ca282269050195e8c83
data/.gitignore CHANGED
@@ -1,13 +1,16 @@
1
- /.bundle/
2
- /.yardoc
3
- /_yardoc/
4
- /coverage/
5
- /doc/
6
- /pkg/
7
- /spec/reports/
8
- /tmp/
9
-
10
- # rspec failure tracking
11
- .rspec_status
12
-
13
- .gem
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ /icon-weixin/
10
+ /icon-qq/
11
+ /icon-weibo/
12
+
13
+ # rspec failure tracking
14
+ .rspec_status
15
+
16
+ .gem
data/README.md CHANGED
@@ -1,38 +1,82 @@
1
1
  # Makeicon
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/makeicon`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ ## Installation
4
+ ### Windows
4
5
 
5
- TODO: Delete this and the text above, and describe your gem
6
+ 1. 安装imagemagick/graphicsmagick
7
+ [下载graphicsmagick](ftp://ftp.graphicsmagick.org/pub/GraphicsMagick/windows/)对应操作系统位数的安装程序,安装过程全部选默认。
6
8
 
7
- ## Installation
9
+ 2. 下载makeicon.exe
10
+ [下载makeicon.exe](http://kgotmbzh-sand.droibaascdn.com/droi/kgotmbzhvdZZbRem9j0h9waEeAyhc0L7lQAAwKII/933627884172611584/makeicon.exe)
8
11
 
9
- Add this line to your application's Gemfile:
12
+ ### Mac
10
13
 
11
- ```ruby
12
- gem 'makeicon'
14
+ 1. 安装imagemagick/graphicsmagick
15
+ ``` bash
16
+ # 如果没有安装brew,请安装
17
+ $ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
18
+ # 安装imagemagick
19
+ $ brew install imagemagick
13
20
  ```
14
21
 
15
- And then execute:
22
+ 2. 安装ruby
23
+ Mac自带,可通过以下命令升级
24
+ ``` bash
25
+ $ sudo gem update --system
26
+ ```
16
27
 
17
- $ bundle
28
+ 3. 安装makeicon
29
+ ``` bash
30
+ $ sudo gem install makeicon
31
+ ```
18
32
 
19
- Or install it yourself as:
33
+ ## Usage
20
34
 
21
- $ gem install makeicon
35
+ ### Windows
36
+ 1. 未加path
37
+ ``` bash
38
+ $ makeicon.exe iconpath
39
+ # 例如(makeicon.exe为全路径)
40
+ $ makeicon.exe Themoji.png
41
+ # 生成的图片在当前文件夹下,以平台命名
42
+ ```
22
43
 
23
- ## Usage
44
+ 2. 加入path
45
+ ``` bash
46
+ $ makeicon iconpath
47
+ # 例如
48
+ $ makeicon Themoji.png
49
+ # 生成的图片在当前文件夹下,以平台命名
50
+ ```
24
51
 
25
- TODO: Write usage instructions here
52
+ ### Mac
53
+ ``` bash
54
+ $ makeicon iconpath
55
+ # 例如
56
+ $ makeicon Themoji.png
57
+ # 生成的图片在当前文件夹下,以平台命名
58
+ ```
26
59
 
27
60
  ## Development
28
61
 
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
62
+ 1. 修改版本号,对`./lib/makeicon/version.rb`的`VERSION = "0.1.6"`进行修改
30
63
 
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
64
+ 2. 打包
65
+ ``` bash
66
+ $ gem build makeicon.gemspec
67
+ ```
32
68
 
33
- ## Contributing
69
+ 3. 发布
70
+ ``` bash
71
+ $ gem push makeicon-VERSION.gem # VERSION替换为0.1.6等
72
+ ```
34
73
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/makeicon. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
74
+ 4. windows-exe 发布(必须在本机安装过最新版makeicon之后)
75
+ ``` bash
76
+ $ gem install ocra
77
+ $ ocra ./bin/makeicon
78
+ # 会在当前目录下生成 makeicon.exe
79
+ ```
36
80
 
37
81
  ## License
38
82
 
data/bin/makeicon CHANGED
@@ -1,6 +1,6 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'makeicon'
4
-
5
- params = Hash[:appicon_image_file => ARGV[0], :appicon_path => "icon",:appicon_filename=>"icon"]
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'makeicon'
4
+
5
+ params = Hash[:appicon_image_file => ARGV[0]||'Themoji.png', :appicon_path => "icon",:appicon_filename=>"icon"]
6
6
  MakeIcon::SocialAction::run(params)
@@ -1,3 +1,3 @@
1
- module Makeicon
2
- VERSION = "0.1.6"
3
- end
1
+ module Makeicon
2
+ VERSION = "0.1.7"
3
+ end
data/lib/makeicon.rb CHANGED
@@ -1,181 +1,183 @@
1
- require "makeicon/version"
2
-
3
- module MakeIcon
4
- module Helper
5
- class AppiconHelper
6
- def self.check_input_image_size(image, size)
7
- puts "Minimum width of input image should be #{size}" if image.width < size
8
- puts "Minimum height of input image should be #{size}" if image.height < size
9
- puts "Input image should be square" if image.width != image.height
10
- # UI.user_error!("Minimum width of input image should be #{size}") if image.width < size
11
- # UI.user_error!("Minimum height of input image should be #{size}") if image.height < size
12
- # UI.user_error!("Input image should be square") if image.width != image.height
13
- end
14
- end
15
- end
16
-
17
- class SocialAction
18
- def self.get_needed_icons(device, needed_icons, is_android = false, custom_sizes = {})
19
- icons = []
20
- puts device
21
- needed_icons[device].each do |scale, sizes|
22
- sizes.each do |size|
23
- if size.kind_of?(Array)
24
- size, role, subtype = size
25
- end
26
-
27
- if is_android
28
- width, height = size.split('x').map { |v| v.to_f }
29
- else
30
- width, height = size.split('x').map { |v| v.to_f * scale.to_i }
31
- end
32
-
33
- icons << {
34
- 'width' => width,
35
- 'height' => height,
36
- 'size' => size,
37
- 'device' => device.to_s.gsub('_', '-'),
38
- 'scale' => scale,
39
- 'role' => role,
40
- 'subtype' => subtype
41
- }
42
- end
43
- end
44
-
45
- # Add custom icon sizes (probably for notifications)
46
- custom_sizes.each do |path, size|
47
- path = path.to_s
48
- width, height = size.split('x').map { |v| v.to_f }
49
-
50
- icons << {
51
- 'width' => width,
52
- 'height' => height,
53
- 'size' => size,
54
- 'basepath' => File.dirname(path),
55
- 'filename' => File.basename(path)
56
- }
57
- end
58
-
59
- # Sort from the largest to the smallest needed icon
60
- icons = icons.sort_by {|value| value['width']} .reverse
61
- end
62
-
63
- def self.needed_icons
64
- {
65
- social: {
66
- 'weixin' => ['28x28','108x108'],
67
- 'weibo' => ['16x16','80x80','120x120'],
68
- 'qq' => ['16x16','512x512'],
69
- },
70
- }
71
- end
72
-
73
- def self.notification_icons(path, filename)
74
- return {} if !path || !filename
75
-
76
- {
77
- "#{path}-ldpi/#{filename}" => '36x36',
78
- "#{path}-mdpi/#{filename}" => '24x24',
79
- "#{path}-hdpi/#{filename}" => '36x36',
80
- "#{path}-xhdpi/#{filename}" => '48x48',
81
- "#{path}-xxhdpi/#{filename}" => '72x72',
82
- "#{path}-xxxhdpi/#{filename}" => '96x96',
83
- }
84
- end
85
-
86
- def self.run(params)
87
- fname = params[:appicon_image_file]
88
-
89
- require 'mini_magick'
90
- image = MiniMagick::Image.open(fname)
91
-
92
- Helper::AppiconHelper.check_input_image_size(image, 512)
93
-
94
- # Convert image to png
95
- image.format 'png'
96
-
97
- # Merge notification icons into customer sizes as they are handled thes same way
98
-
99
- icons = get_needed_icons(:social, self.needed_icons, true)
100
- icons.each do |icon|
101
- width = icon['width']
102
- height = icon['height']
103
-
104
- # Custom icons will have basepath and filename already defined
105
- if icon.has_key?('basepath') && icon.has_key?('filename')
106
- basepath = Pathname.new(icon['basepath'])
107
- filename = icon['filename']
108
- else
109
- basepath = Pathname.new("#{params[:appicon_path]}-#{icon['scale']}")
110
- filename = "#{params[:appicon_filename]}_#{width}x#{height}.png"
111
- end
112
- FileUtils.mkdir_p(basepath)
113
-
114
- image.resize "#{width}x#{height}"
115
- image.write basepath + filename
116
- end
117
-
118
- puts "Successfully stored launcher icons at '#{params[:appicon_path]}'"
119
- end
120
-
121
- def self.get_custom_sizes(image, custom_sizes)
122
-
123
- end
124
-
125
- def self.description
126
- "Generate required icon sizes from a master application icon"
127
- end
128
-
129
- def self.authors
130
- ["@adrum"]
131
- end
132
-
133
- def self.available_options
134
- [
135
- FastlaneCore::ConfigItem.new(key: :appicon_image_file,
136
- env_name: "APPICON_IMAGE_FILE",
137
- description: "Path to a square image file, at least 512x512",
138
- optional: false,
139
- type: String),
140
- FastlaneCore::ConfigItem.new(key: :appicon_devices,
141
- env_name: "APPICON_DEVICES",
142
- default_value: [:phone],
143
- description: "Array of device types to generate icons for",
144
- optional: true,
145
- type: Array),
146
- FastlaneCore::ConfigItem.new(key: :appicon_path,
147
- env_name: "APPICON_PATH",
148
- default_value: 'app/res/mipmap/',
149
- description: "Path to res subfolder",
150
- optional: true,
151
- type: String),
152
- FastlaneCore::ConfigItem.new(key: :appicon_filename,
153
- env_name: "APPICON_FILENAME",
154
- default_value: 'ic_launcher',
155
- description: "The output filename of each image",
156
- optional: true,
157
- type: String),
158
- FastlaneCore::ConfigItem.new(key: :appicon_notification_icon_path,
159
- env_name: "APPICON_NOTIFICATION_ICON_PATH",
160
- default_value: 'app/res/drawable/',
161
- description: "Path to res subfolder",
162
- optional: true,
163
- type: String),
164
- FastlaneCore::ConfigItem.new(key: :appicon_notification_icon_filename,
165
- env_name: "APPICON_NOTIFICATION_ICON_FILENAME",
166
- default_value: 'ic_stat_onesignal_default',
167
- description: "File name for notification icons",
168
- optional: true,
169
- type: String),
170
- FastlaneCore::ConfigItem.new(key: :appicon_custom_sizes,
171
- description: "Hash of custom sizes - {'path/icon.png' => '256x256'}",
172
- optional: true,
173
- type: Hash)
174
- ]
175
- end
176
-
177
- def self.is_supported?(platform)
178
- [:android].include?(platform)
179
- end
180
- end
181
- end
1
+ require "makeicon/version"
2
+
3
+ module MakeIcon
4
+ module Helper
5
+ class AppiconHelper
6
+ def self.check_input_image_size(image, size)
7
+ puts "Minimum width of input image should be #{size}" if image.width < size
8
+ puts "Minimum height of input image should be #{size}" if image.height < size
9
+ puts "Input image should be square" if image.width != image.height
10
+ # UI.user_error!("Minimum width of input image should be #{size}") if image.width < size
11
+ # UI.user_error!("Minimum height of input image should be #{size}") if image.height < size
12
+ # UI.user_error!("Input image should be square") if image.width != image.height
13
+ end
14
+ end
15
+ end
16
+
17
+ class SocialAction
18
+ def self.get_needed_icons(device, needed_icons, is_android = false, custom_sizes = {})
19
+ icons = []
20
+ puts device
21
+ needed_icons[device].each do |scale, sizes|
22
+ sizes.each do |size|
23
+ if size.kind_of?(Array)
24
+ size, role, subtype = size
25
+ end
26
+
27
+ if is_android
28
+ width, height = size.split('x').map { |v| v.to_f }
29
+ else
30
+ width, height = size.split('x').map { |v| v.to_f * scale.to_i }
31
+ end
32
+
33
+ icons << {
34
+ 'width' => width,
35
+ 'height' => height,
36
+ 'size' => size,
37
+ 'device' => device.to_s.gsub('_', '-'),
38
+ 'scale' => scale,
39
+ 'role' => role,
40
+ 'subtype' => subtype
41
+ }
42
+ end
43
+ end
44
+
45
+ # Add custom icon sizes (probably for notifications)
46
+ custom_sizes.each do |path, size|
47
+ path = path.to_s
48
+ width, height = size.split('x').map { |v| v.to_f }
49
+
50
+ icons << {
51
+ 'width' => width,
52
+ 'height' => height,
53
+ 'size' => size,
54
+ 'basepath' => File.dirname(path),
55
+ 'filename' => File.basename(path)
56
+ }
57
+ end
58
+
59
+ # Sort from the largest to the smallest needed icon
60
+ icons = icons.sort_by {|value| value['width']} .reverse
61
+ end
62
+
63
+ def self.needed_icons
64
+ {
65
+ social: {
66
+ 'weixin' => ['28x28','108x108'],
67
+ 'weibo' => ['16x16','80x80','120x120'],
68
+ 'qq' => ['16x16','512x512'],
69
+ },
70
+ }
71
+ end
72
+
73
+ def self.notification_icons(path, filename)
74
+ return {} if !path || !filename
75
+
76
+ {
77
+ "#{path}-ldpi/#{filename}" => '36x36',
78
+ "#{path}-mdpi/#{filename}" => '24x24',
79
+ "#{path}-hdpi/#{filename}" => '36x36',
80
+ "#{path}-xhdpi/#{filename}" => '48x48',
81
+ "#{path}-xxhdpi/#{filename}" => '72x72',
82
+ "#{path}-xxxhdpi/#{filename}" => '96x96',
83
+ }
84
+ end
85
+
86
+ def self.run(params)
87
+ fname = params[:appicon_image_file]
88
+
89
+ require 'mini_magick'
90
+ image = MiniMagick::Image.open(fname)
91
+ fpname = Pathname.new(fname)
92
+ basedir = fpname.dirname
93
+
94
+ Helper::AppiconHelper.check_input_image_size(image, 512)
95
+
96
+ # Convert image to png
97
+ image.format 'png'
98
+
99
+ # Merge notification icons into customer sizes as they are handled thes same way
100
+
101
+ icons = get_needed_icons(:social, self.needed_icons, true)
102
+ icons.each do |icon|
103
+ width = icon['width']
104
+ height = icon['height']
105
+
106
+ # Custom icons will have basepath and filename already defined
107
+ if icon.has_key?('basepath') && icon.has_key?('filename')
108
+ basepath = Pathname.new(icon['basepath'])
109
+ filename = icon['filename']
110
+ else
111
+ basepath = basedir + Pathname.new("#{params[:appicon_path]}-#{icon['scale']}")
112
+ filename = "#{params[:appicon_filename]}_#{width}x#{height}.png"
113
+ end
114
+ FileUtils.mkdir_p(basepath)
115
+ puts basepath + filename
116
+ image.resize "#{width}x#{height}"
117
+ image.write basepath + filename
118
+ end
119
+
120
+ puts "Successfully stored launcher icons at '#{params[:basepath]}'"
121
+ end
122
+
123
+ def self.get_custom_sizes(image, custom_sizes)
124
+
125
+ end
126
+
127
+ def self.description
128
+ "Generate required icon sizes from a master application icon"
129
+ end
130
+
131
+ def self.authors
132
+ ["@adrum"]
133
+ end
134
+
135
+ def self.available_options
136
+ [
137
+ FastlaneCore::ConfigItem.new(key: :appicon_image_file,
138
+ env_name: "APPICON_IMAGE_FILE",
139
+ description: "Path to a square image file, at least 512x512",
140
+ optional: false,
141
+ type: String),
142
+ FastlaneCore::ConfigItem.new(key: :appicon_devices,
143
+ env_name: "APPICON_DEVICES",
144
+ default_value: [:phone],
145
+ description: "Array of device types to generate icons for",
146
+ optional: true,
147
+ type: Array),
148
+ FastlaneCore::ConfigItem.new(key: :appicon_path,
149
+ env_name: "APPICON_PATH",
150
+ default_value: 'app/res/mipmap/',
151
+ description: "Path to res subfolder",
152
+ optional: true,
153
+ type: String),
154
+ FastlaneCore::ConfigItem.new(key: :appicon_filename,
155
+ env_name: "APPICON_FILENAME",
156
+ default_value: 'ic_launcher',
157
+ description: "The output filename of each image",
158
+ optional: true,
159
+ type: String),
160
+ FastlaneCore::ConfigItem.new(key: :appicon_notification_icon_path,
161
+ env_name: "APPICON_NOTIFICATION_ICON_PATH",
162
+ default_value: 'app/res/drawable/',
163
+ description: "Path to res subfolder",
164
+ optional: true,
165
+ type: String),
166
+ FastlaneCore::ConfigItem.new(key: :appicon_notification_icon_filename,
167
+ env_name: "APPICON_NOTIFICATION_ICON_FILENAME",
168
+ default_value: 'ic_stat_onesignal_default',
169
+ description: "File name for notification icons",
170
+ optional: true,
171
+ type: String),
172
+ FastlaneCore::ConfigItem.new(key: :appicon_custom_sizes,
173
+ description: "Hash of custom sizes - {'path/icon.png' => '256x256'}",
174
+ optional: true,
175
+ type: Hash)
176
+ ]
177
+ end
178
+
179
+ def self.is_supported?(platform)
180
+ [:android].include?(platform)
181
+ end
182
+ end
183
+ end
data/makeicon.exe ADDED
Binary file
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: makeicon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - marekchen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-11-23 00:00:00.000000000 Z
11
+ date: 2017-11-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -86,6 +86,7 @@ files:
86
86
  - bin/makeicon
87
87
  - lib/makeicon.rb
88
88
  - lib/makeicon/version.rb
89
+ - makeicon.exe
89
90
  - makeicon.gemspec
90
91
  homepage: http://www.droi.com
91
92
  licenses:
@@ -107,7 +108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
107
108
  version: '0'
108
109
  requirements: []
109
110
  rubyforge_project:
110
- rubygems_version: 2.6.11
111
+ rubygems_version: 2.6.13
111
112
  signing_key:
112
113
  specification_version: 4
113
114
  summary: makeicon