This commit is contained in:
Alexander Popov 2021-02-25 20:44:15 +03:00
parent 872da73ea7
commit cce83d9668
Signed by: iiiypuk
GPG Key ID: 398FC73478D97286
6 changed files with 30 additions and 22 deletions

3
.gitignore vendored
View File

@ -1,6 +1,3 @@
venv/
images/
logo.png
dist/
assm/__pycache__

View File

@ -1,3 +1,3 @@
"""iOS splash screen generator"""
__version__ = "0.1.11"
__version__ = "0.1.1"

View File

@ -1,11 +1,11 @@
#!/usr/bin/env python3
"""iOS splash screen generator"""
import os
import json
from PIL import Image
from assm.devices import APPLE_DEVICES
def makeSplashImage(screen_orientation, screen_width, screen_height, logo_path='logo.png'):
def make_splash_image(screen_orientation, screen_width, screen_height, logo_path):
""" Generate splash image """
# swap screen sizes
@ -21,9 +21,12 @@ def makeSplashImage(screen_orientation, screen_width, screen_height, logo_path='
app_logo = logo_image.resize((logo_size, logo_size))
splash_image.paste(app_logo, (logo_w_pos, logo_h_pos), app_logo)
return(splash_image)
return splash_image
def main(output_folder='./images/'):
"""Sample main function"""
# check folder exists
if not os.path.exists(output_folder):
os.mkdir(output_folder)
@ -32,31 +35,34 @@ def main(output_folder='./images/'):
print('Generate portrait splash...')
for device in APPLE_DEVICES:
w = APPLE_DEVICES[device][0]
h = APPLE_DEVICES[device][1]
device_w = APPLE_DEVICES[device][0]
device_h = APPLE_DEVICES[device][1]
file_name = '{folder}/splash-portrait-{height}x{width}.png'.format(
folder=output_folder, width=w, height=h)
splash = makeSplashImage('portrait', w, h, 'logo.png')
file_name = '{f}/splash-portrait-{h}x{w}.png'.format(
f=output_folder, w=device_w, h=device_h
)
splash = make_splash_image('portrait', device_w, device_h, 'logo.png')
splash.save(file_name)
print('..splash for {w}x{h} saved...'.format(w=w, h=h))
print('..splash for {w}x{h} saved...'.format(w=device_w, h=device_h))
# landscape
print('Generate landscape splash...')
for device in APPLE_DEVICES:
w = APPLE_DEVICES[device][0]
h = APPLE_DEVICES[device][1]
device_w = APPLE_DEVICES[device][0]
device_h = APPLE_DEVICES[device][1]
file_name = '{folder}/splash-landscape-{height}x{width}.png'.format(
folder=output_folder, width=w, height=h)
file_name = '{f}/splash-landscape-{h}x{w}.png'.format(
f=output_folder, w=device_w, h=device_h
)
splash = makeSplashImage('landscape', w, h, 'logo.png')
splash = make_splash_image('landscape', device_w, device_h, 'logo.png')
splash.save(file_name)
print('...splash for {h}x{w} saved...'.format(w=w, h=h))
print('...splash for {h}x{w} saved...'.format(w=device_w, h=device_h))
if __name__ == '__main__':
main()

View File

@ -1,3 +1,5 @@
"""Default iOS screen sizes"""
APPLE_DEVICES = {
'iPhone SE': [640, 1136],
'iPhone 6/7/8': [750, 1334],
@ -8,5 +10,5 @@ APPLE_DEVICES = {
'9.7" iPad': [1536, 2048],
'10.5" iPad Pro': [1668, 2224],
'11" iPad Pro': [1668, 2388],
'12.9" iPad Pro': [2048, 2732]
'12.9" iPad Pro': [2048, 2732],
}

3
dev_requirements.txt Normal file
View File

@ -0,0 +1,3 @@
black==20.8b1
flit==3.0.0
pylint==2.7.1

Binary file not shown.

Before

Width:  |  Height:  |  Size: 69 KiB