Categories
ios swift

How do I upscale an image in ImageIO iOS framework?

I went through the usual process of progressively discovering the best performing Image resizing solution in iOS and I ended up with ImageIO.

The following works well

if let currentImage = CGImageSourceCreateWithData(imageData, nil)
//...some code that extracts the existing size, and based on my maximum expected horizontal size..calculates a new horizontal/vertical maximum size..
let options: CFDictionary = [kCGImageSourceThumbnailMaxPixelSize as NSString : maximumImageWidthOrHeight,
kCGImageSourceCreateThumbnailFromImageAlways as NSString : true]
CGImageSourceCreateThumbnailAtIndex(image, options)

but only for down-sampling.

If I have an image that is full HD ie. 1920 x 1080, it is resized (with aspect ratio kept) so that it fits into 320 px horizontaly, because this is what I set to be the maximum horizontal size.

However if I pass in an image that is 16 pixels x 9 pixels.. a really small one (and having a 16:9 aspect ratio obviously). This image is not resized.

I want to it to be resized to 320 x 180 pixels.

Is there a combination of options/ a missed method call / anything that will give me that in the imageIO framework?