remove duplicate calculation of image_ratio