Improve Resize output dimensions calculation