Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the Size (KB) of UIImage

I am getting Image from didFinishPickingMediaWithInfo.

UIImage *originalImage = (UIImage*)[info valueForKey:UIImagePickerControllerOriginalImage];

I want to get the size of Image in Kb.

like image 931
Amir iDev Avatar asked Feb 19 '13 12:02

Amir iDev


People also ask

What is UIImage?

An object that manages image data in your app.

How do I find my UIImage path?

Once a UIImage is created, the image data is loaded into memory and no longer connected to the file on disk. As such, the file can be deleted or modified without consequence to the UIImage and there is no way of getting the source path from a UIImage.

How do I resize the UIImage to reduce upload image size?

It reduces the image size to less than 100kb. It works proportionally! extension UIImage { class func scaleImageWithDivisor(img: UIImage, divisor: CGFloat) -> UIImage { let size = CGSize(width: img. size.


1 Answers

    UIImage *originalImage = (UIImage*)[info valueForKey:UIImagePickerControllerOriginalImage];
    NSData *imgData = UIImageJPEGRepresentation(originalImage, 1); //1 it represents the quality of the image.
    NSLog(@"Size of Image(bytes):%d",[imgData length]);
    imgData = nil;
like image 195
Mutawe Avatar answered Sep 22 '22 17:09

Mutawe