Skip to content
TheChatArchiveThe Chat Archive
Geminigemini-pro· GoogleHugging Face Arena Human Preference 55K

give me a python script that takes input folder path as static then downscale every…

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with gpt-4-0613’s answer.
  1. User

    give me a python script that takes input folder path as static

    then downscale every image in that folder with 50% and save as best quality jpg and overwrite image

  2. Gemini Assistant
    import os
    import sys
    from PIL import Image
    
    # Set the input folder path as a static variable
    input_folder_path = "path/to/input_folder"
    
    # Iterate over the files in the input folder
    for file in os.listdir(input_folder_path):
        # Check if the file is an image
        if file.endswith((".jpg", ".jpeg", ".png")):
            # Open the image
            image = Image.open(os.path.join(input_folder_path, file))
    
            # Downscale the image by 50%
            image = image.resize((int(image.width * 0.5), int(image.height * 0.5)))
    
            # Save the downscaled image as a high-quality JPG
            image.save(os.path.join(input_folder_path, file), "JPEG", quality=95)
    
            # Print a message to indicate that the image has been downscaled
            print(f"Downscaled {file} to 50% of its original size.")
    

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.