objective-cios13uiimagejpegrepresentation

UIImageJPEGRepresentation not working in iOS 13.2.3


I am using the following code to convert UIImage to NSData:

imgData = UIImageJPEGRepresentation(image, 0.75);

The code is working fine with iOS 12.4, but when I try with it with iOS 13.2.3, it returns nothing.

Any help would be greatly appreciated.

Thank you.


Solution

  • After thoroughly examining and researching, it turned out that UIImageJPEGRepresentation with 0.75 compression was causing a crash due to large image size. Changing 0.75 to 0.1 solved the problem.