jaleel
jaleel

Reputation: 1187

Image size on Objective-C

How to get Image size in Objective-C.

I loaded one image using imagePicker, I want know the size of that image. (w*h)

is it possible?

Thanks & regards...

Upvotes: 3

Views: 4045

Answers (1)

brain
brain

Reputation: 5546

You implement the UIImagePickerControllerDelegate Protocol and in particular the imagePickerController:didFinishPickingMediaWithInfo: method. The last parameter in that method is a dictionary that includes an UImage references by the UIImagePickerControllerOriginalImage key. Get this UIImage* and get it's size property.

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {

    UIImage *image = (UIImage*) [info objectForKey:UIImagePickerControllerOriginalImage];
    //access width and height like this
    image.size.width;
    image.size.height;
}

Upvotes: 8

Related Questions