#!/bin/bash input_dir="$1" # Replace with your input directory path output_dir="$2" # Replace with your output directory path # Ensure the output directory exists or create it mkdir -p "$output_dir" # Loop through all JPEG files in the input directory for file in "$input_dir"/*.jpg; do if [ -e "$file" ]; then filename=$(basename "$file") filename_without_extension="${filename%.*}" output_file1="$output_dir/${filename_without_extension}_left.jpg" output_file2="$output_dir/${filename_without_extension}_right.jpg" # Get the width of the image width=$(identify -format "%w" "$file") # Use ImageMagick to split the image in half convert "$file" -crop "50%x100%+0+0" "$output_file1" convert "$file" -crop "50%x100%+$((width / 2))+0" "$output_file2" echo "Split $filename into $output_file1 and $output_file2" fi done echo "Splitting completed."