fix bug for resizing images.