0

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.

Rob
  • 415,655
  • 72
  • 787
  • 1,044
Cemil Tatoglu
  • 65
  • 1
  • 10
  • Thank you very much for your reply. I am using Objective-C and when I check the documentation at https://developer.apple.com/documentation/uikit/uiimage/1624115-jpegdata it seems that the Objective-C counterpart is the same as my code , wouldn't there be any other alternatives? Thank you – Cemil Tatoglu Dec 05 '19 at 06:48
  • Check https://stackoverflow.com/a/58048339/2152616 it says that the issue has been solved in 13.1 – Onur Tuna Dec 05 '19 at 07:26
  • Does this answer your question? [UIImageJPEGRepresentation and UIImagePNGRepresentation returns nil in iOS 13](https://stackoverflow.com/questions/58012911/uiimagejpegrepresentation-and-uiimagepngrepresentation-returns-nil-in-ios-13) – Onur Tuna Dec 05 '19 at 07:27
  • Hi, thank you. I have already checked this answer and unfortunately, it is not working with iOS 13.2.3 . – Cemil Tatoglu Dec 05 '19 at 07:38

1 Answers1

0

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.

Cemil Tatoglu
  • 65
  • 1
  • 10