2022.02.02.3
|
@ -26,46 +26,6 @@ class MockupEngineerInstance:
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.logger.warning('Failed to load "{}" module: {}'.format(template, e))
|
self.logger.warning('Failed to load "{}" module: {}'.format(template, e))
|
||||||
|
|
||||||
def __create_mockups_list__(self) -> str:
|
|
||||||
output = list()
|
|
||||||
available_templates = self.get_templates()
|
|
||||||
specified_keys = {"pc": 'Computers',
|
|
||||||
'wear': 'Wearable devices'}
|
|
||||||
|
|
||||||
for key, item in available_templates.items():
|
|
||||||
output.append(
|
|
||||||
'### {}'.format('{}s'.format(key.title()) if key not in specified_keys.keys() else specified_keys[key]))
|
|
||||||
|
|
||||||
for template in item:
|
|
||||||
output.append(
|
|
||||||
'* [{manufacturer} {name}](https://raw.githubusercontent.com/'
|
|
||||||
'ulbwazhine/MockupEngineer/main/MockupEngineer/'
|
|
||||||
'templates/{path}/example.png) [{resolution}] ({year})'.format(
|
|
||||||
manufacturer=template.manufacturer, name=template.name,
|
|
||||||
path=os.path.basename(os.path.dirname(template.preview)),
|
|
||||||
resolution=template.resolution, year=template.year))
|
|
||||||
|
|
||||||
for color in sorted(template.colors, key=lambda a: a.color):
|
|
||||||
output.append(' * {}'.format(color.color))
|
|
||||||
|
|
||||||
output.append('')
|
|
||||||
|
|
||||||
return '\n'.join(output)
|
|
||||||
|
|
||||||
def __create_examples__(self, example_path: str) -> None:
|
|
||||||
for template in self.templates:
|
|
||||||
if os.path.isfile(template.preview):
|
|
||||||
os.remove(template.preview)
|
|
||||||
|
|
||||||
mockup_path = self.generate(template.id, example_path)
|
|
||||||
mockup_img = Image.open(mockup_path)
|
|
||||||
background_img = Image.new('RGBA', mockup_img.size, (255, 255, 255, 255))
|
|
||||||
background_img.paste(mockup_img, (0, 0), mockup_img)
|
|
||||||
|
|
||||||
background_img.save(template.preview)
|
|
||||||
|
|
||||||
os.remove(mockup_path)
|
|
||||||
|
|
||||||
def get_template(self, template_id: str) -> Optional[Device]:
|
def get_template(self, template_id: str) -> Optional[Device]:
|
||||||
for template in self.templates:
|
for template in self.templates:
|
||||||
if template.id == template_id:
|
if template.id == template_id:
|
||||||
|
|
Before Width: | Height: | Size: 4.1 MiB After Width: | Height: | Size: 223 KiB |
Before Width: | Height: | Size: 4.1 MiB After Width: | Height: | Size: 225 KiB |
Before Width: | Height: | Size: 1.6 MiB After Width: | Height: | Size: 357 KiB |
Before Width: | Height: | Size: 2.7 MiB After Width: | Height: | Size: 321 KiB |
Before Width: | Height: | Size: 3.0 MiB After Width: | Height: | Size: 372 KiB |
Before Width: | Height: | Size: 2.6 MiB After Width: | Height: | Size: 296 KiB |
Before Width: | Height: | Size: 3.4 MiB After Width: | Height: | Size: 365 KiB |
Before Width: | Height: | Size: 4.6 MiB After Width: | Height: | Size: 372 KiB |
Before Width: | Height: | Size: 2.6 MiB After Width: | Height: | Size: 245 KiB |
Before Width: | Height: | Size: 2.2 MiB After Width: | Height: | Size: 274 KiB |
Before Width: | Height: | Size: 2.7 MiB After Width: | Height: | Size: 264 KiB |
Before Width: | Height: | Size: 3.2 MiB After Width: | Height: | Size: 248 KiB |
Before Width: | Height: | Size: 1.0 MiB After Width: | Height: | Size: 263 KiB |
Before Width: | Height: | Size: 1.5 MiB After Width: | Height: | Size: 316 KiB |
Before Width: | Height: | Size: 2.6 MiB After Width: | Height: | Size: 287 KiB |
Before Width: | Height: | Size: 2.8 MiB After Width: | Height: | Size: 282 KiB |
Before Width: | Height: | Size: 1.2 MiB After Width: | Height: | Size: 251 KiB |
Before Width: | Height: | Size: 1.4 MiB After Width: | Height: | Size: 245 KiB |
Before Width: | Height: | Size: 1.4 MiB After Width: | Height: | Size: 250 KiB |
Before Width: | Height: | Size: 1.8 MiB After Width: | Height: | Size: 236 KiB |
Before Width: | Height: | Size: 3.1 MiB After Width: | Height: | Size: 282 KiB |
Before Width: | Height: | Size: 1.6 MiB After Width: | Height: | Size: 254 KiB |
Before Width: | Height: | Size: 2.1 MiB After Width: | Height: | Size: 239 KiB |
Before Width: | Height: | Size: 3.5 MiB After Width: | Height: | Size: 221 KiB |
Before Width: | Height: | Size: 2.5 MiB After Width: | Height: | Size: 250 KiB |
Before Width: | Height: | Size: 1.6 MiB After Width: | Height: | Size: 272 KiB |
Before Width: | Height: | Size: 3.2 MiB After Width: | Height: | Size: 321 KiB |
Before Width: | Height: | Size: 337 KiB After Width: | Height: | Size: 334 KiB |
33
deploy.py
|
@ -3,6 +3,7 @@ import os
|
||||||
import shutil
|
import shutil
|
||||||
|
|
||||||
from FluentGenerator import FluentImage
|
from FluentGenerator import FluentImage
|
||||||
|
from PIL import Image
|
||||||
from jinja2 import Template
|
from jinja2 import Template
|
||||||
|
|
||||||
from MockupEngineer import MockupEngineerInstance, generated_path
|
from MockupEngineer import MockupEngineerInstance, generated_path
|
||||||
|
@ -11,14 +12,32 @@ from MockupEngineer import MockupEngineerInstance, generated_path
|
||||||
def create_examples():
|
def create_examples():
|
||||||
mockup = MockupEngineerInstance()
|
mockup = MockupEngineerInstance()
|
||||||
|
|
||||||
for template in mockup.templates:
|
max_height = 1000
|
||||||
screenshot = FluentImage(
|
max_width = 1000
|
||||||
colors=10, width=template.image.width, height=template.image.height, background='white').generate()
|
|
||||||
mockuped = mockup.generate(template_id=template.id, screenshot_path=screenshot)
|
|
||||||
os.remove(screenshot)
|
|
||||||
shutil.move(mockuped, template.preview)
|
|
||||||
|
|
||||||
os.removedirs(generated_path)
|
for template in mockup.templates:
|
||||||
|
screenshot_path = FluentImage(
|
||||||
|
colors=10, width=template.image.width, height=template.image.height, background='white').generate()
|
||||||
|
mockup_path = mockup.generate(template_id=template.id, screenshot_path=screenshot_path)
|
||||||
|
os.remove(screenshot_path)
|
||||||
|
shutil.move(mockup_path, template.preview)
|
||||||
|
|
||||||
|
mockup_img = Image.open(template.preview)
|
||||||
|
background_img = Image.new('RGBA', mockup_img.size, (255, 255, 255, 255))
|
||||||
|
background_img.paste(mockup_img, (0, 0), mockup_img)
|
||||||
|
|
||||||
|
if background_img.size[0] > max_width or background_img.size[1] > max_height:
|
||||||
|
if background_img.size[0] > background_img.size[1]:
|
||||||
|
width = max_width
|
||||||
|
height = int(background_img.size[1] * (max_width / background_img.size[0]))
|
||||||
|
else:
|
||||||
|
width = int(background_img.size[0] * (max_height / background_img.size[1]))
|
||||||
|
height = max_height
|
||||||
|
|
||||||
|
background_img = background_img.resize((width, height), Image.ANTIALIAS)
|
||||||
|
background_img.save(template.preview)
|
||||||
|
|
||||||
|
shutil.rmtree(generated_path)
|
||||||
|
|
||||||
|
|
||||||
def create_readme():
|
def create_readme():
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
## Navigation
|
## Navigation
|
||||||
|
|
||||||
* [Example](https://github.com/ulbwazhine/MockupEngineer#example)
|
* [Example](https://github.com/ulbwazhine/MockupEngineer#example)
|
||||||
* [Install](https://github.com/ulbwazhine/MockupEngineer#install)
|
* [Install](https://github.com/ulbwazhine/MockupEngineer#install)
|
||||||
* [Update](https://github.com/ulbwazhine/MockupEngineer#update)
|
* [Update](https://github.com/ulbwazhine/MockupEngineer#update)
|
||||||
|
@ -31,6 +32,9 @@
|
||||||
<p>Apple iPhone 12 Pro Max Mockup</p>
|
<p>Apple iPhone 12 Pro Max Mockup</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
### Notice
|
||||||
|
The quality of all examples is much worse than real mockups, this is due to the project size limit on PyPI.
|
||||||
|
|
||||||
## Install
|
## Install
|
||||||
```console
|
```console
|
||||||
$ python3 -m pip install MockupEngineer
|
$ python3 -m pip install MockupEngineer
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
## Navigation
|
## Navigation
|
||||||
|
|
||||||
* [Example](https://github.com/ulbwazhine/MockupEngineer#example)
|
* [Example](https://github.com/ulbwazhine/MockupEngineer#example)
|
||||||
* [Install](https://github.com/ulbwazhine/MockupEngineer#install)
|
* [Install](https://github.com/ulbwazhine/MockupEngineer#install)
|
||||||
* [Update](https://github.com/ulbwazhine/MockupEngineer#update)
|
* [Update](https://github.com/ulbwazhine/MockupEngineer#update)
|
||||||
|
@ -31,6 +32,9 @@
|
||||||
<p>Apple iPhone 12 Pro Max Mockup</p>
|
<p>Apple iPhone 12 Pro Max Mockup</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
### Notice
|
||||||
|
The quality of all examples is much worse than real mockups, this is due to the project size limit on PyPI.
|
||||||
|
|
||||||
## Install
|
## Install
|
||||||
```console
|
```console
|
||||||
$ python3 -m pip install MockupEngineer
|
$ python3 -m pip install MockupEngineer
|
||||||
|
|
2
setup.py
|
@ -3,7 +3,7 @@ from setuptools import setup, find_packages
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name='MockupEngineer',
|
name='MockupEngineer',
|
||||||
version='2022.02.02.1',
|
version='2022.02.02.3',
|
||||||
packages=find_packages(),
|
packages=find_packages(),
|
||||||
url='https://github.com/ulbwazhine/MockupEngineer',
|
url='https://github.com/ulbwazhine/MockupEngineer',
|
||||||
license='MIT',
|
license='MIT',
|
||||||
|
|