Advertisement
DeaD_EyE

pride-flag

Jun 30th, 2025 (edited)
404
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.22 KB | None | 0 0
  1. from pathlib import Path
  2. import requests
  3. from urllib.request import urlretrieve
  4. from PIL import Image
  5.  
  6. """
  7. 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.
  8. """
  9.  
  10. def download_pride_flag(file: Path):    
  11.     url = "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTxYy7T7Sbzgc3vA2PRtmiwU69CLRl88JIpWQ&s"
  12.     urlretrieve(url, file)
  13.  
  14.  
  15. def process_image(image_path: Path, output_path: Path) -> None:
  16.     with Image.open(image_path) as img:
  17.         _, height = img.size
  18.         img = img.crop((0, 0, height, height))    
  19.         new_img = Image.new("RGB", (height * 2, height * 2), (0, 0, 0))
  20.        
  21.         for x, y in [(1, 0), (1, 1), (0, 1), (0, 0)]:
  22.             new_img.paste(img, (x * height, y * height))
  23.             img = img.rotate(-90)
  24.        
  25.         new_img.save(output_path)
  26.  
  27.  
  28. if __name__ == "__main__":
  29.     input_image = Path("flag.png")
  30.     output_image = Path("output.png")
  31.    
  32.     if not input_image.exists():
  33.         download_pride_flag(input_image)
  34.    
  35.     process_image(input_image, output_image)
  36.     print(f"Processed image saved as {output_image}")
  37.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement