Preparing git repo for final project

This commit is contained in:
2023-07-09 11:19:26 +02:00
parent 6a38966eef
commit 63d06d6b35
67 changed files with 1587 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 980 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

View File

@@ -0,0 +1,43 @@
import os
import sys
import PIL
from PIL import Image
def main():
try:
input_file_name, output_file_name = sys.argv[1:3]
except (IndexError, ValueError):
print("Too few command-line arguments")
sys.exit(1)
if len(sys.argv) > 3:
print("Too many command-line arguments")
sys.exit(1)
if not os.path.isfile(input_file_name): # Or try opening and catch FileNotFoundError
print(f"Input does not exist")
sys.exit(1)
if not (any(input_file_name.lower().endswith(format) for format in (".jpg", ".jpeg", ".png")) and any(output_file_name.lower().endswith(format) for format in (".jpg", ".jpeg", ".png"))):
print(f"Invalid input")
sys.exit(1)
if (input_file_name[-4] == '.' and input_file_name[-4:] != output_file_name[-4:]) or (input_file_name[-3] == '.' and input_file_name[-3:] != output_file_name[-3:]):
print(f"Input and output have different extensions")
sys.exit(1)
overlap_t_shirt(input_file_name, output_file_name)
"""Open the input with Image.open, per pillow.
resize and crop the input with ImageOps.fit, per pillow.readthedocs.io/en/stable/reference/ImageOps.html#PIL.ImageOps.fit,
using default values for method, bleed, and centering, overlay the shirt with Image.paste,
per pillow.readthedocs.io/en/stable/reference/Image.html#PIL.Image.Image.paste,
and save the result with Image.save, per pillow.readthedocs.io/en/stable/reference/Image.html#PIL.Image.Image.save."""
def overlap_t_shirt(input_file_name, output_file_name):
image = Image.open(input_file_name)
shirt = Image.open('shirt.png')
image = PIL.ImageOps.fit(image, size=shirt.size)
image.paste(shirt, mask=shirt)
image.save(output_file_name)
if __name__ == "__main__":
main()