guard let image = UIImage(named: "someImage") else { return } // BAIL let data = UIImageJPEGRepresentation(image,1.0)
数字应在0.0到1.0之间,并设置jpeg质量
—更新—
从Swift 3.1开始仍然有效