articles
articles copied to clipboard
The article, although helpful - misses its original promise - more discussion is needed.
Like all those "StackOverflow" questions+answers about Image resizing - this one too focuses on the same mainstream dull use for images - display. This is not really "Scale an image", but rather "display a smaller version of the image". But there are many important other uses for image scaling, with different assumptions and start-points, that would greatly influence the right technique to use. I'd like these covered too.
Of special interest (to me, in my project!) is the need to scan through the user's large photos' library (as Assets at first), analyzing (using CoreML models, and many direct pixel-analysis algorithms, looking for objects, Applying modifications, reading text off objects, and so on). Images that will NEVER will be displayed, but must be scaled down, to get the right performance. An "Image processing Engine". What is the correct technique here?
Another very popular need for scaling is in a chain coming from live video input. The need to scale (and otherwise manipulate) high quality images, in a chain that never has any "URL" or other File/Internet input - things are in memory all the time, and caching is of no use - what to use here? output may also be file (as opposed to display).
Yet another scenario is where you want to scale down images, to make them small enough you could pass them through network connection (uploads, streaming, etc.) There you must have these output scaled images as pixel-maps in RAM (not on the GPU).
I was so happy to see this new article coming out, but quite disappointed in the end. Also - no attempt was made to explain the rather huge difference in performance between the techniques - it's about 12 times faster to use UIGraphicsImageRenderer than using accelerate vImage... how come? how can low-level be slower than high-level? that's counterintuitive because the "higher level" knows less of your intentions, and surely doesn't cover all scenarios.
I'd like to see the article revised a little, adding more about different (quite common) scenarios, and more ideas for helping us to choose the right solution.
Thanks for your feedback, @Motti-Shneor. Those are all, indeed, interesting topics worthy of further discussion. To be clear, the article published last Monday wasn't a new article, but rather an update to an existing article that gets a significant amount of organic traffic, but had — up until last week — been woefully out of date with its code samples. The update was more triage than anything else.
The article focuses on downsampling images for display because that's far and away the most important use case for the majority of my readers. For other use cases, such as the ones you described, my intention was to provide working examples of various techniques that might serve as a starting point for further evaluation.
I'm certainly interested in exploring those other use cases more clearly, providing more insight into why you'd use one technique over another, and exploring the differences between processing images in RAM vs. loading from disk. And I look forward to revisiting this article again soon.