When you select an image from the UIImageController and calculate its size, the image resizes, that is, the image size on the disk is different.
Is there any way to get the right size?
What I tried -
- Convert an image to data using
UIImagePNGReprensentation and UIImageJPEGReprensentation . The problem with this approach is
a. This approach is memory consumed, so it looks good.
b. The size varies, I can understand that it converts the image into data and then calculates the size, so the size is different.
But no matter what I was looking for, all the accepted answers are just around this.
- Using
ALAssetsLibrary to get the image size, but the size calculated from this also does not match the disk size.
I used the following method - assetForURL: resultBlock:^(ALAsset *asset) failureBlock:
- Using the
CGImageRef methods CGImageRef , but this also does not give the desired result.
Any other approach I missed?
EDIT -
So here is the size difference -
when I check the image size in finder - 5.3 MB
when I check the size of a UIImage object with -
UIImageJPEGRepresentation (Image 1.0) - 2.29 MB
When I check image size using ALAsset library - 4.4 MB
source share