How to fetch the data of a PNG PHAsset, which is cropped or adjusted?

33 Views Asked by At

I want to fetch the data of a PNG PHAsset with the code below, but it always returns the image data of the original image asset even if I have cropped it.

PHImageRequestOptions *options = [PHImageRequestOptions new];
options.networkAccessAllowed = YES;
options.deliveryMode = PHImageRequestOptionsDeliveryModeHighQualityFormat;
options.version = PHImageRequestOptionsVersionOriginal;

[[PHImageManager defaultManager] requestImageDataAndOrientationForAsset:asset 
                                                                options:options
                                                          resultHandler:^(NSData * _Nullable imageData,
                                                                          NSString * _Nullable dataUTI,
                                                                          CGImagePropertyOrientation orientation,
                                                                          NSDictionary * _Nullable info) {
    // ....
}];

I tried to use PHImageRequestOptionsVersionCurrent and got the right edited image, but the return value will lose the picture's transparency.

How can I ensure that I don't lose the transparency of an image while obtaining the correctly edited version?

0

There are 0 best solutions below