Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
ios image asset creation
#!/usr/bin/env python
import sys
import subprocess
if len(sys.argv) < 3:
print(' InputImage BackgroundColor [OutputPrefix]')
input_image = sys.argv[1]
background_color = sys.argv[2]
if len(sys.argv) >= 4:
output_prefix = sys.argv[3]
output_prefix = ''
assets = [
('320x480', 'Default.png'),
('640x960', 'Default@2x.png'),
('640x1136', 'Default-568h@2x.png'),
('750x1334', 'Default-667h@2x.png'),
('1242x2208', 'Default-736h@3x.png'),
('768x1024', 'Default-Portrait.png'),
('1024x768', 'Default-Landscape.png'),
('1536x2048', 'Default-Portrait@2x.png'),
('2048x1536', 'Default-Landscape@2x.png'),
('2208x1242', 'Default-Landscape@3x.png'),
('384x512', 'LaunchScreen-Center.png'),
('768x1024', 'LaunchScreen-Center@2x.png')
backgrounds = [
('768x1024', 'LaunchScreen-AspectFill.png'),
('1536x2048', 'LaunchScreen-AspectFill@2x.png'),
for output in assets:
params = (input_image, output[0], background_color, output[0], output[1])
print('/usr/local/bin/convert %s -resize %s -background %s -gravity center -extent %s %s' % params)[
'%s' % output[0],
'%s' % background_color,
'%s' % output[0],
'%s%s' % (output_prefix, output[1])
for output in backgrounds:
params = (output[0], background_color, output_prefix, output[1])
print('/usr/local/bin/convert -size %s xc:%s %s%s' % params)[
'%s' % output[0],
'xc:%s' % background_color,
'%s%s' % (output_prefix, output[1])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment