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."

sanjihan
  • 113
  • 5

2 Answers2

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.

Sven
  • 98,649
  • 14
  • 180
  • 226
  • _multicore support (via OpenMP) and Intel SSE optimizations_ https://github.com/pornel/pngquant – Lenniey May 10 '17 at 16:18
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
rudimeier
  • 250
  • 1
  • 9