Optimization of cropping image