├── .gitignore ├── screens └── .gitignore ├── s9splashgen.rb └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | *.png -------------------------------------------------------------------------------- /screens/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore -------------------------------------------------------------------------------- /s9splashgen.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # encoding : utf-8 3 | 4 | require 'rubygems' 5 | require 'RMagick' 6 | include Magick 7 | 8 | # arguments processing 9 | if ARGV.empty? 10 | puts 'no arguments given' 11 | exit 12 | else 13 | img_name = ARGV[0] 14 | unless File.exists?(img_name) 15 | puts "no file named #{img_name}" 16 | exit 17 | end 18 | end 19 | 20 | device = (ARGV.count > 1 ? ARGV[1] : 'iphone') 21 | img = ImageList.new(img_name) 22 | 23 | # only iOS 7.0 and above 24 | sizes = [{ 25 | idiom: 'iphone 4 portrait', 26 | name: 'Default@2x~iphone.png', 27 | orientation: 'portrait', 28 | width: 320, 29 | height: 480, 30 | scale: 2}, 31 | { 32 | idiom: 'iphone 5 portrait', 33 | name: 'Default-568h@2x~iphone.png', 34 | orientation: 'portrait', 35 | width: 320, 36 | height: 568, 37 | scale: 2}, 38 | { 39 | idiom: 'iphone 6 portrait', 40 | name: 'Default-667h@2x~iphone.png', 41 | orientation: 'portrait', 42 | width: 375, 43 | height: 667, 44 | scale: 2}, 45 | { 46 | idiom: 'iphone 6 plus portrait', 47 | name: 'Default-736h@3x~iphone.png', 48 | orientation: 'portrait', 49 | width: 414, 50 | height: 736, 51 | scale: 3}, 52 | { 53 | idiom: 'ipad 1/2 portrait', 54 | name: 'Default-Portrait~ipad.png', 55 | orientation: 'portrait', 56 | width: 768, 57 | height: 1024, 58 | scale: 1}, 59 | { 60 | idiom: 'ipad 1/2 landscape', 61 | name: 'Default-Landscape~ipad.png', 62 | orientation: 'landscape', 63 | width: 1024, 64 | height: 768, 65 | scale: 1}, 66 | { 67 | idiom: 'ipad 3/4/Air portrait', 68 | name: 'Default-Portrait@2x~ipad.png', 69 | orientation: 'portrait', 70 | width: 768, 71 | height: 1024, 72 | scale: 2}, 73 | { 74 | idiom: 'ipad 3/4/Air landscape', 75 | name: 'Default-Landscape@2x~ipad.png', 76 | orientation: 'landscape', 77 | width: 1024, 78 | height: 768, 79 | scale: 2}] 80 | 81 | def log(width, height, scale, filename) 82 | s = "#{width/scale}x#{height/scale}" 83 | s.insert(0, ' '*(9 - s.length)) 84 | f = "#{scale}x" 85 | fs = "#{width}x#{height}" 86 | fs.insert(0, ' '*(9 - fs.length)) 87 | puts "#{s}(#{f}) -> #{fs}: #{filename}" 88 | end 89 | 90 | `rm screens/*.png` unless Dir['screens/*.png'].empty? 91 | sizes.each do |s| 92 | if device == 'universal' || s[:idiom].start_with?(device) 93 | width = s[:scale]*s[:width] 94 | height = s[:scale]*s[:height] 95 | scaled_img = img.resize_to_fill(width, height) 96 | filename = 'screens/' + s[:name] 97 | log(width, height, s[:scale], filename) 98 | scaled_img.write(filename) 99 | end 100 | end -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | s9splashgen - Splash screen generator 2 | ====================================== 3 | 4 | ## Introduction 5 | 6 | The Ruby script `s9splashgen` automatically generates splash screens of all necessary sizes for iPhone and/or iPad apps (iOS 7 and above). It uses `imagemagick` and the gem `rmagick`. 7 | 8 | ## Installation 9 | 10 | Install `imagemagick` and `rmagick` via 11 | 12 | ```bash 13 | brew install imagemagick 14 | gem install rmagick 15 | ``` 16 | 17 | ## Usage 18 | 19 | Just run the script 20 | 21 | ```bash 22 | ./s9splashgen.rb my_splash.png 23 | ``` 24 | 25 | The first argument is the filename of the splash screen image (for best results use an image in portrait mode of size of at least 1536x2048 [1242x2208 iphone only]). By default only iPhone splash screens are generated. 26 | If one supplies a second argument (`ipad` or `universal`), iPad splash screens or iPhone/iPad splash screens are generated respectively. 27 | 28 | ## Example 29 | 30 | The command 31 | 32 | ```bash 33 | ./s9splashgen.rb my_splash.png universal 34 | ``` 35 | 36 | will generate 37 | 38 | ```bash 39 | 320x480(2x) -> 640x960: screens/Default@2x~iphone.png 40 | 320x568(2x) -> 640x1136: screens/Default-568h@2x~iphone.png 41 | 375x667(2x) -> 750x1334: screens/Default-667h@2x~iphone.png 42 | 414x736(3x) -> 1242x2208: screens/Default-736h@3x~iphone.png 43 | 768x1024(1x) -> 768x1024: screens/Default-Portrait~ipad.png 44 | 1024x768(1x) -> 1024x768: screens/Default-Landscape~ipad.png 45 | 768x1024(2x) -> 1536x2048: screens/Default-Portrait@2x~ipad.png 46 | 1024x768(2x) -> 2048x1536: screens/Default-Landscape@2x~ipad.png 47 | ``` 48 | 49 | 50 | ## RubyMotion 51 | 52 | Add the splash screens to your resources folder. Since RubyMotion 2.34 there is no need to modify your rakefile, if you only want iPhone and iPad portrait launch images. For a universal app with additional iPad landscape launch images you have to add the following lines to your rakefile. 53 | 54 | ```ruby 55 | app.info_plist['UILaunchImages'] = [ 56 | # iphone 57 | { 58 | 'UILaunchImageName' => 'Default', 59 | 'UILaunchImageOrientation' => 'Portrait', 60 | 'UILaunchImageMinimumOSVersion' => '7.0', 61 | 'UILaunchImageSize' => '{320, 480}' 62 | }, 63 | { 64 | 'UILaunchImageName' => 'Default-568h', 65 | 'UILaunchImageOrientation' => 'Portrait', 66 | 'UILaunchImageMinimumOSVersion' => '7.0', 67 | 'UILaunchImageSize' => '{320, 568}' 68 | }, 69 | { 70 | 'UILaunchImageName' => 'Default-667h', 71 | 'UILaunchImageOrientation' => 'Portrait', 72 | 'UILaunchImageMinimumOSVersion' => '8.0', 73 | 'UILaunchImageSize' => '{375, 667}' 74 | }, 75 | { 76 | 'UILaunchImageName' => 'Default-736h', 77 | 'UILaunchImageOrientation' => 'Portrait', 78 | 'UILaunchImageMinimumOSVersion' => '8.0', 79 | 'UILaunchImageSize' => '{414, 736}' 80 | }, 81 | # ipad 82 | { 83 | 'UILaunchImageName' => 'Default-Portrait', 84 | 'UILaunchImageOrientation' => 'Portrait', 85 | 'UILaunchImageMinimumOSVersion' => '7.0', 86 | 'UILaunchImageSize' => '{768, 1024}' 87 | }, 88 | { 89 | 'UILaunchImageName' => 'Default-Landscape', 90 | 'UILaunchImageOrientation' => 'Landscape', 91 | 'UILaunchImageMinimumOSVersion' => '7.0', 92 | 'UILaunchImageSize' => '{768, 1024}' 93 | } 94 | ] 95 | ``` 96 | --------------------------------------------------------------------------------