Moved all logic to ResizeImage