Giter Club home page Giter Club logo

macimagesetgenerator's Introduction

概述

之前用的一个批量导出APP图标和启动图的软件,今天发现收费了,于是自己造了个简单的轮子。

实现

Mac上的sips命令,可以很方便的帮助用户修改图片尺寸

Xcode里面的APP启动图资源包含两部分

  1. 图片资源
  2. 描述文件

所以这个脚本的功能就是两个

  1. 生成描述文件Contents.json
  2. 修改图片尺寸并关联描述文件

生成描述文件

使用cat命令生成描述文件

setContents(){
cat <<EOF >./AppIcon/Contents.json
{  
    "images" : [
    {
      "size" : "20x20",
      "idiom" : "iphone",
      "scale" : "2x",
      "filename" : "icon_40x40.png"
    },
    {
      "size" : "20x20",
      "idiom" : "iphone",
      "scale" : "3x",
      "filename" : "icon_60x60.png"
    },
    ...
EOF
}

修改图片尺寸

iconWithSize() {
sips -Z $1 icon.png --out ./AppIcon/icon_$1x$1.png
}

函数调用

mkdir AppIcon
setContents
for size in  40 58 60 80 87 120 180 1024
do
iconWithSize $size
done

效果展示

怎么使用

AppIcon

下载对应的sh文件,放到你想导出图片的目录下,将你的原图命名为icon.png,然后在控制台中进入该目录,执行

sh AppIcon.sh

LaunchImage

下载对应的sh文件,放到你想导出图片的目录下,将你的原图命名为default.png,然后在控制台中进入该目录,执行

sh AppLaunch.sh

就可以得到你要的资源啦。

更新日志

2019-04-28

更新生成XRXS Max的启动图

2018-08-07

更新代码,使用cat命令替换echo生成Contents.json文件
感谢@LinMaris提供的思路

2018-06-24

更新iPad图标支持

macimagesetgenerator's People

Contributors

wuotto avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.