import requests import os def download_lorem_picsum_images(count, width, height, output_folder): # Create the output folder if it doesn't exist if not os.path.exists(output_folder): os.makedirs(output_folder) for i in range(21, count): # Construct the URL for the specific image size url = f'https://picsum.photos/{width}/{height}' # Fetch the image data response = requests.get(url) if response.status_code == 200: # Save the image to the output folder image_path = os.path.join(output_folder, f'picsum_image_{i+1}.jpg') with open(image_path, 'wb') as img_file: img_file.write(response.content) print(f"Downloaded image {i+1}/{count} to {image_path}") else: print(f"Failed to download image {i+1}/{count}") print("Download complete.") # Usage k = int(input("Kolik obrázků stáhnout? : ")) size = int(input("Rozměr obrázků: ")) download_lorem_picsum_images(k, size, size,"images")