LoginSignup
3
2

More than 5 years have passed since last update.

Appiconset generator

Last updated at Posted at 2017-12-02

はじめに

1024px x 1024pxの画像からmacOSアプリやiOSアプリで必要になるアプリアイコンを書き出すRubyスクリプトです。

以下の環境で動作確認をしています。
macOS High Sierra(10.13.1)

appiconset

appiconsetは以下の方法でインストールできます。

1
$ gem install specific_install
$ gem specific_install -l 'git://github.com/arthur87/appiconset.git'

appiconsetの使い方

2
$ appiconset -h
Usage: appiconset [options] <input>
    -o, --output <output>
    -x, --xcode <version>            set xcode version; 8.3.3, 9.1
    -p, --platform <platform>        set platform; ios, mac, univarsal
    -h, --help                       Show this message

1024px x 1024px の画像からアプリアイコンを作成します。

3
$ appiconset icon.jpg
$ cd ./AppIcon.appiconset
$ ls
Contents.json    Icon-20@3x.png   Icon-40@1x.png   Icon-60@3x.png
Icon-1024@1x.png Icon-29@1x.png   Icon-40@2x.png   Icon-76@1x.png
Icon-20@1x.png   Icon-29@2x.png   Icon-40@3x.png   Icon-76@2x.png
Icon-20@2x.png   Icon-29@3x.png   Icon-60@2x.png   Icon-83.5@2x.png

Contents.jsonと複数のpngファイルが作成されます。
これらのファイルをXcodeプロジェクトのAppIcon.appiconsetにコピーします。

スライド02.jpeg

このスクリプトでは、iOS、macOS、univarsalのアイコン作成をサポートしています。
例えば、platformにmacを指定するとmacOS向け、universalを指定するとimageset向けの3種類のアイコンを作成します。
省略した場合はiOS向けのアイコンを作成します。

4
$ appiconset icon.jpg -p mac

sips

このスクリプトでは、macOSの標準コメンド「sips」を利用しています。
sipsは画像に関する情報取得や画像の変換処理ができます。
このコマンドには、縦横比を維持した変形、回転、水平反転、切り抜きなど多数のオプションがあります。

最後に

このスクリプトはGitHubで公開しています。

3
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
2