diff --git a/aula200/ new.JPG b/aula200/ new.JPG new file mode 100644 index 0000000..88e7593 Binary files /dev/null and b/aula200/ new.JPG differ diff --git a/aula200/main.py b/aula200/main.py new file mode 100644 index 0000000..d56d700 --- /dev/null +++ b/aula200/main.py @@ -0,0 +1,26 @@ +# Pillow: redimensionando imagens com Python +# Essa biblioteca é o Photoshop do Python 😂 +from pathlib import Path + +from PIL import Image + +ROOT_FOLDER = Path(__file__).parent +ORIGINAL = ROOT_FOLDER / 'original.JPG' +NEW_IMAGE = ROOT_FOLDER / ' new.JPG' + +pil_image = Image.open(ORIGINAL) +width, height = pil_image.size +exif = pil_image.info['exif'] + +# width new_width +# height ?? +new_width = 640 +new_height = round(height * new_width / width) + +new_image = pil_image.resize(size=(new_width, new_height)) +new_image.save( + NEW_IMAGE, + optimize=True, + quality=70, + # exif=exif, +) diff --git a/aula200/original.JPG b/aula200/original.JPG new file mode 100644 index 0000000..a90bf44 Binary files /dev/null and b/aula200/original.JPG differ