Answer the question
In order to leave comments, you need to log in
Recursively apply a watermark overlay script to all pictures in a folder?
There is such a script, it's normal and puts a watermark on the image, I need to go recursively inside the folder through the folders, even I'm stupid, help, alarm.
for image in *png *jpg *gif
do
if [ -s $image ] ; then # ненулевой размер файла
width=$(identify -format %w $image)
convert -background '#0008' -fill white -gravity center \
-size ${width}x30 caption:AskDaveTaylor.com \
$image +swap -gravity south -composite new-$image
mv $image $savedir
mv new-$image $image
echo "На изображение $image успешно нанесен водяной знак"
fi
done
Answer the question
In order to leave comments, you need to log in
In short, he himself answered his own question
vodyanoy - this is what to write
/ tmp - the way
for i in `ls /tmp -ld $(find . -regex ".*\(jpg\|jpeg\|JPG\|JPEG\|png\|PNG\)")`
do
echo $i
if [ -s $i ] ; then # ненулевой размер файла
width=$(identify -format %w $i)
convert -background '#0008' -fill white -gravity center \
-size ${width}x30 caption:vodyanoy \
$i +swap -gravity south -composite new-$image
mv new-$image $i
echo "На изображение $i успешно нанесен водяной знак"
fi
done
find /tmp -type f -regex ".*\(jpg\|jpeg\|JPG\|JPEG\)" -exec jpegoptim --preserve --preserve-perms --max=85 {} \;
/tmp
find
to search recursively from the current directory -type f
- display only files -regex ".*\(jpg\|jpeg\|JPG\|JPEG\)"
- well, the regular expression here is shorter -exec
to execute with the found one - jpegoptim --preserve --preserve-perms --max=85
my command {}
is the place where you substitute the found file, \;
end
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question