Fixed calculation of imageSize