Bash scripting 7 – Image resize

So moving on to resizing images, I have created two scripts. The first extracts the image size from the photo metadata.

echo display metadata image size in photos
echo
echo "requires exiftool as a dependency"
echo "requires gm (graphics magick) as a dependency"


for file in *.JPG # apply to all files ending with JPG
do
    filename="${file%.*}"
    exiftool -TAG -s -ImageSize ${file}
done

The second script resizes each image to the specified new size. Then displays the new metadata to help confirm successful operation.

echo resize photos
echo
echo "requires exiftool as a dependency"
echo "requires gm (graphics magick) as a dependency"

for file in *.JPG # apply to all files ending with JPG
do
    filename="${file%.*}"
    gm mogrify -resize 1024x768 $file  
    exiftool -TAG -s -ImageSize ${file}
done

Tags

#Bash,#Bashscripting,#BatchProcessing,


MastodonPeertubeJoin Mastodon

AI statement : Consent is NOT granted to use the content of this blog for the purposes of AI training or similar activity. Consent CANNOT be assumed, it has to be granted.

Donate using Liberapay