2022.02.02.3

This commit is contained in:
ульба 2022-02-02 19:52:19 +05:00
parent b8b4b713c1
commit 1db3710f47
33 changed files with 35 additions and 48 deletions

View File

@ -26,46 +26,6 @@ class MockupEngineerInstance:
except Exception as 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]:
for template in self.templates:
if template.id == template_id:

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 MiB

After

Width:  |  Height:  |  Size: 223 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 MiB

After

Width:  |  Height:  |  Size: 225 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 MiB

After

Width:  |  Height:  |  Size: 357 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 MiB

After

Width:  |  Height:  |  Size: 321 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 MiB

After

Width:  |  Height:  |  Size: 372 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 MiB

After

Width:  |  Height:  |  Size: 296 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 MiB

After

Width:  |  Height:  |  Size: 365 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 MiB

After

Width:  |  Height:  |  Size: 372 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 MiB

After

Width:  |  Height:  |  Size: 245 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 MiB

After

Width:  |  Height:  |  Size: 274 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 MiB

After

Width:  |  Height:  |  Size: 264 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 MiB

After

Width:  |  Height:  |  Size: 248 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 MiB

After

Width:  |  Height:  |  Size: 263 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 MiB

After

Width:  |  Height:  |  Size: 316 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 MiB

After

Width:  |  Height:  |  Size: 287 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 MiB

After

Width:  |  Height:  |  Size: 282 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 MiB

After

Width:  |  Height:  |  Size: 251 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 MiB

After

Width:  |  Height:  |  Size: 245 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 MiB

After

Width:  |  Height:  |  Size: 250 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 MiB

After

Width:  |  Height:  |  Size: 236 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 MiB

After

Width:  |  Height:  |  Size: 282 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 MiB

After

Width:  |  Height:  |  Size: 254 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 MiB

After

Width:  |  Height:  |  Size: 239 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 MiB

After

Width:  |  Height:  |  Size: 221 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 MiB

After

Width:  |  Height:  |  Size: 250 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 MiB

After

Width:  |  Height:  |  Size: 272 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 MiB

After

Width:  |  Height:  |  Size: 321 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 337 KiB

After

Width:  |  Height:  |  Size: 334 KiB

View File

@ -3,6 +3,7 @@ import os
import shutil
from FluentGenerator import FluentImage
from PIL import Image
from jinja2 import Template
from MockupEngineer import MockupEngineerInstance, generated_path
@ -11,14 +12,32 @@ from MockupEngineer import MockupEngineerInstance, generated_path
def create_examples():
mockup = MockupEngineerInstance()
for template in mockup.templates:
screenshot = FluentImage(
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)
max_height = 1000
max_width = 1000
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():

View File

@ -10,6 +10,7 @@
</div>
## Navigation
* [Example](https://github.com/ulbwazhine/MockupEngineer#example)
* [Install](https://github.com/ulbwazhine/MockupEngineer#install)
* [Update](https://github.com/ulbwazhine/MockupEngineer#update)
@ -31,6 +32,9 @@
<p>Apple iPhone 12 Pro Max Mockup</p>
</div>
### Notice
The quality of all examples is much worse than real mockups, this is due to the project size limit on PyPI.
## Install
```console
$ python3 -m pip install MockupEngineer

View File

@ -10,6 +10,7 @@
</div>
## Navigation
* [Example](https://github.com/ulbwazhine/MockupEngineer#example)
* [Install](https://github.com/ulbwazhine/MockupEngineer#install)
* [Update](https://github.com/ulbwazhine/MockupEngineer#update)
@ -31,6 +32,9 @@
<p>Apple iPhone 12 Pro Max Mockup</p>
</div>
### Notice
The quality of all examples is much worse than real mockups, this is due to the project size limit on PyPI.
## Install
```console
$ python3 -m pip install MockupEngineer

View File

@ -3,7 +3,7 @@ from setuptools import setup, find_packages
setup(
name='MockupEngineer',
version='2022.02.02.1',
version='2022.02.02.3',
packages=find_packages(),
url='https://github.com/ulbwazhine/MockupEngineer',
license='MIT',