The app downloads images from the web and shows them in a table view as thumbnails. However, the quality of these image are "too good". They are HD quality and if there are too many images in a table view, it might slow down the UI a bit.
Before I set the image to a cell, how to make it "less quality"? (occupying less memory & requiring less processing power to show them)
I tried something like this:
let smallerImage = UIImage(CGImage: image.CGImage!, scale: 0.2, orientation: image.imageOrientation)
but it's not working as expected. What's the right way to do it?
Here is my working code from an old project from before the Swift era. An extra parameter maxLength passes the maximum height and width to use (for portrait it's max height, for landscape it's max width). Hope you know how to translate from Ojbective-C to Swift:
Applying such scaling does indeed limit the total memory consumed by the thumbnails.