0.1.1
This commit is contained in:
parent
555a0819e1
commit
872da73ea7
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,3 +1,6 @@
|
|||||||
venv/
|
venv/
|
||||||
images/
|
images/
|
||||||
logo.png
|
logo.png
|
||||||
|
|
||||||
|
dist/
|
||||||
|
assm/__pycache__
|
||||||
|
43
assm.py
43
assm.py
@ -1,43 +0,0 @@
|
|||||||
import json
|
|
||||||
from PIL import Image
|
|
||||||
|
|
||||||
def getDevicesList():
|
|
||||||
with open('./devicesArrays.json', encoding='utf-8') as f:
|
|
||||||
raw = f.read()
|
|
||||||
|
|
||||||
return(json.loads(raw))
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
devicesList = getDevicesList()
|
|
||||||
|
|
||||||
# portrait
|
|
||||||
for device in devicesList:
|
|
||||||
device_w = devicesList[device][0]
|
|
||||||
device_h = devicesList[device][1]
|
|
||||||
device_r = round(device_w / 5)
|
|
||||||
|
|
||||||
image_w_center = round((device_w / 2) - (device_r / 2))
|
|
||||||
image_h_center = round((device_h / 2) - (device_r / 2))
|
|
||||||
|
|
||||||
base_image = Image.new('RGB', (device_w, device_h), (255, 255, 255))
|
|
||||||
logo_image = Image.open('./logo.png')
|
|
||||||
a = logo_image.resize((device_r, device_r))
|
|
||||||
base_image.paste(a, (image_w_center, image_h_center), a)
|
|
||||||
base_image.save('./images/splash-portrait-{width}x{height}.png'.format(
|
|
||||||
width=device_w, height=device_h))
|
|
||||||
|
|
||||||
# landscape
|
|
||||||
for device in devicesList:
|
|
||||||
device_w = devicesList[device][0]
|
|
||||||
device_h = devicesList[device][1]
|
|
||||||
device_r = round(device_w / 5)
|
|
||||||
|
|
||||||
image_w_center = round((device_w / 2) - (device_r / 2))
|
|
||||||
image_h_center = round((device_h / 2) - (device_r / 2))
|
|
||||||
|
|
||||||
base_image = Image.new('RGB', (device_h, device_w), (255, 255, 255))
|
|
||||||
logo_image = Image.open('./logo.png')
|
|
||||||
a = logo_image.resize((device_r, device_r))
|
|
||||||
base_image.paste(a, (image_h_center, image_w_center), a)
|
|
||||||
base_image.save('./images/splash-landscape-{height}x{width}.png'.format(
|
|
||||||
width=device_w, height=device_h))
|
|
3
assm/__init__.py
Normal file
3
assm/__init__.py
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
"""iOS splash screen generator"""
|
||||||
|
|
||||||
|
__version__ = "0.1.11"
|
62
assm/__main__.py
Normal file
62
assm/__main__.py
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
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'):
|
||||||
|
""" Generate splash image """
|
||||||
|
|
||||||
|
# swap screen sizes
|
||||||
|
if screen_orientation == 'landscape':
|
||||||
|
screen_width, screen_height = screen_height, screen_width
|
||||||
|
|
||||||
|
logo_size = round(screen_width / 5)
|
||||||
|
logo_w_pos = round((screen_width / 2) - (logo_size / 2))
|
||||||
|
logo_h_pos = round((screen_height / 2) - (logo_size / 2))
|
||||||
|
|
||||||
|
splash_image = Image.new('RGB', (screen_width, screen_height), (255, 255, 255))
|
||||||
|
logo_image = Image.open(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)
|
||||||
|
|
||||||
|
def main(output_folder='./images/'):
|
||||||
|
# check folder exists
|
||||||
|
if not os.path.exists(output_folder):
|
||||||
|
os.mkdir(output_folder)
|
||||||
|
|
||||||
|
# portrait
|
||||||
|
print('Generate portrait splash...')
|
||||||
|
|
||||||
|
for device in APPLE_DEVICES:
|
||||||
|
w = APPLE_DEVICES[device][0]
|
||||||
|
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')
|
||||||
|
splash.save(file_name)
|
||||||
|
|
||||||
|
print('..splash for {w}x{h} saved...'.format(w=w, h=h))
|
||||||
|
|
||||||
|
# landscape
|
||||||
|
print('Generate landscape splash...')
|
||||||
|
|
||||||
|
for device in APPLE_DEVICES:
|
||||||
|
w = APPLE_DEVICES[device][0]
|
||||||
|
h = APPLE_DEVICES[device][1]
|
||||||
|
|
||||||
|
file_name = '{folder}/splash-landscape-{height}x{width}.png'.format(
|
||||||
|
folder=output_folder, width=w, height=h)
|
||||||
|
|
||||||
|
splash = makeSplashImage('landscape', w, h, 'logo.png')
|
||||||
|
splash.save(file_name)
|
||||||
|
|
||||||
|
print('...splash for {h}x{w} saved...'.format(w=w, h=h))
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
12
assm/devices.py
Normal file
12
assm/devices.py
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
APPLE_DEVICES = {
|
||||||
|
'iPhone SE': [640, 1136],
|
||||||
|
'iPhone 6/7/8': [750, 1334],
|
||||||
|
'iPhone XR': [828, 1792],
|
||||||
|
'iPhone X': [1125, 2436],
|
||||||
|
'iPhone 8 Plus': [1242, 2208],
|
||||||
|
'iPhone XS Max': [1242, 2688],
|
||||||
|
'9.7" iPad': [1536, 2048],
|
||||||
|
'10.5" iPad Pro': [1668, 2224],
|
||||||
|
'11" iPad Pro': [1668, 2388],
|
||||||
|
'12.9" iPad Pro': [2048, 2732]
|
||||||
|
}
|
@ -1,12 +0,0 @@
|
|||||||
{
|
|
||||||
"iPhone SE": [640, 1136],
|
|
||||||
"iPhone 6/7/8": [750, 1334],
|
|
||||||
"iPhone XR": [828, 1792],
|
|
||||||
"iPhone X": [1125, 2436],
|
|
||||||
"iPhone 8 Plus": [1242, 2208],
|
|
||||||
"iPhone XS Max": [1242, 2688],
|
|
||||||
"9.7\" iPad": [1536, 2048],
|
|
||||||
"10.5\" iPad Pro": [1668, 2224],
|
|
||||||
"11\" iPad Pro": [1668, 2388],
|
|
||||||
"12.9\" iPad Pro": [2048, 2732]
|
|
||||||
}
|
|
16
pyproject.toml
Normal file
16
pyproject.toml
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
[build-system]
|
||||||
|
requires = ["flit_core >=2,<4"]
|
||||||
|
build-backend = "flit_core.buildapi"
|
||||||
|
|
||||||
|
[tool.flit.metadata]
|
||||||
|
module = "assm"
|
||||||
|
author = "Alexander Popov"
|
||||||
|
author-email = "iiiypuk@iiiypuk.me"
|
||||||
|
home-page = "https://github.com/emilecok/assm"
|
||||||
|
requires-python = ">=3"
|
||||||
|
requires = ["Pillow==8.1.0" ]
|
||||||
|
classifiers = [
|
||||||
|
"License :: OSI Approved :: MIT License",
|
||||||
|
"Programming Language :: Python :: 3"
|
||||||
|
]
|
||||||
|
description-file = "README.md"
|
Loading…
Reference in New Issue
Block a user