Skip to content

Hexagon0000/multiple_image_process

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 

Repository files navigation

πŸ–ΌοΈ Image Processing and Organization Script

I am employing this script to systematically organize my AI-generated images based on their names and aspect ratios. The random image selection aspect of the script is crucial for my content creation process, where I generate textual content using these images. I aim to ensure diversity by utilizing a different image for each piece of content.

Crop and Rename Images by Aspect Ratio πŸ“

The script allows you to crop images based on specified aspect ratios and organize them into folders. The crop_image_by_ratio function takes an input image, calculates the desired crop dimensions, and saves the cropped images with new names based on the specified aspect ratios.

Copy and Rename Images with Subfolders πŸ“

The copy_and_rename_images function organizes images into subfolders, renaming them in a structured manner. It creates a main folder named "images" and subfolders for each image, with names like "image_1," "image_2," etc. The script renames the images based on the desired ratio and saves both the original and cropped images.

Choose Random Images 🎲

The choose_random_images function randomly selects a specified number of images from a source folder and copies them to a destination folder. This functionality is useful for creating a random set of images for various purposes.

Usage πŸš€

  1. Setup:

    • Install the required libraries: PIL (Pillow).
    • Ensure the script is in the same directory as your images or provide the correct source path.
  2. Configuration:

    • Set the src_path variable to the path containing your original images.
    • Specify the desktop_folder where the main "images" folder will be created.
    • Adjust the image_amount for the number of randomly chosen images.
    • Set the valid_image_extensions for the image file types you want to process.
    • Specify the desired_ratios for cropping images.
  3. Run the Script:

    • Execute the script to organize and process your images.

Example 🌈

# Specify the folder containing the original files
src_path = "/Users/ahmedefepetek/Desktop/Studio Ghibli Inspired Arts"
desktop_folder = "/Users/ahmedefepetek/Desktop"

# Random image amount
image_amount = 5
dst_path_for_random_images = (
    f"/Users/ahmedefepetek/Desktop/Random {image_amount} Images"
)

# Specify the valid image extensions
valid_image_extensions = [".png", ".jpg", ".webp"]

# Specify the desired aspect ratios
desired_ratios = [(9, 16), (3, 4), (4, 5)]

# Call the function with the specified folder and valid extensions
copy_and_rename_images(src_path, valid_image_extensions)

# Choose desired amount of images randomly and copy them to the destination folder
choose_random_images(src_path, dst_path_for_random_images, image_amount)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages