I have an image folder that serves content, it contains jpeg, jpg and gif files. More files are added automatically all the time.
What I intend on doing is adding the following commands to crontab (with the appropriate file path of course)
mogrify -quality 80% "*.jpg"
mogrify -quality 80% "*.jpeg"
mogrify -quality 80% "*.gif"
I'd like to respectfully ask if anyone knows if these commands would end up processing files multiple times, so when a file is converted to 80%, then next time cron runs it reduces it further etc...
Does ImageMagick ensure it doesn't process the same file twice, and if not how do I deal with this given I can't rename the files.
Any help from the community would be greatly appreciated.
thank you.
Edited: Thanks to user: Sven for the answer below. This is the script I am now using that appears to be working:
Thank you for this. It appears that mogrify can write in place, preliminarily.
I will use this script:
#!/bin/bash
watchedFolder=[insert path here]
quality=70
while [ true ]
do
fileName=$(inotifywait -q -e create --format "%f" "$watchedFolder")
sleep 1s
mogrify -quality 80% "$watchedFolder/$fileName"
sleep 2s
echo "Processed " $fileName
sleep 2s
done