Revert "Revert "Image optimization""

This reverts commit 9adfcf8ddc474021f185fec5d12033e4b382150c.