Resize image. fix a bug in Safari.