Home Ask Login Register

Developers Planet

Your answer is one click away!

Mitesh Dobareeya February 2016

How to get Original Image and media type from PHAsset?

My **GMImagePickerController** returns the list of selected images from photos app.

The code are as follows.

  - (void)assetsPickerController:(GMImagePickerController *)picker  didFinishPickingAssets:(NSArray *)assetArray
        NSLog(@"GMImagePicker: User ended picking assets. Number of selected items is: %lu", (unsigned long)assetArray.count);

The assetArray return result like this, I selected 3 images from photos app

"<PHAsset: 0x7fa39e02e840> 1AEEF04A-F8AB-4019-AAB5- 2875CFD8F8E3/L0/001 mediaType=1/0, sourceType=1, (425x425), creationDate=2016-02-03 13:53:17 +0000, location=0, hidden=0, favorite=0 ",
"<PHAsset: 0x7fa39e02c840> 50489C13-55D0-4518-B290-B01B99D66996/L0/001 mediaType=1/0, sourceType=1, (425x335), creationDate=2016-02-03 13:53:08 +0000, location=0, hidden=0, favorite=0 ",
"<PHAsset: 0x7fa39e02c750> D0A466B2-9CF2-4FD9-A12F-07921A1D0E8F/L0/001 mediaType=1/0, sourceType=1, (425x365), creationDate=2016-02-03 13:53:04 +0000, location=0, hidden=0, favorite=0 "

Now the problem is I want to get OriginalImage and mediaType from above result to store image into document directory. Please help me to solve this problem.


Mitesh Dobareeya February 2016


for(int i=0;i<assetArray.count;i++)
    self.requestOptions = [[PHImageRequestOptions alloc] init];
    self.requestOptions.resizeMode   = PHImageRequestOptionsResizeModeExact;
    self.requestOptions.deliveryMode = PHImageRequestOptionsDeliveryModeHighQualityFormat;

    // this one is key
    self.requestOptions.synchronous = true;

    //  self.assets = [NSMutableArray arrayWithArray:assets];
    PHImageManager *manager = [PHImageManager defaultManager];
    Albumimages = [NSMutableArray arrayWithCapacity:[assetArray count]];

    // assets contains PHAsset objects.
    __block UIImage *ima;

    for (PHAsset *asset in assetArray) {
        // Do something with the asset

        [manager requestImageForAsset:asset
                        resultHandler:^void(UIImage *image, NSDictionary *info) {
                         //retrive all  images   
                     ima = image;



Using PHImageManager we can get full original image.

Post Status

Asked in February 2016
Viewed 3,334 times
Voted 9
Answered 1 times


Leave an answer

Quote of the day: live life