Created
March 5, 2017 23:52
-
-
Save benbahrenburg/7820832ed3d3c27645f16571cbc04ae6 to your computer and use it in GitHub Desktop.
UIImageJPEGRepresentation wrapped within an Autorelease Pool
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func UIImageToDataJPEG2(image: UIImage, compressionRatio: CGFloat) -> Data? { | |
return autoreleasepool(invoking: { () -> Data? in | |
return UIImageJPEGRepresentation(image, compressionRatio) | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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?