diff --git a/MockupEngineer/__init__.py b/MockupEngineer/__init__.py index b310166..cb109b1 100644 --- a/MockupEngineer/__init__.py +++ b/MockupEngineer/__init__.py @@ -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: diff --git a/MockupEngineer/templates/galaxys20/preview.png b/MockupEngineer/templates/galaxys20/preview.png index 66cd5d7..af5176f 100644 Binary files a/MockupEngineer/templates/galaxys20/preview.png and b/MockupEngineer/templates/galaxys20/preview.png differ diff --git a/MockupEngineer/templates/galaxys20ultra/preview.png b/MockupEngineer/templates/galaxys20ultra/preview.png index bdfbf9f..bfd17d6 100644 Binary files a/MockupEngineer/templates/galaxys20ultra/preview.png and b/MockupEngineer/templates/galaxys20ultra/preview.png differ diff --git a/MockupEngineer/templates/imac212015/preview.png b/MockupEngineer/templates/imac212015/preview.png index c115e26..28e48eb 100644 Binary files a/MockupEngineer/templates/imac212015/preview.png and b/MockupEngineer/templates/imac212015/preview.png differ diff --git a/MockupEngineer/templates/ipad9/preview.png b/MockupEngineer/templates/ipad9/preview.png index 9895414..045670f 100644 Binary files a/MockupEngineer/templates/ipad9/preview.png and b/MockupEngineer/templates/ipad9/preview.png differ diff --git a/MockupEngineer/templates/ipadair4/preview.png b/MockupEngineer/templates/ipadair4/preview.png index e2af124..a751b6d 100644 Binary files a/MockupEngineer/templates/ipadair4/preview.png and b/MockupEngineer/templates/ipadair4/preview.png differ diff --git a/MockupEngineer/templates/ipadmini5/preview.png b/MockupEngineer/templates/ipadmini5/preview.png index e42f4ea..b7596ec 100644 Binary files a/MockupEngineer/templates/ipadmini5/preview.png and b/MockupEngineer/templates/ipadmini5/preview.png differ diff --git a/MockupEngineer/templates/ipadpro114/preview.png b/MockupEngineer/templates/ipadpro114/preview.png index f71412a..e03062e 100644 Binary files a/MockupEngineer/templates/ipadpro114/preview.png and b/MockupEngineer/templates/ipadpro114/preview.png differ diff --git a/MockupEngineer/templates/ipadpro134/preview.png b/MockupEngineer/templates/ipadpro134/preview.png index 586fb83..3d2c497 100644 Binary files a/MockupEngineer/templates/ipadpro134/preview.png and b/MockupEngineer/templates/ipadpro134/preview.png differ diff --git a/MockupEngineer/templates/iphone12/preview.png b/MockupEngineer/templates/iphone12/preview.png index e722cb5..944b7dc 100644 Binary files a/MockupEngineer/templates/iphone12/preview.png and b/MockupEngineer/templates/iphone12/preview.png differ diff --git a/MockupEngineer/templates/iphone12mini/preview.png b/MockupEngineer/templates/iphone12mini/preview.png index 22d198f..31c785a 100644 Binary files a/MockupEngineer/templates/iphone12mini/preview.png and b/MockupEngineer/templates/iphone12mini/preview.png differ diff --git a/MockupEngineer/templates/iphone12pro/preview.png b/MockupEngineer/templates/iphone12pro/preview.png index de92686..8925a8c 100644 Binary files a/MockupEngineer/templates/iphone12pro/preview.png and b/MockupEngineer/templates/iphone12pro/preview.png differ diff --git a/MockupEngineer/templates/iphone12promax/preview.png b/MockupEngineer/templates/iphone12promax/preview.png index dcdabc5..adc8374 100644 Binary files a/MockupEngineer/templates/iphone12promax/preview.png and b/MockupEngineer/templates/iphone12promax/preview.png differ diff --git a/MockupEngineer/templates/iphonese2020/preview.png b/MockupEngineer/templates/iphonese2020/preview.png index 944db46..a9d35f0 100644 Binary files a/MockupEngineer/templates/iphonese2020/preview.png and b/MockupEngineer/templates/iphonese2020/preview.png differ diff --git a/MockupEngineer/templates/iphonexr/preview.png b/MockupEngineer/templates/iphonexr/preview.png index 9fe3588..79a6201 100644 Binary files a/MockupEngineer/templates/iphonexr/preview.png and b/MockupEngineer/templates/iphonexr/preview.png differ diff --git a/MockupEngineer/templates/iphonexs/preview.png b/MockupEngineer/templates/iphonexs/preview.png index 7a3b4f1..ef5f40d 100644 Binary files a/MockupEngineer/templates/iphonexs/preview.png and b/MockupEngineer/templates/iphonexs/preview.png differ diff --git a/MockupEngineer/templates/iphonexsmax/preview.png b/MockupEngineer/templates/iphonexsmax/preview.png index b4ac9b7..14a1569 100644 Binary files a/MockupEngineer/templates/iphonexsmax/preview.png and b/MockupEngineer/templates/iphonexsmax/preview.png differ diff --git a/MockupEngineer/templates/macbook122016/preview.png b/MockupEngineer/templates/macbook122016/preview.png index 786b926..98eb811 100644 Binary files a/MockupEngineer/templates/macbook122016/preview.png and b/MockupEngineer/templates/macbook122016/preview.png differ diff --git a/MockupEngineer/templates/macbookpro132015/preview.png b/MockupEngineer/templates/macbookpro132015/preview.png index 7e544b3..cbad5e1 100644 Binary files a/MockupEngineer/templates/macbookpro132015/preview.png and b/MockupEngineer/templates/macbookpro132015/preview.png differ diff --git a/MockupEngineer/templates/macbookpro152015/preview.png b/MockupEngineer/templates/macbookpro152015/preview.png index 54ea840..a0a9c23 100644 Binary files a/MockupEngineer/templates/macbookpro152015/preview.png and b/MockupEngineer/templates/macbookpro152015/preview.png differ diff --git a/MockupEngineer/templates/macbookpro162019/preview.png b/MockupEngineer/templates/macbookpro162019/preview.png index 3e0658c..0c43b28 100644 Binary files a/MockupEngineer/templates/macbookpro162019/preview.png and b/MockupEngineer/templates/macbookpro162019/preview.png differ diff --git a/MockupEngineer/templates/macbookpro162021/preview.png b/MockupEngineer/templates/macbookpro162021/preview.png index db541b1..33b2924 100644 Binary files a/MockupEngineer/templates/macbookpro162021/preview.png and b/MockupEngineer/templates/macbookpro162021/preview.png differ diff --git a/MockupEngineer/templates/pixel/preview.png b/MockupEngineer/templates/pixel/preview.png index 3ca3e6a..f188bae 100644 Binary files a/MockupEngineer/templates/pixel/preview.png and b/MockupEngineer/templates/pixel/preview.png differ diff --git a/MockupEngineer/templates/pixel4/preview.png b/MockupEngineer/templates/pixel4/preview.png index 2dd3348..3b548df 100644 Binary files a/MockupEngineer/templates/pixel4/preview.png and b/MockupEngineer/templates/pixel4/preview.png differ diff --git a/MockupEngineer/templates/pixel4xl/preview.png b/MockupEngineer/templates/pixel4xl/preview.png index d2cf9fb..a0d3b85 100644 Binary files a/MockupEngineer/templates/pixel4xl/preview.png and b/MockupEngineer/templates/pixel4xl/preview.png differ diff --git a/MockupEngineer/templates/pixel5/preview.png b/MockupEngineer/templates/pixel5/preview.png index 514c12e..2b87b85 100644 Binary files a/MockupEngineer/templates/pixel5/preview.png and b/MockupEngineer/templates/pixel5/preview.png differ diff --git a/MockupEngineer/templates/pixelbookgo/preview.png b/MockupEngineer/templates/pixelbookgo/preview.png index b7c5758..41f7cc8 100644 Binary files a/MockupEngineer/templates/pixelbookgo/preview.png and b/MockupEngineer/templates/pixelbookgo/preview.png differ diff --git a/MockupEngineer/templates/prodisplayxdr/preview.png b/MockupEngineer/templates/prodisplayxdr/preview.png index 890fcae..306b927 100644 Binary files a/MockupEngineer/templates/prodisplayxdr/preview.png and b/MockupEngineer/templates/prodisplayxdr/preview.png differ diff --git a/MockupEngineer/templates/watchseries644mm/preview.png b/MockupEngineer/templates/watchseries644mm/preview.png index 64cb698..0186d7b 100644 Binary files a/MockupEngineer/templates/watchseries644mm/preview.png and b/MockupEngineer/templates/watchseries644mm/preview.png differ diff --git a/deploy.py b/deploy.py index c1d262c..b452284 100644 --- a/deploy.py +++ b/deploy.py @@ -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(): diff --git a/readme-template.md b/readme-template.md index 513db5d..8a2056f 100644 --- a/readme-template.md +++ b/readme-template.md @@ -10,6 +10,7 @@ ## 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 @@

Apple iPhone 12 Pro Max Mockup

+### 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 diff --git a/readme.md b/readme.md index 032c726..a72523a 100644 --- a/readme.md +++ b/readme.md @@ -10,6 +10,7 @@ ## 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 @@

Apple iPhone 12 Pro Max Mockup

+### 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 diff --git a/setup.py b/setup.py index 4e80e38..ee917f1 100644 --- a/setup.py +++ b/setup.py @@ -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',