问题
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