Automatically optimizing the images