简体   繁体   中英

How to get UIImage size in inches or UIImage resolution?

I want to compress my image and upload to server. This compression should be depended on the image size. Or it would help if we have any API in iPhone to get image resolution so that based on this resolution, i can set the compression rate.

Thanks Jithen

iOS SDK中没有提供给定像素的以英寸为单位的图像大小的方法,一种选择是确定您的应用在哪个设备上运行 ,然后为图像对象计算以英寸为单位的大小

You can get the size in points by image.size.width and image.size.height ...

To get the value in pixels, multiply those by image.scale . To get the size in inches, you can maybe multiply them by 1/264.0 instead (according to Wikipedia )...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM