Search code examples
swiftnetworkingswiftuiimage-resizingimage-size

Should I resize images from camera / photo library before sending over network?


The images I am getting back from the photo library and camera are HUGE, and it takes a significant amount of time to send them over the network even in good conditions. I can't imagine a scenario in which I would need the full double-digit MB image, but maybe I'm missing something? Is it common practice to resize them before sending them over the network?


Solution

  • You can transform the image into data and then use this:

        let imageData = image!.jpegData(compressionQuality: 0.5)!
    

    It will make the quality less than usual with 50% to be able to save it quickly and smoothly