I\'m using a wp-cli tool in order to optimize images:
$ wp image-optimize batch --limit=20
I\'ve installed wpcli using composer so it\'s in an unu