0

I am running a command (pngquant to be precise: https://github.com/pornel/pngquant) in a terminal window. I noticed, that if I open 4 terminal windows, and run pngquant command in each of them, I get 4x speed increase, effectively compression 4 times as many images in the same time as before.

So I used this approach and assigned each pngqunat process a portion of images I want to compress, effectively creating multiple processes on multiple threads

Can you run command on multiple threads without doing this tricks that I did? I would like to just say "run pngquant compression on all this images and use all threads avalable."

2 Answers 2

0

In your case it should be simple to use GNU xargs. Here an example using 4 threads (-P4)

find . -name "*.png*" -not -name "*8.png" -print0 | xargs -0 -n1 -P4 pngquant 64
3

This is only possible if the developer of the tool developed it with multithreading capabilities, which appears to not be the case for your tool.

However, in many cases you can use something like GNU Parallel to overcome this limitation and it will automate this for you.

1

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.