New code to handle scaling images on upload