0

I run the following command to compress jpg file:

convert -strip -interlace Plane -gaussian-blur 0.05 -quality 85% source.jpg result.jpg

How to execute it for all jpg files in the directory where compressed file name will be define this way: Old_Name_Compressed.jpg

  • 1
    What have you tried? How did it not work as expected or intended? – DopeGhoti Apr 30 '19 at 19:06
2

using find and execute convert command for each file found.

find . -type f -name '*.jpg' -exec bash -c 'convert -strip -interlace Plane -gaussian-blur 0.05 -quality 85% "$1" "${1%.jpg}_compressed.jpg" ' bash  {} \;

${parameter%suffix} is known as bash-parameter-expansion, that strips shortest suffix from its parameter.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.