another hack test1
another hack test1
import requests
from PIL import Image
website_url = "https://example.com/images/"
# Define the URL of the website containing the images you want to download
def organize_images_by_dimensions(input_folder):
for filename in os.listdir(input_folder):
input_path = os.path.join(input_folder, filename)
img = Image.open(input_path)
width, height = img.size
folder_name = f"{width}x{height}"
folder_path = os.path.join(input_folder, folder_name)
if not os.path.exists(folder_path):
os.mkdir(folder_path)
output_path = os.path.join(folder_path, filename)
shutil.move(input_path, output_path)
resize_folder = "resized"
os.makedirs(resize_folder, exist_ok=True)
resize_images(download_folder, resize_folder, target_size)
organize_images_by_dimensions(resize_folder)