How to get UIImage size in inches or UIImage resolution?

て烟熏妆下的殇ゞ 提交于 2019-12-24 14:36:00

问题


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


回答1:


There is nothing in iOS SDK to give you image size in inches from given pixel, one option is to determine on which device your app is running and then calculate size in inches for you image object.




回答2:


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)...



来源:https://stackoverflow.com/questions/15336789/how-to-get-uiimage-size-in-inches-or-uiimage-resolution

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!