DanielZanchi
DanielZanchi

Reputation: 2768

UIImage.size different from pixel resolution?

I'm resizing an UIImage, after the resizing if I print the size:

print(myImage.size)

I get the output:

(295.5, 350.0)

After saving the image I check the resolution and I get: 555 × 700 pixels

Isn't the UIImage.size the resolution of the image?

Upvotes: 3

Views: 1556

Answers (1)

rkyr
rkyr

Reputation: 3251

To get pixel resolution of your image you could use next snippet:

let image: UIImage = ...
let size = CGSize(width: image.size.width * image.scale, height: image.size.height * image.scale)

It takes into account image's scale value.

Upvotes: 5

Related Questions