I have a simple bash script running a command in ImageMagick. It takes an image (INFILE - typically a .tif), resizes it, and saves the result (OUTFILE - typically a .jpg)
INFILE=/path/'image name.tif'
OUTFILE=/path/'image name.jpg'
echo INFILE="${INFILE}" OUTFILE="${OUTFILE}"
magick -quiet "${INFILE}" \
-filter LanczosRadius \
-distort resize 1600 \
-quality 92 \
"${OUTFILE}"
The name of this script is Magick-Resize.sh
I would like to batch process a number of images using this script - that is, run it on multiple INFILES. Eg. If I have 100 images in a folder, I would like each of them to be processed once by this script, producing a unique OUTFILE for each.
I am very much a novice in bash. I gave it a crack with the below:
INSCRIPT=/path/Magick-Resize.sh
echo INSCRIPT="${INSCRIPT}"
for INFILE in *.tif; do
if [[ "$INFILE" = *-tagged.tif ]]; then
continue # skip output
fi
name=$(basename "$INFILE")-tagged.jpg
echo name="${name}"
"${INSCRIPT}" "$INFILE" > "${name}"
done
But in a test folder containing two .tif images, all it output was one image with the filename "*.jpg"
Is anyone able to provide a solution?
I'm on Mint 20.3