mirror of
https://github.com/ulbwazhine/MockupEngineer.git
synced 2024-11-22 00:46:33 +03:00
2022.01.25.1
This commit is contained in:
parent
b9058b05ff
commit
3425ee78e2
|
@ -1,9 +1,9 @@
|
|||
import logging
|
||||
import os
|
||||
|
||||
from TemporaryStorage import TemporaryStorageInstance
|
||||
from importlib import import_module
|
||||
|
||||
from typing import List
|
||||
|
||||
from PIL import Image
|
||||
|
||||
from MockupEngineer import templates
|
||||
|
@ -18,6 +18,7 @@ class MockupEngineerInstance:
|
|||
def __init__(self):
|
||||
self.logger = logging.getLogger('MockupEngineer')
|
||||
self.templates: List[templates.Template] = []
|
||||
self.storage = TemporaryStorageInstance()
|
||||
|
||||
for template in templates.ALL_TEMPLATES:
|
||||
self.templates.append(getattr(
|
||||
|
@ -83,7 +84,7 @@ class MockupEngineerInstance:
|
|||
|
||||
def generate(self, template: templates.Template,
|
||||
screenshot_path: str, color: str = None,
|
||||
orientation: str = None) -> str:
|
||||
orientation: str = None, external_storage: bool = False) -> str:
|
||||
if not orientation:
|
||||
img = Image.open(screenshot_path)
|
||||
width, height = img.size
|
||||
|
@ -128,4 +129,13 @@ class MockupEngineerInstance:
|
|||
|
||||
os.remove(resized_screenshot_path)
|
||||
|
||||
return mockup_path
|
||||
if not external_storage:
|
||||
return mockup_path
|
||||
else:
|
||||
uploaded = self.storage.upload(mockup_path)
|
||||
|
||||
if uploaded and uploaded.url:
|
||||
os.remove(mockup_path)
|
||||
return uploaded.url
|
||||
else:
|
||||
return mockup_path
|
||||
|
|
|
@ -20,7 +20,7 @@ def main():
|
|||
print('- - - - - - - - - -')
|
||||
screenshot = input('Enter path to screenshot: ')
|
||||
print('- - - - - - - - - -\nWorking...')
|
||||
mockup = mockup.generate(template, screenshot, color)
|
||||
mockup = mockup.generate(template, screenshot, color, external_storage=True)
|
||||
print('- - - - - - - - - -\nSuccess: {}'.format(mockup))
|
||||
os.system('open {}'.format(mockup))
|
||||
|
||||
|
|
17
readme.md
17
readme.md
|
@ -13,8 +13,8 @@
|
|||
* [Example](https://github.com/ulbwazhine/MockupEngineer#example)
|
||||
* [Install](https://github.com/ulbwazhine/MockupEngineer#install)
|
||||
* [Usage](https://github.com/ulbwazhine/MockupEngineer#usage)
|
||||
* [In Python console](https://github.com/ulbwazhine/MockupEngineer#in-python-console)
|
||||
* [As a standalone application](https://github.com/ulbwazhine/MockupEngineer#as-a-standalone-application)
|
||||
* [In Python console](https://github.com/ulbwazhine/MockupEngineer#in-python-console)
|
||||
* [List of supported mockups](https://github.com/ulbwazhine/MockupEngineer#list-of-supported-mockups)
|
||||
* [Phones](https://github.com/ulbwazhine/MockupEngineer#phones)
|
||||
* [Tablets](https://github.com/ulbwazhine/MockupEngineer#tablets)
|
||||
|
@ -36,6 +36,11 @@ $ python3 -m pip install MockupEngineer
|
|||
|
||||
## Usage
|
||||
|
||||
#### As a standalone application:
|
||||
```console
|
||||
$ python3 -m MockupEngineer
|
||||
```
|
||||
|
||||
#### In Python console:
|
||||
|
||||
```python
|
||||
|
@ -52,10 +57,12 @@ mockup.generate(template=mockup.templates[0],
|
|||
>>> /path/to/mockup
|
||||
```
|
||||
|
||||
#### As a standalone application:
|
||||
```console
|
||||
$ python3 -m MockupEngineer
|
||||
```
|
||||
##### `MockupEngineerInstance.generate` parameters:
|
||||
* `template`: *Template* — Device template model, must be passed from *MockupEngineerInstance.templates* or *MockupEngineerInstance.get_templates()*.
|
||||
* `screenshot_path`: *str* — Absolute path to the image in **JPG, PNG format**.
|
||||
* `color`: *Optional[str]* — Optional parameter, force device color. Must be passed according to *Template.colors[**n**].color*
|
||||
* `orientation`: *str* — Optional parameter, force device orientation. Must be *landscape* or *portrait*.
|
||||
* `external_storage`: *Optional[bool]* — Optional parameter, true if you need to upload mockup on [TemporaryStorage](https://github.com/ulbwazhine/TemporaryStorage) (0x0.st etc)
|
||||
|
||||
## List of supported mockups
|
||||
|
||||
|
|
|
@ -1,2 +1,4 @@
|
|||
Pillow>=8.4.0
|
||||
setuptools>=59.2.0
|
||||
setuptools>=59.2.0
|
||||
MockupEngineer>=2022.1.23.18
|
||||
TemporaryStorage>=2022.1.25.3
|
4
setup.py
4
setup.py
|
@ -3,13 +3,13 @@ from setuptools import setup, find_packages
|
|||
|
||||
setup(
|
||||
name='MockupEngineer',
|
||||
version='2022.01.23.19',
|
||||
version='2022.01.25.1',
|
||||
packages=find_packages(),
|
||||
url='https://github.com/ulbwazhine/MockupEngineer',
|
||||
license='MIT',
|
||||
author='Ulbwazhine',
|
||||
author_email='ulbwa@icloud.com',
|
||||
description='An simple library for creating beautiful screenshots.',
|
||||
description='A simple library for creating beautiful screenshots.',
|
||||
install_requires=[line.strip() for line in open("requirements.txt").readlines()],
|
||||
long_description=open('readme.md', 'r').read(),
|
||||
long_description_content_type='text/markdown',
|
||||
|
|
Loading…
Reference in New Issue
Block a user