UIImageJPEGRpresentation error in Share extension on iPhone SE

I have a sharing extension that allows you to crop the image and then upload it to our service. We call UIImageJPEGRepresentationto get image data before loading it, but it crashes due to excessive memory. This only happens with large images and (as far as we can tell) on SE, and didReceiveMemoryWarningnot called the first. This happens when using the Photos app.

In any case, is it safe to call UIImageJPEGRepresentationor try to determine if the image is too large?

+4
source share
1 answer

? , .

let image: Data = UIImagePNGRepresentation(image)
var imageSize: Double = (image.length)/1024 // in KB
0

Source: https://habr.com/ru/post/1663780/


All Articles