Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIImage.size different from pixel resolution?

Tags:

ios

swift

uiimage

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?

like image 392
DanielZanchi Avatar asked Jun 08 '26 03:06

DanielZanchi


1 Answers

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.

like image 79
rkyr Avatar answered Jun 10 '26 16:06

rkyr