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 +4 -4
 - data/.gitignore +16 -13
 - data/README.md +60 -16
 - data/bin/makeicon +5 -5
 - data/lib/makeicon/version.rb +3 -3
 - data/lib/makeicon.rb +183 -181
 - data/makeicon.exe +0 -0
 - metadata +4 -3
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 5b44b43cf85eec1e22ea91cd46604cdd81e46904
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: bc25f0ea9699644146a7f0d1170eb313132f0393
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 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 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
      
 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 
     | 
    
         
            -
             
     | 
| 
      
 3 
     | 
    
         
            +
            ## Installation
         
     | 
| 
      
 4 
     | 
    
         
            +
            ### Windows
         
     | 
| 
       4 
5 
     | 
    
         | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
      
 6 
     | 
    
         
            +
            1. 安装imagemagick/graphicsmagick  
         
     | 
| 
      
 7 
     | 
    
         
            +
            [下载graphicsmagick](ftp://ftp.graphicsmagick.org/pub/GraphicsMagick/windows/)对应操作系统位数的安装程序,安装过程全部选默认。  
         
     | 
| 
       6 
8 
     | 
    
         | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
      
 9 
     | 
    
         
            +
            2. 下载makeicon.exe
         
     | 
| 
      
 10 
     | 
    
         
            +
            [下载makeicon.exe](http://kgotmbzh-sand.droibaascdn.com/droi/kgotmbzhvdZZbRem9j0h9waEeAyhc0L7lQAAwKII/933627884172611584/makeicon.exe)
         
     | 
| 
       8 
11 
     | 
    
         | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
      
 12 
     | 
    
         
            +
            ### Mac
         
     | 
| 
       10 
13 
     | 
    
         | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
      
 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 
     | 
    
         
            -
             
     | 
| 
      
 22 
     | 
    
         
            +
            2. 安装ruby  
         
     | 
| 
      
 23 
     | 
    
         
            +
            Mac自带,可通过以下命令升级
         
     | 
| 
      
 24 
     | 
    
         
            +
            ``` bash
         
     | 
| 
      
 25 
     | 
    
         
            +
            $ sudo gem update --system
         
     | 
| 
      
 26 
     | 
    
         
            +
            ```
         
     | 
| 
       16 
27 
     | 
    
         | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
      
 28 
     | 
    
         
            +
            3. 安装makeicon
         
     | 
| 
      
 29 
     | 
    
         
            +
            ``` bash
         
     | 
| 
      
 30 
     | 
    
         
            +
            $ sudo gem install makeicon
         
     | 
| 
      
 31 
     | 
    
         
            +
            ```
         
     | 
| 
       18 
32 
     | 
    
         | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
      
 33 
     | 
    
         
            +
            ## Usage
         
     | 
| 
       20 
34 
     | 
    
         | 
| 
       21 
     | 
    
         
            -
             
     | 
| 
      
 35 
     | 
    
         
            +
            ### Windows
         
     | 
| 
      
 36 
     | 
    
         
            +
            1. 未加path
         
     | 
| 
      
 37 
     | 
    
         
            +
            ``` bash
         
     | 
| 
      
 38 
     | 
    
         
            +
            $ makeicon.exe iconpath
         
     | 
| 
      
 39 
     | 
    
         
            +
            # 例如(makeicon.exe为全路径)
         
     | 
| 
      
 40 
     | 
    
         
            +
            $ makeicon.exe Themoji.png
         
     | 
| 
      
 41 
     | 
    
         
            +
            # 生成的图片在当前文件夹下,以平台命名
         
     | 
| 
      
 42 
     | 
    
         
            +
            ```
         
     | 
| 
       22 
43 
     | 
    
         | 
| 
       23 
     | 
    
         
            -
             
     | 
| 
      
 44 
     | 
    
         
            +
            2. 加入path
         
     | 
| 
      
 45 
     | 
    
         
            +
            ``` bash
         
     | 
| 
      
 46 
     | 
    
         
            +
            $ makeicon iconpath
         
     | 
| 
      
 47 
     | 
    
         
            +
            # 例如
         
     | 
| 
      
 48 
     | 
    
         
            +
            $ makeicon Themoji.png
         
     | 
| 
      
 49 
     | 
    
         
            +
            # 生成的图片在当前文件夹下,以平台命名
         
     | 
| 
      
 50 
     | 
    
         
            +
            ```
         
     | 
| 
       24 
51 
     | 
    
         | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
      
 52 
     | 
    
         
            +
            ### Mac
         
     | 
| 
      
 53 
     | 
    
         
            +
            ``` bash
         
     | 
| 
      
 54 
     | 
    
         
            +
            $ makeicon iconpath
         
     | 
| 
      
 55 
     | 
    
         
            +
            # 例如
         
     | 
| 
      
 56 
     | 
    
         
            +
            $ makeicon Themoji.png
         
     | 
| 
      
 57 
     | 
    
         
            +
            # 生成的图片在当前文件夹下,以平台命名
         
     | 
| 
      
 58 
     | 
    
         
            +
            ```
         
     | 
| 
       26 
59 
     | 
    
         | 
| 
       27 
60 
     | 
    
         
             
            ## Development
         
     | 
| 
       28 
61 
     | 
    
         | 
| 
       29 
     | 
    
         
            -
             
     | 
| 
      
 62 
     | 
    
         
            +
            1. 修改版本号,对`./lib/makeicon/version.rb`的`VERSION = "0.1.6"`进行修改
         
     | 
| 
       30 
63 
     | 
    
         | 
| 
       31 
     | 
    
         
            -
             
     | 
| 
      
 64 
     | 
    
         
            +
            2. 打包
         
     | 
| 
      
 65 
     | 
    
         
            +
            ``` bash
         
     | 
| 
      
 66 
     | 
    
         
            +
            $ gem build makeicon.gemspec
         
     | 
| 
      
 67 
     | 
    
         
            +
            ```
         
     | 
| 
       32 
68 
     | 
    
         | 
| 
       33 
     | 
    
         
            -
             
     | 
| 
      
 69 
     | 
    
         
            +
            3. 发布
         
     | 
| 
      
 70 
     | 
    
         
            +
            ``` bash
         
     | 
| 
      
 71 
     | 
    
         
            +
            $ gem push makeicon-VERSION.gem # VERSION替换为0.1.6等
         
     | 
| 
      
 72 
     | 
    
         
            +
            ```
         
     | 
| 
       34 
73 
     | 
    
         | 
| 
       35 
     | 
    
         
            -
             
     | 
| 
      
 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)
         
     | 
    
        data/lib/makeicon/version.rb
    CHANGED
    
    | 
         @@ -1,3 +1,3 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            module Makeicon
         
     | 
| 
       2 
     | 
    
         
            -
              VERSION = "0.1. 
     | 
| 
       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 
     | 
    
         
            -
                   
     | 
| 
       93 
     | 
    
         
            -
             
     | 
| 
       94 
     | 
    
         
            -
                   
     | 
| 
       95 
     | 
    
         
            -
             
     | 
| 
       96 
     | 
    
         
            -
                  
         
     | 
| 
       97 
     | 
    
         
            -
                   
     | 
| 
       98 
     | 
    
         
            -
             
     | 
| 
       99 
     | 
    
         
            -
                  icons  
     | 
| 
       100 
     | 
    
         
            -
             
     | 
| 
       101 
     | 
    
         
            -
             
     | 
| 
       102 
     | 
    
         
            -
             
     | 
| 
       103 
     | 
    
         
            -
             
     | 
| 
       104 
     | 
    
         
            -
                     
     | 
| 
       105 
     | 
    
         
            -
             
     | 
| 
       106 
     | 
    
         
            -
             
     | 
| 
       107 
     | 
    
         
            -
             
     | 
| 
       108 
     | 
    
         
            -
             
     | 
| 
       109 
     | 
    
         
            -
                       
     | 
| 
       110 
     | 
    
         
            -
             
     | 
| 
       111 
     | 
    
         
            -
             
     | 
| 
       112 
     | 
    
         
            -
             
     | 
| 
       113 
     | 
    
         
            -
             
     | 
| 
       114 
     | 
    
         
            -
                     
     | 
| 
       115 
     | 
    
         
            -
                     
     | 
| 
       116 
     | 
    
         
            -
             
     | 
| 
       117 
     | 
    
         
            -
             
     | 
| 
       118 
     | 
    
         
            -
                   
     | 
| 
       119 
     | 
    
         
            -
             
     | 
| 
       120 
     | 
    
         
            -
             
     | 
| 
       121 
     | 
    
         
            -
                 
     | 
| 
       122 
     | 
    
         
            -
             
     | 
| 
       123 
     | 
    
         
            -
                 
     | 
| 
       124 
     | 
    
         
            -
             
     | 
| 
       125 
     | 
    
         
            -
                 
     | 
| 
       126 
     | 
    
         
            -
             
     | 
| 
       127 
     | 
    
         
            -
                 
     | 
| 
       128 
     | 
    
         
            -
             
     | 
| 
       129 
     | 
    
         
            -
                 
     | 
| 
       130 
     | 
    
         
            -
             
     | 
| 
       131 
     | 
    
         
            -
                 
     | 
| 
       132 
     | 
    
         
            -
             
     | 
| 
       133 
     | 
    
         
            -
                 
     | 
| 
       134 
     | 
    
         
            -
             
     | 
| 
       135 
     | 
    
         
            -
             
     | 
| 
       136 
     | 
    
         
            -
             
     | 
| 
       137 
     | 
    
         
            -
             
     | 
| 
       138 
     | 
    
         
            -
                                             
     | 
| 
       139 
     | 
    
         
            -
             
     | 
| 
       140 
     | 
    
         
            -
             
     | 
| 
       141 
     | 
    
         
            -
             
     | 
| 
       142 
     | 
    
         
            -
             
     | 
| 
       143 
     | 
    
         
            -
             
     | 
| 
       144 
     | 
    
         
            -
             
     | 
| 
       145 
     | 
    
         
            -
             
     | 
| 
       146 
     | 
    
         
            -
             
     | 
| 
       147 
     | 
    
         
            -
             
     | 
| 
       148 
     | 
    
         
            -
             
     | 
| 
       149 
     | 
    
         
            -
             
     | 
| 
       150 
     | 
    
         
            -
             
     | 
| 
       151 
     | 
    
         
            -
             
     | 
| 
       152 
     | 
    
         
            -
             
     | 
| 
       153 
     | 
    
         
            -
             
     | 
| 
       154 
     | 
    
         
            -
             
     | 
| 
       155 
     | 
    
         
            -
             
     | 
| 
       156 
     | 
    
         
            -
             
     | 
| 
       157 
     | 
    
         
            -
             
     | 
| 
       158 
     | 
    
         
            -
             
     | 
| 
       159 
     | 
    
         
            -
             
     | 
| 
       160 
     | 
    
         
            -
             
     | 
| 
       161 
     | 
    
         
            -
             
     | 
| 
       162 
     | 
    
         
            -
             
     | 
| 
       163 
     | 
    
         
            -
             
     | 
| 
       164 
     | 
    
         
            -
             
     | 
| 
       165 
     | 
    
         
            -
             
     | 
| 
       166 
     | 
    
         
            -
             
     | 
| 
       167 
     | 
    
         
            -
             
     | 
| 
       168 
     | 
    
         
            -
             
     | 
| 
       169 
     | 
    
         
            -
             
     | 
| 
       170 
     | 
    
         
            -
             
     | 
| 
       171 
     | 
    
         
            -
             
     | 
| 
       172 
     | 
    
         
            -
             
     | 
| 
       173 
     | 
    
         
            -
             
     | 
| 
       174 
     | 
    
         
            -
             
     | 
| 
       175 
     | 
    
         
            -
             
     | 
| 
       176 
     | 
    
         
            -
             
     | 
| 
       177 
     | 
    
         
            -
                 
     | 
| 
       178 
     | 
    
         
            -
             
     | 
| 
       179 
     | 
    
         
            -
                 
     | 
| 
       180 
     | 
    
         
            -
             
     | 
| 
       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. 
     | 
| 
      
 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- 
     | 
| 
      
 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. 
     | 
| 
      
 111 
     | 
    
         
            +
            rubygems_version: 2.6.13
         
     | 
| 
       111 
112 
     | 
    
         
             
            signing_key: 
         
     | 
| 
       112 
113 
     | 
    
         
             
            specification_version: 4
         
     | 
| 
       113 
114 
     | 
    
         
             
            summary: makeicon
         
     |