Automate image optimisation

(Mergeable version of #123)