Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from pathlib import Path
- import requests
- from urllib.request import urlretrieve
- from PIL import Image
- """
- The flag does not have to be designed that way intentionally. You can do that with anything if there is a right-angled triangle on one side and the side below the right angle is not visible.
- """
- def download_pride_flag(file: Path):
- url = "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTxYy7T7Sbzgc3vA2PRtmiwU69CLRl88JIpWQ&s"
- urlretrieve(url, file)
- def process_image(image_path: Path, output_path: Path) -> None:
- with Image.open(image_path) as img:
- _, height = img.size
- img = img.crop((0, 0, height, height))
- new_img = Image.new("RGB", (height * 2, height * 2), (0, 0, 0))
- for x, y in [(1, 0), (1, 1), (0, 1), (0, 0)]:
- new_img.paste(img, (x * height, y * height))
- img = img.rotate(-90)
- new_img.save(output_path)
- if __name__ == "__main__":
- input_image = Path("flag.png")
- output_image = Path("output.png")
- if not input_image.exists():
- download_pride_flag(input_image)
- process_image(input_image, output_image)
- print(f"Processed image saved as {output_image}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement