Fix a bug in image resize