guard let cgImage = image.CGImage else{ return nil } let width = CGImageGetWidth(cgImage) let height = CGImageGetHeight(cgImage)
CGImageGetWidth和CGImageGetHeight将返回与image.size * image.scale返回的相同大小(以像素为单位).