I have a script I've created that will pad a series of Jpgs, create a subdirectory in the working directory, move the padded Jpgs to the subdirectory, change to the subdirectory, and then use Imagemagick's convert command to overlay a single transparent .gif over the padded images. All but the last step works. If I run this script on one Jpg file it works correctly. But when I try it on multiple Jpgs it will only semi-work on one Jpg and not the others. I assume that I'm not using the correct naming variable in the last command, but I'm having no luck finding the correction.
Bash script:
#!/bin/bash
if yad \
--image "dialog-question" \
--title "Alert" \
--button=gtk-yes:0 \
--button=gtk-no:1 \
--text "Have you resized JPGs?"
then
convert *.jpg "$i" -bordercolor black -border 120x0 "pad$i.jpg"
mkdir -p ./padded; mv pad*.jpg $_
cd padded
cp /home/mastergif/ggg.gif /home/test/padded
convert ggg.gif *.jpg "$i" -background black -gravity center -compose dstover -composite $i*.jpg
exec bash
else
exit 1
fi
convert
command, but, from your description of the result, it sounds like you need to run the finalconvert
command once for each JPEG file (i.e., in a loop) rather than once for all the files. (2) What is$i
? (3) Why does your script doexec bash
?exec bash
is in there. I copied part of the script somewhere. I removed it from the script and the script runs fine, so I guess I don't need it.exec bash
runs a new shell, but it will look like the script returned. The new shell runs in the new subdirectory, because of thecd padded
above it. It's very confusing, but maybe it made sense for some situation.