Skip to content

Instantly share code, notes, and snippets.

@KentarouKanno
Created October 4, 2015 00:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KentarouKanno/104314f177e7d50a9fbb to your computer and use it in GitHub Desktop.
Save KentarouKanno/104314f177e7d50a9fbb to your computer and use it in GitHub Desktop.
let limitByte: Int = 1000000
var compressionQuality: CGFloat = 1.0
var data: NSData!
repeat {
data = UIImageJPEGRepresentation(images,compressionQuality)
print("Quality\((compressionQuality)) = \(data!.length)")
compressionQuality -= 0.1
} while data?.length > limitByte
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment