Last active
December 25, 2024 14:39
-
-
Save pax/384dfa1ecea6bdafd44d810850303932 to your computer and use it in GitHub Desktop.
adds 2 frames with blended opacity in between each 2 jpg images in a folder
This file contains hidden or 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 | |
# adds 2 frames with blended opacity in between each 2 jpg images in a folder | |
if [ "$#" -ne 1 ]; then | |
echo "Usage: $0 <input_directory>" | |
exit 1 | |
fi | |
input_dir="$1" | |
if [ ! -d "$input_dir" ]; then | |
echo "Error: Directory '$input_dir' does not exist." | |
exit 1 | |
fi | |
output_dir="morphed_frames" | |
mkdir -p "$output_dir" | |
images=( "$input_dir"/*.jpg ) | |
num_images=${#images[@]} | |
morph_frames=2 # Number of intermediate frames between each pair | |
if [ "$num_images" -lt 2 ]; then | |
echo "Not enough images to process (need at least 2)." | |
exit 1 | |
fi | |
for ((i=0; i<$num_images-1; i++)); do | |
img1="${images[$i]}" | |
img2="${images[$((i+1))]}" | |
magick "$img1" "$img2" -morph "$morph_frames" "$output_dir/morph_${i}_%02d.jpg" | |
done | |
echo "Morphing complete. Check the '$output_dir' folder." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment