The aspect ratio is calculated wrong. You should cast the dimensions to floats instead to int's to get the correct aspect ratio.