From 8347ad23146660472e56f088647c18a3cf8fd9d1 Mon Sep 17 00:00:00 2001 From: Danilo Reyes Date: Tue, 16 Jul 2024 15:10:40 -0600 Subject: [PATCH] conversion ignores videos --- photos-metadata.sh | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/photos-metadata.sh b/photos-metadata.sh index bd10d34..3ead96f 100755 --- a/photos-metadata.sh +++ b/photos-metadata.sh @@ -76,11 +76,17 @@ log_change() { # Function to handle errors and convert images to JPEG using ImageMagick handle_conversion_error() { photo="$1" - new_photo="${photo%.*}.jpg" - echo "Converting $photo to $new_photo using ImageMagick." -mogrify -format jpg "$photo" - mv "${photo%.*}.jpg" "$new_photo" - rm "$photo" + file_type=$(file --mime-type -b "$photo") + + if [[ $file_type == image/* ]]; then + new_photo="${photo%.*}.jpg" + echo "Converting $photo to $new_photo using ImageMagick." + mogrify -format jpg "$photo" + mv "${photo%.*}.jpg" "$new_photo" + rm "$photo" + else + echo "File is a video or unsupported type: $photo. Skipping conversion." + fi } # Loop through each year directory