Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
UIImageJPEGRepresentation wrapped within an Autorelease Pool
func UIImageToDataJPEG2(image: UIImage, compressionRatio: CGFloat) -> Data? {
return autoreleasepool(invoking: { () -> Data? in
return UIImageJPEGRepresentation(image, compressionRatio)

This comment has been minimized.

Copy link

@santhoshs5 santhoshs5 commented Jul 13, 2017

Dear benbahrenburg,

I am also facing memory issues with compression I am reducing the size of the image first and then getting data with UIImageJPEGRepresentation applying metadata on this data cgimage properities. I am doing this using OpeationQueue for each operation does this job and upload to the server.Some times memory is going 400 to 500 MB. But the same code is working perfectly in Objective C .Can you tell me what can be my issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment