Created
August 16, 2023 15:39
-
-
Save cpietsch/7732afd0a638f29c9e4f3bbddf5efd90 to your computer and use it in GitHub Desktop.
bash script to extract automatic1111 output image metadata and generate a csv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Path to the directory containing folders with images | |
base_dir="/home/jovyan/stable-diffusion-webui/outputs/txt2img-images" | |
# Path to the ExifTool executable | |
exiftool_path="/home/jovyan/Image-ExifTool-12.65/exiftool" | |
# Loop through each folder in the base directory | |
for folder in "$base_dir"/*; do | |
if [ -d "$folder" ]; then | |
folder_name=$(basename "$folder") | |
csv_file="$folder_name.csv" | |
# Write CSV header | |
echo "ImageName,Parameters" > "$csv_file" | |
# Loop through PNG files in the folder | |
for image in "$folder"/*.png; do | |
if [ -f "$image" ]; then | |
parameters=$($exiftool_path -Parameters "$image" | awk -F ': ' '{print $2}') | |
echo "$(basename "$image"),$parameters" >> "$csv_file" | |
fi | |
done | |
echo "CSV file '$csv_file' created for folder '$folder_name'" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
install Image-ExifTool or download it